community / community.general / 6.6.8 / module / jenkins_script Executes a groovy script in the jenkins instance Authors: James Hogarth (@hogarthj)community.general.jenkins_script (6.6.8) — module
Install with ansible-galaxy collection install community.general:==6.6.8
collections: - name: community.general version: 6.6.8
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 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: false
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. type: str 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). type: dict user: description: - The username to connect to the jenkins server with. type: str script: description: - The groovy script to be executed. This gets passed as a string Template if args is defined. required: true type: str timeout: default: 10 description: - The request timeout in seconds type: int password: description: - The password to connect to the jenkins server with. type: str validate_certs: default: true description: - If set to C(false), the SSL certificates will not be validated. This should only set to C(false) 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