pipeline如何传参到ansible playbook 或者roles

Ryan
  • 1
新手上路,请多包涵

我在跑脚本的时候发现pipeline的参数传不到ansible playbook里面,望求大神解决。
pipeline代码大概是这样的:
pipeline {

agent any

parameters {
    choice(name: 'ABC', choices: 'one\ntwo\nthree', description: 'test parms')
}
stages {
    stage('Build') {
        steps {
            echo 'Building start...'
            echo "${params.ACTION}"
        }
    }
    }
    stage('ansible tower'){
        steps {
          ansibleTower credential: '',
          extraVars: "ABC: ${params.ABC}",
          importTowerLogs: true, 
          importWorkflowChildLogs: false, 
          inventory: '', 
          jobTags: '', 
          jobTemplate: '10001', 
          jobType: 'run', 
          limit: '', 
          removeColor: false, 
          skipJobTags: '', 
          templateType: 'job', 
          throwExceptionWhenFail: false, 
          towerServer: 'Ansible', 
          verbose: false
        }
    }
}

}

ansible playbook代码是这样的:

  • hosts: localhost
    gather_facts: false
    become: true
    become_user: test
    become_method: sudo

    tasks:

    • name: echo global var
      debug:

      msg: "{{ ABC }} "
      register: parms_result
      
    • name: echo result
      debug:

      var: parms_result.stdout_lines  

问题:
如何通过pipeline定义的参数ABC让ansible roles读取到ABC的变量

回复
阅读 588
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏