Skip to content

[JENKINS-56736] strage behavior of manager.logContains() API in Groovy Post Build plugin #180

@jenkins-infra-bot

Description

@jenkins-infra-bot

Hi,

 

Trying to use Groovy Post build plugin in order to parse build output log in reverse order. 

manager.logContains seems not to be suitable for my since it always parse the log from the begging and I am using a variable in my scripted pipeline as a matcher which needs to be updated with latest value found in the console output. This seems not to be happening. 

The scenario is: in the same build log I have several text lines like: Failed: *. In case I find Failed: 0, I do something, in case of Failed: anything but 0, I do something else. 

Using: 

if(manager.logContains(".Failed: 0.")) {if(manager.logContains(".Failed: 0.")) {     println "No failure"     println "+++++ ${manager.logContains(".Failed: 0.")}" } else if(matcher?.matches()){            echo 'Matches!!'                buildMsg=matcher.group(1).toInteger()            if ((buildMsg - failure)> 0)

{           println 'There are tests failed!'        //   manager.buildUnstable()          throw new RuntimeException("Failed")           }

    }

this does not work properly. Can you please help to solve this?

 

Thank you!


Originally reported by geanina, imported from: strage behavior of manager.logContains() API in Groovy Post Build plugin
  • assignee: wolfs
  • status: Open
  • priority: Major
  • component(s): groovy-postbuild-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 20251216-225446
Raw content of original issue

Hi,

 

Trying to use Groovy Post build plugin in order to parse build output log in reverse order. 

manager.logContains seems not to be suitable for my since it always parse the log from the begging and I am using a variable in my scripted pipeline as a matcher which needs to be updated with latest value found in the console output. This seems not to be happening. 

The scenario is: in the same build log I have several text lines like: Failed: *. In case I find Failed: 0, I do something, in case of Failed: anything but 0, I do something else. 

Using: 

if(manager.logContains(".Failed: 0.")) {if(manager.logContains(".Failed: 0.")) {     println "No failure"     println "+++++ ${manager.logContains(".Failed: 0.")}" } else if(matcher?.matches()){            echo 'Matches!!'                buildMsg=matcher.group(1).toInteger()            if ((buildMsg - failure)> 0)

{           println 'There are tests failed!'        //   manager.buildUnstable()          throw new RuntimeException("Failed")           }

    }

this does not work properly. Can you please help to solve this?

 

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions