获取作业的构建状态作为构建后变量 [英] Getting a job's build status as post-build variable
本文介绍了获取作业的构建状态作为构建后变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在构建后的Shell脚本中,是否可以通过变量获取Jenkins作业的状态?
Is there a way to obtain the status of the Jenkins job in a variable during a Post-Build shell script?
我想打印出消息Build Status is $BUILD_URL :: $BUILD_STATUS
,其中$BUILD_STATUS
是当前已完成构建的状态(例如ABORTED
,SUCCESS
或FAILURE
).
I want to print out the message Build Status is $BUILD_URL :: $BUILD_STATUS
, where $BUILD_STATUS
is the status of the current completed build (e.g. ABORTED
, SUCCESS
, or FAILURE
).
推荐答案
就我而言,我必须包含API令牌,这对我有用:
In my case, I had to include the API TOKEN here is what worked for me:
BUILD_STATUS=$(curl --user USER:TOKEN_VALUE --silent $BUILD_URLapi/json | jq -r '.result')
对我来说是
BUILD_STATUS=$(curl --user robert:valueofmysecrettoken --silent $BUILD_URLapi/json | jq -r '.result')
这篇关于获取作业的构建状态作为构建后变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文