Jenkinsfile Creation Log

Is there a built-in variable that provides access to the text of the current executable assembly?

I tried using something like currentBuild.log , currentBuild.buildLog , but with no luck.

+7
jenkins jenkins-pipeline jenkins-workflow jenkinsfile
source share
3 answers

Actually, you can use currentBuild.rawBuild.log or better (not outdated) currentBuild.rawBuild.getLog(100) (for the last 100 lines), link: http://javadoc.jenkins-ci.org/hudson/model/Run .html # getLog-int-

+2
source share

I searched a lot for a solution to analyze the log.

  • use rawBuild not normal because I want to execute my scripts in a sandbox without additional statements
  • using tee in the steps that I want to analyze was not quite so, because I do not want to change the previous steps, and I do not want my entire log to be in RAM (and, unfortunately, I need this on a Windows machine)

I found a solution that Jesse Glakes answered:

  • In my.jenkins.url / pipeline-syntax / globals you can see that manager -variable allows you to parse the log using manager.logContains(regexp) or manager.getLogMatcher(regexp)
  • So, if you just want to verify that your log contains the string myTestString , you can simply call manager.logContains('.*myTestString.*')
  • If you want to get some information from the first relevant line, you can use manager.getLogMatcher(regexp)

Unfortunately, I did not find a way to getLogMatcher entire log ( getLogMatcher returns only the first matching Matcher string). Therefore, I currently see no way, for example, count how often the log file contains a special line.

+3
source share

Not at present. (The currentBuild properties currentBuild described in the currentBuild Generator section.) Global variables, by the way.)

It can be implemented quite easily, although it will not scale well with huge builds. JENKINS-28119 will provide a more scalable solution for me guessing your basic request.

+2
source share

All Articles