community.general.jenkins_job – Manage jenkins jobs
Note
This plugin is part of the community.general collection (version 1.3.2).
To install it use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.jenkins_job.
Synopsis
- Manage Jenkins jobs by using Jenkins REST API.
 
Requirements
The below requirements are needed on the host that executes this module.
- python-jenkins >= 0.4.12
 
Parameters
| Parameter | Choices/Defaults | Comments | 
|---|---|---|
|   config    string    |    config in XML format.  Required if job does not yet exist.  Mutually exclusive with   enabled.Considered if   state=present. |  |
|   enabled    boolean    |   
  |    Whether the job should be enabled or disabled.  Mutually exclusive with   config.Considered if   state=present. |  
|   name    string / required    |    Name of the Jenkins job.   |  |
|   password    string    |    Password to authenticate with the Jenkins server.   |  |
|   state    string    |   
  |    Attribute that specifies if the job has to be created or deleted.   |  
|   token    string    |    API token used to authenticate alternatively to password.   |  |
|   url    string    |   Default: "http://localhost:8080"   |    URL where the Jenkins server is accessible.   |  
|   user    string    |    User to authenticate with the Jenkins server.   |  
Examples
- name: Create a jenkins job using basic authentication
  community.general.jenkins_job:
    config: "{{ lookup('file', 'templates/test.xml') }}"
    name: test
    password: admin
    url: http://localhost:8080
    user: admin
- name: Create a jenkins job using the token
  community.general.jenkins_job:
    config: "{{ lookup('template', 'templates/test.xml.j2') }}"
    name: test
    token: asdfasfasfasdfasdfadfasfasdfasdfc
    url: http://localhost:8080
    user: admin
- name: Delete a jenkins job using basic authentication
  community.general.jenkins_job:
    name: test
    password: admin
    state: absent
    url: http://localhost:8080
    user: admin
- name: Delete a jenkins job using the token
  community.general.jenkins_job:
    name: test
    token: asdfasfasfasdfasdfadfasfasdfasdfc
    state: absent
    url: http://localhost:8080
    user: admin
- name: Disable a jenkins job using basic authentication
  community.general.jenkins_job:
    name: test
    password: admin
    enabled: False
    url: http://localhost:8080
    user: admin
- name: Disable a jenkins job using the token
  community.general.jenkins_job:
    name: test
    token: asdfasfasfasdfasdfadfasfasdfasdfc
    enabled: False
    url: http://localhost:8080
    user: admin
   Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description | 
|---|---|---|
|   enabled    boolean    |  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   |  
Authors
- Sergio Millan Rodriguez (@sermilrod)
 
    © 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
    https://docs.ansible.com/ansible/2.10/collections/community/general/jenkins_job_module.html