Is there any builtin variable that gives access to the text of the currently executing build?
I tried using something like currentBuild.log
, currentBuild.buildLog
but without any luck.
In Jenkins, in the pipeline where failure occurred, in the pane, select the latest build, and click Console Output. On the Console Output page, check the logs to find the reason for the failure. If required, update the parameters in the deployment input configuration file.
Now open a new tab in your web browser and type the URL http://192.168.33.10/logs/jenkins. You will see all the content of the Jenkins server /var/log/jenkins folder, including the jenkins. log file!
currentBuild is a global variable that may be used to refer to the currently running build.
Actually it is possible using currentBuild.rawBuild.log
or better (not deprecated) currentBuild.rawBuild.getLog(100)
(for the last 100 lines), reference: http://javadoc.jenkins-ci.org/hudson/model/Run.html#getLog-int-
I searched a lot for a solution to analyze the log.
rawBuild
was not OK, because I want to execute my scripts in a sandbox without additional approvalstee
in the steps, that I want to analyse was not OK, because I don't want to modify previous steps, nor I don't want to have my whole log in RAM (and unfortunately I needed that on a Windows machine)I found a solution inspired by Jesse Glicks answer:
manager
-variable allows you to analyse the log by using manager.logContains(regexp)
or manager.getLogMatcher(regexp)
myTestString
you can just call manager.logContains('.*myTestString.*')
manager.getLogMatcher(regexp)
Unfortunately I found no way to analyze the whole log (getLogMatcher
returns only the first matching line Matcher). So I see currently no way to e.g. count how often a log file contains a special string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With