0

我们有这个用于 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函数中

关于我做错了什么的任何意见?谢谢!

4

1 回答 1

0

该错误消息意味着您使用的命令或“步骤”无效。这要么是因为您输入了错误的内容,要么是未安装提供该步骤的插件。我猜你没有安装 ansible 插件。

于 2017-11-09T05:17:42.457 回答