pipeline {
agent none
stages {
stage ('INSTALL_IMAGE') {
steps {
script {
def command = "env.job_file --testbed-file env.testbed_file --image_file env.image_file --mail_to env.mail_to"
build job: 'PYATS_JOB_EXECUTOR', parameters:
[
string(name: 'branch_name', value: env.branch_name),
string(name: 'pyats_job_args', value: ${command}),
]
}
}
}
}
}
Getting this error: java.lang.NoSuchMethodError: No such DSL method '$' found among steps
job_file
testbed_file
image_file
mail_to
branch_name
are all string parameters defined in the jenkins pipeline project.
CodePudding user response:
You are receiving this error because of the following line: value: ${command}
.
The ${}
syntax is used for the groovy String Interpolation, and as the name implies can be used only inside double quoted (single line or multi line) strings.
The following should work:
string(name: 'pyats_job_args', value: "${command}"),
However, because your value is already a parameter you do not need the string interpolation at all, you can just use your command
parameter directly:
string(name: 'pyats_job_args', value: command),
This is a much more simple and readable approach.