在我们公司,当每个测试获得其自己的节点时,我们执行并行测试执行......节点是aws点类型代理,根据策略,它可以由aws获取,并在进行时终止。我们希望重新执行节点被aws终止的阶段,我们遇到了管道重试步骤,它可以被设置为在代理被中断的情况下重试管道阶段。要使用它,我们需要传递对象的嵌套选择数组-在我的例子中,“agent”的单个对象,我尝试用不同的语法尝试执行下一个代码:
import hudson.model.*
import jenkins.model.*
pipeline {
agent { label 'aws-fleet-spot-small' }
stages {
stage('test parallel') {
steps {
script {
def stepsForParallel = [:]
stepsForParallel["stage1"] = {
retry(count: 3, conditions: [agent{ label 'aws-fleet-spot-small' }]){
node("aws-fleet-spot-small") {
stage("stage1") {
script {
echo ('stage11111')
}
}
}
}
}
stepsForParallel["stage2"] = {
node("aws-fleet-spot-small") {
stage("stage2") {
script {
echo ('stage2222')
}
}
}
}
parallel stepsForParallel
}
}
}
}
}
或
retry(count:3, conditions:[agent])
我还发现了这个阻塞溢出线程Retry with condition jenkins pipeline,并使用代码:
import org.jenkinsci.plugins.workflow.support.steps.AgentErrorCondition
retry(count: 3, conditions: [new AgentErrorCondition()){
或
retry(count:3, conditions: [AgentErrorCondition])
根据jenkins代码,它期望ErrorCondition实现类arr/list作为条件键的值**,但我得到编译异常**
有谁能给我建议正确的语法或指向一个工作的例子吗?
1条答案
按热度按时间wwwo4jvm1#
在我们公司,我们有完全相同的设置,下面的代码在AWS节点被取走或该节点上发生其他问题时重试该步骤:
然后以下列方式 Package 程式码: