在此脚本中,如果requestState id PENDING每次在2分钟后重复该阶段,并且如果其未挂起则应停止。
pipeline {
agent {
label "cicd-npe-slave0"
}
options {
buildDiscarder(logRotator(numToKeepStr: '20'))
disableConcurrentBuilds()
}
parameters {
string(name: 'access_token', defaultValue: '')
string(name: 'body', defaultValue: '')
}
stages {
stage('Execute curl command') {
steps {
script {
def response = sh(script: '''curl --location 'URL' \\
--header 'Content-Type: application/json' \\
--header 'Authorization: Bearer xxx' \\
--data '{
xxxx
}' ''', returnStdout: true).trim()
println(response)
def jsonSlurper = new groovy.json.JsonSlurper()
def jsonResponse = jsonSlurper.parseText(response)
requestState = jsonResponse.response.requestState
echo "Request State = '${requestState}'"
}
}
}
}
}
我尝试了很多东西,得到下面的错误,为上述脚本,如果我是添加睡眠intervels
Caused: java.io.NotSerializableException: groovy.json.internal.LazyMap
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:274)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
Finished: FAILURE
1条答案
按热度按时间ukdjmx9f1#
这是一个有效的解决方案,请根据您的需要进行调整。