あなたはJenkinsパイプラインを使用していると仮定します。さまざまな方法がありますが、JOB Aのステータスを確認するための第一歩とステータスを確認するユーティリティ機能を追加することで、これを解決します。
stage('check Job A status'){
// If A is running, B waits for A.
if(checkStatus() == "RUNNING"){
timeout(time: 60, unit: 'MINUTES') {
waitUntil {
def status = checkStatus()
return (status == "SUCCESS" || status == "FAILURE" || status == "UNSTABLE" || status == "ABORTED")
}
}
}
// Proceed with B, only when A is in a good state
if(checkStatus() != "SUCCESS"){
error('Stopping Job B becuase job A is not successful.')
}
}
def checkStatus() {
def statusUrl = httpRequest "https://jenkins.example.com/job/${job-A-Name}/lastBuild/api/json"
def statusJson = new JsonSlurper().parseText(statusUrl.getContent())
return statusJson['result']
}
出典
2017-10-21 23:22:35
Kvk