开发者

Who's the user that executed Jenkins job

开发者 https://www.devze.com 2023-04-11 01:54 出处:网络
I need to include information about the user that executed 开发者_JAVA百科Jenkins job inside JAR Manifest among other things

I need to include information about the user that executed 开发者_JAVA百科Jenkins job inside JAR Manifest among other things

What variable I need to read it off?


You can query Jenkins via its api. See http://[jenkins-host]/api or https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API for help. The information you need is contained there.

To get a feel for it, enter http://[jenkins-host]/api/xml?depth=2 and search for "started by" on the page (make sure set the depth to at least 2).

You will need to get that information via a script in your build and then parse it based on the build id.

There already exists Python wrapper for that sort of thing: http://packages.python.org/python-jenkins/

Here's also an XPath expression that will parse out the "started by..." info by BUILD_ID:

http://[jenkins-host]/api/xml?depth=2&xpath=//build/id[text()='BUILD_ID']/../action/cause/shortDescription/text()

(Of course, you need to specify the actual BUILD_ID string).


Information about the user who started the build seems unavailable through environment variables set by Jenkins.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号