0

We am using Jenkins Pipeline to configure jobs in jenkins. For a bunch of jobs we need user input for which we use parameterised build where user can input parameter values and later we use the values in our .jenkinsfile in sh like

 sh "./build-apply.sh ${accountnumber} ${volumename} ${vpcname} services ${snapshotid}"

This used to work with

  • Jenkins 2.16
  • Pipeline 2.3
  • Groovy 2.15

However, when I rebuild Jenkins to:

  • 2.16 or latest 2.26
  • Pipeline 2.5
  • Pipeline: Groovy 2.19

The above sh stopped working. Error being

groovy.lang.MissingPropertyException: No such property: accountnumber for class: groovy.lang.Binding

Any idea what I am missing? Is the syntax not correct?

For reference full Jenkinsfile for reference

node {
  // Mark the code checkout 'stage'....


  stage 'Checkout'
  git branch: '****', credentialsId: '***', url: '****'

  stage 'Provision Volume'
  withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: '*****',
                    credentialsId: '****',
                    secretKeyVariable: '*****']]) {
    // Run the terraform build
    env.PATH = "${env.PATH}:/jenkins/terraform"
    sh "./build-apply.sh ${accountnumber} ${volumename} ${vpcname} services ${snapshotid}"
  }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
user3073335
  • 31
  • 2
  • 4
  • Where do you expect `accountnumber`, `volumename`, `vpcname`, and `snapshotid` to come from? Are you running the job with the right parameters? – mkobit Oct 19 '16 at 13:50
  • These are set as parameters on the job, this job has parameters with these names. So this comes from user input and are set. – user3073335 Oct 19 '16 at 14:01
  • Can you please share those parameters definition from this Jenkinsfile? – hakamairi Jan 05 '17 at 14:26

1 Answers1

0

Copy and paste the below code in the pipeline script node: {

stage ('BCCdlVsLib') {
build job: 'BCCdlVsLib', parameters:
[
    [$class: 'StringParameterValue', name: 'BINPATH', value: 'BINPATH'], 
    [$class: 'StringParameterValue', name: 'SOURCEFILE', value: 'SOURCEFILE']
        ]
}

In the jobs (BCCdlVsLib) enable the option "this project is parametrized" and enter 2 string parameters job_binpath,job_sourcefile.

Print the variables in the pipeline jobs echo job_binpath echo job_sourcefile

After run the pipeline job,will get the below output. BINPATH SOURCEFILE

user3065934
  • 199
  • 1
  • 2
  • 7