我正在使用jenkins-job-builder来生成 jenkins 工作。
我在我的 jenkins 中添加了ansible
插件,我想用它作为我的部署工具。
当我开始转换builder
我的工作部分时,yaml
它适用于大多数元素。但是,我无法将Extra Variables
or转换extraVars
为yaml。limit
config.xml
没有extraVars
and 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?