ansible / ansible.builtin / v2.9.27 / module / jenkins_script Executes a groovy script in the jenkins instance | "added in version" 2.3 of ansible.builtin" Authors: James Hogarth (@hogarthj) preview | supported by communityansible.builtin.jenkins_script (v2.9.27) — module
pip
Install with pip install ansible==2.9.27
The C(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.
- name: Obtaining a list of plugins jenkins_script: script: 'println(Jenkins.instance.pluginManager.plugins)' user: admin password: admin
- name: Setting master using a variable to hold a more complicate script set_fact: setmaster_mode: | import jenkins.model.* instance = Jenkins.getInstance() instance.setMode(${jenkins_mode}) instance.save()
- name: use the variable as the script jenkins_script: script: "{{ setmaster_mode }}" args: jenkins_mode: Node.Mode.EXCLUSIVE
- name: interacting with an untrusted HTTPS connection jenkins_script: script: "println(Jenkins.instance.pluginManager.plugins)" user: admin password: admin url: https://localhost validate_certs: no
url: default: http://localhost:8080 description: - The jenkins server to execute the script against. The default is a local jenkins instance that is not being proxied through a webserver. args: description: - 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). user: description: - The username to connect to the jenkins server with. script: description: - The groovy script to be executed. This gets passed as a string Template if args is defined. required: true timeout: default: 10 description: - The request timeout in seconds version_added: '2.4' version_added_collection: ansible.builtin password: description: - The password to connect to the jenkins server with. validate_certs: default: 'yes' description: - If set to C(no), the SSL certificates will not be validated. This should only set to C(no) used on personally controlled sites using self-signed certificates as it avoids verifying the source site. type: bool
output: description: Result of script returned: success sample: 'Result: true' type: str