我有一套完整的单元测试,我想在 Jenkins 中每天通宵运行,但前提是我的应用程序已在另一项工作中正确构建。我不希望单元测试在提交添加到应用程序时全天触发。
我该如何配置?重申:詹金斯有两个工作:
甲和乙:
A 运行每次签入,除非 B 正在运行,在这种情况下它等待 B。
B 午夜运行,IFF A 状态良好。如果 A 正在运行,则 B 等待 A。
我已经将 A 设置为“A 运行每次签入”。
我假设您正在使用 Jenkins 管道。可能有很多方法,但我会通过在JOB B中添加一个新阶段来检查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']
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7540 次 |
| 最近记录: |