Documentation
PLEASE NOTE: This document applies to latest version and not to the latest stable release v3.0
Documentation for other releases can be found by using the version selector in the top right of any doc page.jenkins_job
Manage Jenkins jobs and builds.
Attributes
check_mode:
support: full
Parameters
| Parameter | Required | Type | Values | Description |
|---|---|---|---|---|
| name | true | string | Name of the Jenkins job. | |
| url | true | string | Jenkins server URL. | |
| user | true | string | Jenkins username for authentication. | |
| password | true | string | Jenkins password or API token. | |
| state | string | present absent |
Whether the job should be present or absent. [default: "present"] |
|
| config | string | Job configuration XML content. | ||
| token | string | Build token for triggering builds. | ||
| enabled | boolean | Whether to trigger a build (only for state=present). | ||
| timeout | integer | Timeout in seconds for API requests. | ||
| validate_certs | boolean | If false, SSL certificates will not be validated. |
Examples
- name: Create Jenkins job
jenkins_job:
name: myapp-build
state: present
url: http://jenkins.local
user: admin
password: secret
- name: Create Jenkins job with config XML
jenkins_job:
name: myapp-build
state: present
url: http://jenkins.local
user: admin
password: secret
config: |
<project>
<description>My app build job</description>
<builders>
<hudson.tasks.Shell>
<command>echo "Building"</command>
</hudson.tasks.Shell>
</builders>
</project>
- name: Trigger Jenkins build
jenkins_job:
name: myapp-build
state: present
url: http://jenkins.local
user: admin
password: secret
enabled: true
- name: Delete Jenkins job
jenkins_job:
name: old-job
state: absent
url: http://jenkins.local
user: admin
password: secret
- name: Trigger build with token
jenkins_job:
name: myapp-build
state: present
url: http://jenkins.local
user: admin
password: secret
token: build-token
enabled: true