我们有这个用于 jenkins 的复杂 groovy 脚本,看起来像
def run_pipeline() {
try {
stage('Build') {
sh "docker build . -t ansible"
}
stage('Linux Common Tag') {
def stage_common = [
[tag: 'common', serial: '100%', user: "${env.ANSIBLE_USER}", playbook: 'platform.yml'],
]
run_stages(stage_common, serial)
}
}
def run_stages(stages, serial) {
stages.each { phase ->
def serial_percent=serial.containsKey(phase.tag) ? serial[phase.tag]: phase.serial
ansible(phase.tag, phase.user, phase.password, limit=phase.limit, playbook=phase.playbook, serial=serial_percent)
}
execute_stages()
}
def ansible(tag, user, password, limit='', serial='100%' playbook='platform.yml') {
// stuff in here
}
我们得到的是
java.lang.NoSuchMethodError: No such DSL method 'ansible' found among steps
它似乎发生在run_stages
函数中
关于我做错了什么的任何意见?谢谢!