![](/img/trans.png)
[英]Jenkins pipeline groovy.lang.MissingPropertyException
[英]Jenkins declarative pipeline groovy.lang.MissingPropertyException: No such property: stage for class: groovy.lang
我正在嘗試創建一個聲明性 jenkins 管道來部署 aws lmabda 但我每次都遇到這個錯誤:
groovy.lang.MissingPropertyException: No such property: stage for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at
我很確定管道的語法,我發現它掛在“舞台”表達式上很奇怪,因為它是 groovy 語法的原生
在管道下方:
pipeline {
agent {
label 'node1'
}
environment {
awsRegion = 'some_region'
// Role name is the same in ALL aws accounts
Role = 'some_role'
awsAccount = 'Some_account_number'
envName = 'some_env'
paramsfile = 'vars.json'
templatebody = 'PATH/lambda-template.yml'
}
stages {
stage('Init') {
steps {
echo 'Init done'
}
}
stage('BuildBackend parameter file') {
steps {
withAWS(credentials:'jenkins_user', region:"eu-west-1") {
withAWS(role:"$cfnexecutionRole", roleAccount: targetAWSAccounts['targetaccount'], duration:900, roleSessionName:'jenkins-session') {
script{
for (def key in backendParamList.keySet()){
echo "Fetching ${key}"
backendParamValues[key] = sh(script:"aws ssm get-parameter --query 'Parameter.Value' --name '/config/${stageToParamPrefix[stage]}/lambda/${key}'", returnStdout: true).trim()
echo ParamValues[key]
}
}
}
// Next roleAccount depends on the param stage
withAWS(role:"$Role", roleAccount: targetAWSAccounts[stageToAccount[env.stage]], duration:900, roleSessionName:'jenkins-session') {
script{
def backendParams = "{\n"
def nbParams = 0
for (def key in backendParamList.keySet()){
echo "Writing parameter ${key}"
if(nbParams > 0){
backendParams += ","
}
backendParams += "{\"ParameterKey\":\"${backendParamList[key]}\", \"ParameterValue\": ${backendParamValues[key]}}"
backendParams += "\n"
nbParams += 1
}
backendParams += "}"
writeFile(file:'$paramsfile', text: backendParams)
echo backendParams
// deploy secrets
sh "aws "
}
}
}
}
}
stage('Check params file') {
steps {
sh "cat $paramsfile"
}
}
stage('Deploy lambda using cloudformation template') {
steps {
withAWS(credentials:'user_credentials', region:"$awsRegion") {
echo "Assume Cloudformation-Execution-Role - AWS Account: $awsAccount"
withAWS(role:"$Role", roleAccount:"$awsAccount", duration:900, roleSessionName:'jenkins-session'){
sh'aws cloudformation create-stack --stack-name "$stackname" --template-body "$templatebody" --parameters "$paramsfile"'
}
}
}
}
}
}
知道管道有什么問題嗎?
請檢查您是否安裝了所需的插件,例如 - 工作流階段視圖等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.