我正在使用jenkins-job-builder来生成jenkins职位。
我向我的jenkins添加了ansible
插件,我希望将其用作我的部署工具。
当我开始在builder
转换我的工作的yaml
部分时,它适用于大多数元素。但是,我无法将Extra Variables
中的extraVars
或limit
和config.xml
转换为yaml。
没有extraVars
和limit
,我的yaml如下。
builders:
- ansible-playbook:
playbook: my_playbook.yaml
inventory:
path: '{host_file}'
sudo: true
我的工作config.xml
将构建器节点设为
<builders>
<org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder plugin="ansible@0.8">
<playbook>my_playbook.yaml</playbook>
<inventory class="org.jenkinsci.plugins.ansible.InventoryPath">
<path>hosts</path>
</inventory>
<limit>myhost</limit>
<tags></tags>
<skippedTags></skippedTags>
<startAtTask></startAtTask>
<credentialsId></credentialsId>
<vaultCredentialsId></vaultCredentialsId>
<sudo>true</sudo>
<sudoUser></sudoUser>
<forks>5</forks>
<unbufferedOutput>true</unbufferedOutput>
<colorizedOutput>false</colorizedOutput>
<hostKeyChecking>false</hostKeyChecking>
<additionalParameters>-b --become-method su --become-user root -u rack --extra-vars "ansible_ssh_pass=************" --extra-vars "ansible_become_pass=************"</additionalParameters>
<copyCredentialsInWorkspace>false</copyCredentialsInWorkspace>
<extraVars>
<org.jenkinsci.plugins.ansible.ExtraVar>
<key>ldap_password</key>
<value>*******</value>
<hidden>false</hidden>
</org.jenkinsci.plugins.ansible.ExtraVar>
</extraVars>
</org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder>
</builders>
我尝试添加limit
和extraVars
。
builders:
- ansible-playbook:
playbook: my_playbook.yaml
inventory:
path: '{host_file}'
sudo: true
limit: myhost
extra-vars:
key: ldap_password
value: ********
但那不起作用。
中给出的答案 Answer1给出了logRotator
Answer2仅作为xml。
builders:
- raw:
xml: |
<org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder plugin="ansible@0.8">
<playbook>my_playbook.yaml</playbook>
<inventory class="org.jenkinsci.plugins.ansible.InventoryPath">
<path>hosts</path>
</inventory>
<limit>myhost</limit>
<tags></tags>
<skippedTags></skippedTags>
<startAtTask></startAtTask>
<credentialsId></credentialsId>
<vaultCredentialsId></vaultCredentialsId>
<sudo>true</sudo>
<sudoUser></sudoUser>
<forks>5</forks>
<unbufferedOutput>true</unbufferedOutput>
<colorizedOutput>false</colorizedOutput>
<hostKeyChecking>false</hostKeyChecking>
<additionalParameters>-b --become-method su --become-user root -u rack --extra-vars "ansible_ssh_pass=************" --extra-vars "ansible_become_pass=************"</additionalParameters>
<copyCredentialsInWorkspace>false</copyCredentialsInWorkspace>
<extraVars>
<org.jenkinsci.plugins.ansible.ExtraVar>
<key>ldap_password</key>
<value>*******</value>
<hidden>false</hidden>
</org.jenkinsci.plugins.ansible.ExtraVar>
</extraVars>
</org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder>
我知道,我遗漏了limit
和extraVars
没有将yaml
转换为正确xml
的内容。
我可以更改哪个jenkins-job-builder
生成适当的xml?