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}),
]
}
}
}
}
}
收到此錯誤:java.lang.NoSuchMethodError: No such DSL method '$' found among steps
job_file testbed_file image_file mail_to branch_name都是jenkins管道專案中定義的字串引數。
uj5u.com熱心網友回復:
由于以下行,您收到此錯誤:value: ${command}.
該${}語法用于 groovy String Interpolation,顧名思義,只能在雙引號(單行或多行)字串中使用。
以下應該有效:
string(name: 'pyats_job_args', value: "${command}"),
但是,因為您的值已經是一個引數,所以您根本不需要字串插值,您可以直接使用您的command引數:
string(name: 'pyats_job_args', value: command),
這是一種更加簡單易讀的方法。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/497282.html
