Groovy:没有这样的DSL方法' ansible'在步骤中发现

时间:2017-11-08 23:04:02

标签: jenkins groovy jenkins-pipeline jenkins-groovy

我们为jenkins提供了这个复杂的groovy脚本,看起来像

class AddSubjectAndAuthorToNotes < ActiveRecord::Migration
  def change
    add_reference :notes, :author, index: true
    add_reference :notes, :subject, index: true

    add_foreign_key :notes, :people, column: :author_id
    add_foreign_key :notes, :people, column: :subject_id
  end
end

我们得到的是

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 函数

关于我做错了什么的任何输入?谢谢!

1 个答案:

答案 0 :(得分:0)

该错误消息表示您使用的命令或“步骤”无效。这可能是因为您键入了错误,或者未安装提供该步骤的插件。我猜你没有安装ansible插件。