Jenkins声明性管道-如何将表达式分配给shell变量
我也尝试过echo“$tempPass”,但不起作用 我也试过了,但变量值是空的Jenkins声明性管道-如何将表达式分配给shell变量,jenkins,jenkins-pipeline,jenkins-declarative-pipeline,Jenkins,Jenkins Pipeline,Jenkins Declarative Pipeline,我也尝试过echo“$tempPass”,但不起作用 我也试过了,但变量值是空的 stage ('Build image') { steps { withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'user', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY
stage ('Build image') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'user', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
sh "tempPass=\$(aws ecr get-login-password --region us-west-2)"
echo 'Hello------------------'
echo "${tempPass}"
echo 'Hello AFTER------------------'
}
}
}
Exception : groovy.lang.MissingPropertyException: No such property: pass for class: groovy.lang.Binding
有人能帮忙吗?您需要从
sh
步骤returnStatus
或returnStdout
e、 g
script {
tempPass=sh(script: "aws ecr get-login-password --region us-west-2")
}
latest_tag = sh(script: "aws ecr get-login-password --region us-west-2", returnStdout: true).trim()