下面是我在jenkinsfile中部署阶段的代码
stage('Deploy') {
node('slave1') {
if ("${env.Build_testapp1}" == 'true') {
script {
env.packageid = "Applications/testapp1/revesion1"
env.environmentId = "Environments/SysTest1/machine1"
}
xldDeploy serverCredentials: 'developer', environmentId: env.environmentId, packageId: env.packageid
}
但是如何根据环境使它可变?
我正在寻找这样的东西
if ("${env.Build_EVN}" == 'dev'){
env.environmentId = "Environments/Dev/machine1"
}
if ("${env.Build_EVN}" == 'systest1'){
env.environmentId = "Environments/SysTest1/machine1"
}
然后在阶段(“部署”)中使用“ env.environmentId”
答案 0 :(得分:0)
您可以在Deploy
之前添加一个阶段来处理env.environmentId
,以供后续阶段使用。
stage('Prepare env') {
steps {
script {
if ("${env.Build_EVN}" == 'dev'){
env.environmentId = "Environments/Dev/machine1"
}
if ("${env.Build_EVN}" == 'systest1'){
env.environmentId = "Environments/SysTest1/machine1"
}
}
}
}
stage('Deploy') {
...
}