I am trying to create a declarative jenkins pipeline to deploy an aws lmabda but I am stumbling on this error everytime:
groovy.lang.MissingPropertyException: No such property: stage for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at
I am pretty sure of the syntax of the pipeline and I find it very strange that it hangs on the "stage" expression since it is a native to groovy syntax
here below the pipeline:
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"'
}
}
}
}
}
}
Any idea what could be wrong about the pipeline?
Please check if you have installed required plugins like - workflow stage view etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.