【发布时间】:2020-12-31 15:16:40
【问题描述】:
我希望在我当前的流水线脚本中获得单独的 Jenkins 作业 Backup_Precheck 的最新状态。
下面是我的流水线脚本。
import groovy.json.JsonSlurper
pipeline
{
agent any
stages {
stage('check Job Backup_Precheck status'){
steps {
script{
if(checkStatus() == "RUNNING" ){
timeout(time: 60, unit: 'MINUTES') {
waitUntil {
def status = checkStatus()
return (status == "SUCCESS" || status == "FAILURE" || status == "UNSTABLE" || status == "ABORTED")
}
}
}
if( checkStatus() != "SUCCESS" ){
error('Stopping Job Weekend_Backup becuase job Backup_Precheck is not successful.')
} else {
echo 'Triggering ansible backup automation'
} // script end
} //steps ends here
} // stage ends here
stage('Hello') {
steps { echo 'Hello World'}
}
} //step closes
}
def checkStatus() {
def statusUrl = httpRequest "https://portal.myshop.com:9043/job/Backup_Precheck/lastBuild/api/json"
def statusJson = new JsonSlurper().parseText(statusUrl.getContent())
return statusJson['result']
}
我在 jenkins 控制台日志中收到以下错误:
[Pipeline] { (Hello) Stage "Hello" 由于早期的失败而被跳过 [管道] } [管道] // 阶段 [管道] } [管道] // 节点 [管道] 管道结束 java.lang.NoSuchMethodError: 没有这样的 DSL 在步骤 [ansiColor, ansiblePlaybook, ansibleTower, ansibleTowerProjectRevision, ansibleTowerProjectSync, ansibleVault,存档,蝙蝠,构建,catchError,结帐,deleteDir, 目录,dockerFingerprintFrom,dockerFingerprintRun,dockerNode,回声, emailext, emailextrecipients, envVarsForTool, 错误, fileExists, findBuildScans、getContext、git、输入、isUnix、junit、库、 libraryResource,加载,锁定,邮件,里程碑,节点,并行, powershell, 属性, publishHTML, pwd, pwsh, readFile, readTrusted, resolveScm, 重试, 脚本, sh, sleep, stage, stash, step, svn, task, 超时,tm,工具,取消归档,不稳定,unstash, validateDeclarativePipeline、waitUntil、warnError、withContext、 withCredentials, withDockerConta
我了解我可能需要安装 HTTP 请求插件才能解决上述问题。
但是,我不能在不依赖HTTP Request Plugin 的情况下获得工作的最新状态吗?如果是这样,请指导我。
【问题讨论】:
标签: http jenkins jenkins-pipeline status nosuchmethoderror