ansible / ansible.builtin / v2.3.3.0-1 / module / jenkins_script Executes a groovy script in the jenkins instance | "added in version" 2.3 of ansible.builtin" Authors: James Hogarth preview | supported by communityansible.builtin.jenkins_script (v2.3.3.0-1) — module
pip
Install with pip install ansible==2.3.3.0.post1
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 vars: 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. required: false args: default: null description: - A dict of key-value pairs used in formatting the script. required: false user: default: null description: - The username to connect to the jenkins server with. required: false script: default: null description: - The groovy script to be executed. This gets passed as a string Template if args is defined. required: true password: default: null description: - The password to connect to the jenkins server with. required: false validate_certs: default: true 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. required: false
output: description: Result of script returned: success sample: 'Result: true' type: string