community.general.jenkins_script – Executes a groovy script in the jenkins instance¶
Note
This plugin is part of the community.general collection (version 1.3.6).
To install it use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.jenkins_script
.
Synopsis¶
The
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.
Parameters¶
Notes¶
Note
Since the script can do anything this does not report on changes. Knowing the script is being run it’s important to set changed_when for the ansible output to be clear on any alterations made.
Examples¶
- 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
Return Values¶
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
|
Authors¶
James Hogarth (@hogarthj)