enter image description here如何在Jenkins声明性管道中获取此值,如果值匹配,则触发作业,并在ECR存储库中获取ECR标记,然后如何实现enter image description here,因此,如果使用http://jenkins:8080/job/Nm/buildWithParameters?ECR_TAG=0.1.3接口传递标记,则返回错误,如果传入Jenkins URL tag=0.1.1或0.1.2,则成功,但标记名自动递增。
发布于 2021-04-21 22:29:26
可以在stage下使用when,expression,在这个when条件下,可以检查env参数是true还是false。
pipeline {
agent {
node {
label 'master'
}
}
options {
timeout(time: 1, unit: 'HOURS', activity: true) // abort if nothing happens on the console for 1h
timestamps() // prepend timestamps on the console output
}
parameters {
choice(name: 'ECR_TAG', choices: ['0.1.1', '0.1.2', '0.1.3'], description: 'TAG for ECR')
}
stages {
stage('Git Checkout') {
when {
expression { env.ECR_TAG == "0.1.1" }
}
steps {
script{
// your script here.
echo "Hello"
}
}
}
}}//管道
仅当您在触发作业时将ECR_TAG参数值指定为0.1.1时,才会执行上述流水线阶段。
https://stackoverflow.com/questions/67197428
复制相似问题