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.
实际上可以使用currentBuild.rawBuild.log
或更好(未弃用) currentBuild.rawBuild.getLog(100)
(最后 100 行),参考:http ://javadoc.jenkins-ci.org/hudson/model/运行.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 eg count how often a log file contains a special string.
Not currently. (Properties of currentBuild
are documented under Snippet Generator » Global Variables by the way.)
It could be implemented, fairly easily, though it would not scale well with huge builds. JENKINS-28119 would provide a more scalable solution to what I am guessing your underlying request is.
由于 Jenkins 为您提供了BUILD_URL
,您可以下载它:
sh('wget -q --no-check-certificate -O build.log ' + BUILD_URL + 'consoleText')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.