开发者

How can I find out how a build was triggered in Jenkins

开发者 https://www.devze.com 2023-03-27 04:30 出处:网络
I\'m trying to update Jelly scripts in my Jenkins setup to email the reason for a build (the build trigger), but I can\'t find any documentation on this.

I'm trying to update Jelly scripts in my Jenkins setup to email the reason for a build (the build trigger), but I can't find any documentation on this.

I know it should be available, as the build's pa开发者_开发技巧ge will show the information, but I want it to be displayed on the email being distributed.

Does anyone know if there is a var I can query, or a Jenkins API call I can call to get this?


You can do it by calling this API.

More convinient, in env var setted before the build, you'll find BUILD_URL :

BUILD_URL=https://jenkins-server.tld/job/JOBNAME/BUILD_NUMBER

So you just need to append /api/json. You can also got it in xml :

<freeStyleBuild>
<action>
<cause>
<shortDescription>Started by user kenji</shortDescription>
<userName>kenji</userName>
</cause>
</action>
<action/>
<action/>
<action>
<failCount>0</failCount>
<skipCount>0</skipCount>
<totalCount>1</totalCount>
<urlName>testReport</urlName>
</action>
<building>false</building>
<duration>9772</duration>
<fullDisplayName>JOBNAME #4</fullDisplayName>
<id>2011-08-10_11-19-42</id>
<keepLog>false</keepLog>
<number>4</number>
<result>SUCCESS</result>
<timestamp>1312967982296</timestamp>
<url>https://jenkins-server.tld/job/JOBNAME/4/</url>
<builtOn>macboo</builtOn>
<changeSet>
<kind>svn</kind>
<revision>
<module>https://svn-server.tld/JOBNAME/trunk</module>
<revision>7</revision>
</revision>
</changeSet>
</freeStyleBuild>
0

精彩评论

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

关注公众号