我遇到了与此处提到的类似的问题: Jenkinsfile Declarative Pipeline defined dynamic env vars
我正在尝试通过 jenkinsfile 部署应用程序。为此,我必须在 Jenkins 的部署阶段运行此命令(如果我对值进行硬编码,那么它可以正常工作):
xldDeploy serverCredentials: 'usernam', environmentId: 'Environments/SysTest1/SysTest1_1', packageId: 'Applications/Testapp/testapp_1.0.4.5.Build39_TAG-test'
“testapp_1.0.4.5.Build39_TAG-test”在运行时生成。可以通过连接"${TagVersion}.Build${env.BUILD_NUMBER}_${ComponentTagName}"
我在 jenkins 管道中尝试的以下代码来创建它:
stage('Deploy') {
node('noibuild01') {
if ("${env.Build_WildflyCPECommon}" == 'true') {
echo "${TagVersion}"
echo "${ComponentTagName}"
echo "${env.BUILD_NUMBER}"
script {
env.buildNumber = "${TagVersion}.Build${env.BUILD_NUMBER}_${ComponentTagName}"
env.packageid = "'Applications/Testapp/${env.buildNumber}'"
}
echo "${env.buildNumber}"
echo "${env.packageid}"
xldDeploy serverCredentials: 'nex8voo', environmentId: 'Environments/SysTest1/SysTest1_1', packageId: "${env.packageid}"
}
}
}
我检查了输出,它显示正确:
echo "${env.buildNumber}" giving
testapp_1.0.4.5.Build39_TAG-test
echo "${env.packageid}" giving
'Applications/Testapp/testapp_1.0.4.5.Build39_TAG-test'
但是xldDeploy serverCredentials: 'username', environmentId: 'Environments/SysTest1/SysTest1_1', packageId: "${env.packageid}"
作为 [/repository/ci/'Applications/Testapp/testapp_1.0.4.5.Build39_TAG-test']: Repository entity ['Applications/Testapp/testapp_1.0.4.5.Build39_TAG-test'] not found
我觉得我不能用packageId: "${env.packageid}"
。
有什么我可以尝试的吗?也许是 Groovy 或 Python 代码?