Search code examples
jenkinsgroovyjenkins-pipelinejenkins-cli

get String value from Jenkins console output


In the Jenkins output, I had the following assert error enter image description here

but I need to get the String error from the error assert or any text. I'm using I'm My JenkinsFile:

def matcher = manager.getLogMatcher('.*Delete organization Account failed: *')

but generates the following error: enter image description here

So I just want to check, that the log contains a specific string and if the texts exists make the build failed currentBuild.result = "FAILED", saving the text to send it by slack


Solution

  • You can put the condition in below way :

     if (manager.logContains('.*Delete organization Account failed:*')) {
              error("Build failed because of Delete organization Account..")    
                    }