- Docs »
- jenkins_job - Manage jenkins jobs
-
You are reading an unmaintained version of the Ansible documentation. Unmaintained Ansible versions can contain unfixed security vulnerabilities (CVE). Please upgrade to a maintained version. See the latest Ansible documentation.
jenkins_job - Manage jenkins jobs
- Manage Jenkins jobs by using Jenkins REST API.
The below requirements are needed on the host that executes this module.
- python-jenkins >= 0.4.12
- lxml >= 3.3.3
Parameter |
Choices/Defaults |
Comments |
config
|
|
config in XML format.
Required if job does not yet exist.
Mututally exclusive with enabled .
Considered if state=present .
|
enabled
|
|
Whether the job should be enabled or disabled.
Mututally exclusive with config .
Considered if state=present .
|
name
required |
|
Name of the Jenkins job.
|
password
|
|
Password to authenticate with the Jenkins server.
|
state
|
Choices:
present ←
- absent
|
Attribute that specifies if the job has to be created or deleted.
|
token
|
|
API token used to authenticate alternatively to password.
|
url
|
Default:
"http://localhost:8080"
|
Url where the Jenkins server is accessible.
|
user
|
|
User to authenticate with the Jenkins server.
|
# Create a jenkins job using basic authentication
- jenkins_job:
config: "{{ lookup('file', 'templates/test.xml') }}"
name: test
password: admin
url: http://localhost:8080
user: admin
# Create a jenkins job using the token
- jenkins_job:
config: "{{ lookup('template', 'templates/test.xml.j2') }}"
name: test
token: asdfasfasfasdfasdfadfasfasdfasdfc
url: http://localhost:8080
user: admin
# Delete a jenkins job using basic authentication
- jenkins_job:
name: test
password: admin
state: absent
url: http://localhost:8080
user: admin
# Delete a jenkins job using the token
- jenkins_job:
name: test
token: asdfasfasfasdfasdfadfasfasdfasdfc
state: absent
url: http://localhost:8080
user: admin
# Disable a jenkins job using basic authentication
- jenkins_job:
name: test
password: admin
enabled: False
url: http://localhost:8080
user: admin
# Disable a jenkins job using the token
- jenkins_job:
name: test
token: asdfasfasfasdfasdfadfasfasdfasdfc
enabled: False
url: http://localhost:8080
user: admin
Common return values are documented here, the following are the fields unique to this module:
Key |
Returned |
Description |
enabled
bool
|
success |
Whether the jenkins job is enabled or not.
Sample:
True
|
name
string
|
success |
Name of the jenkins job.
Sample:
test-job
|
state
string
|
success |
State of the jenkins job.
Sample:
present
|
url
string
|
success |
Url to connect to the Jenkins server.
Sample:
https://jenkins.mydomain.com
|
user
string
|
success |
User used for authentication.
Sample:
admin
|
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
- Sergio Millan Rodriguez (@sermilrod)
Hint
If you notice any issues in this documentation you can edit this document to improve it.