Note
This plugin is part of the community.general collection.
To install it use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.jenkins_script.
jenkins_script module takes a script plus a dict of values to use within the script and returns the result of the script being run.| Parameter | Choices/Defaults | Comments |
|---|---|---|
| args string | A dict of key-value pairs used in formatting the script using string.Template (see https://docs.python.org/2/library/string.html#template-strings). | |
| password string | The password to connect to the jenkins server with. | |
| script string / required | The groovy script to be executed. This gets passed as a string Template if args is defined. | |
| timeout string | Default: 10 | The request timeout in seconds |
| url string | Default: "http://localhost:8080" | The jenkins server to execute the script against. The default is a local jenkins instance that is not being proxied through a webserver. |
| user string | The username to connect to the jenkins server with. | |
| validate_certs boolean |
| If set to no, the SSL certificates will not be validated. This should only set to no used on personally controlled sites using self-signed certificates as it avoids verifying the source site. |
Note
- name: Obtaining a list of plugins
community.general.jenkins_script:
script: 'println(Jenkins.instance.pluginManager.plugins)'
user: admin
password: admin
- name: Setting master using a variable to hold a more complicate script
ansible.builtin.set_fact:
setmaster_mode: |
import jenkins.model.*
instance = Jenkins.getInstance()
instance.setMode(${jenkins_mode})
instance.save()
- name: Use the variable as the script
community.general.jenkins_script:
script: "{{ setmaster_mode }}"
args:
jenkins_mode: Node.Mode.EXCLUSIVE
- name: Interacting with an untrusted HTTPS connection
community.general.jenkins_script:
script: "println(Jenkins.instance.pluginManager.plugins)"
user: admin
password: admin
url: https://localhost
validate_certs: no
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description |
|---|---|---|
| output string | success | Result of script Sample: Result: true |
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/community/general/jenkins_script_module.html