Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person

Categories

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

agent any

parameters {
    choice(name: 'ABC', choices: 'one
two
three', 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的变量


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
339 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...