Search code examples
jenkinsjenkins-workflowjenkins-pipeline

Error encountered with jenkins properties step


In my Jnekinsfile, I have the following steps:

 properties([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [[$class: 'StringParameterDefinition', defaultValue: 'master', name: 'apiBranchName']]]])
sh "ruby ./build/script '${apiBranchName}'"

It works sometimes but in some other time it raises:

Groovy.lang.MissingPropertyException: No such property: apiBranchName for class: groovy.lang.Binding

Any idea?


Solution

  • I found the solution. I have several steps that require different parameters. So originally I define only those needed properties for each step. (for example, test step requires apiBranchName and deploy requires target. So I define only apiBranchName in tests and only target in deploy). That caused the issue.

    Once I just define them all on each step it works out fine