community.general.jenkins_job (8.5.0) — module

Manage jenkins jobs

Authors: Sergio Millan Rodriguez (@sermilrod)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Manage Jenkins jobs by using Jenkins REST API.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete a jenkins job using basic authentication
  community.general.jenkins_job:
    name: test
    password: admin
    state: absent
    url: http://localhost:8080
    user: admin
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete a jenkins job using the token
  community.general.jenkins_job:
    name: test
    token: asdfasfasfasdfasdfadfasfasdfasdfc
    state: absent
    url: http://localhost:8080
    user: admin
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Disable a jenkins job using basic authentication
  community.general.jenkins_job:
    name: test
    password: admin
    enabled: false
    url: http://localhost:8080
    user: admin
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Disable a jenkins job using the token
  community.general.jenkins_job:
    name: test
    token: asdfasfasfasdfasdfadfasfasdfasdfc
    enabled: false
    url: http://localhost:8080
    user: admin

Inputs

    
url:
    default: http://localhost:8080
    description:
    - URL where the Jenkins server is accessible.
    required: false
    type: str

name:
    description:
    - Name of the Jenkins job.
    required: true
    type: str

user:
    description:
    - User to authenticate with the Jenkins server.
    required: false
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Attribute that specifies if the job has to be created or deleted.
    required: false
    type: str

token:
    description:
    - API token used to authenticate alternatively to password.
    required: false
    type: str

config:
    description:
    - config in XML format.
    - Required if job does not yet exist.
    - Mutually exclusive with O(enabled).
    - Considered if O(state=present).
    required: false
    type: str

enabled:
    description:
    - Whether the job should be enabled or disabled.
    - Mutually exclusive with O(config).
    - Considered if O(state=present).
    required: false
    type: bool

password:
    description:
    - Password to authenticate with the Jenkins server.
    required: false
    type: str

validate_certs:
    default: true
    description:
    - If set to V(false), the SSL certificates will not be validated. This should only
      set to V(false) used on personally controlled sites using self-signed certificates
      as it avoids verifying the source site.
    - The C(python-jenkins) library only handles this by using the environment variable
      E(PYTHONHTTPSVERIFY).
    type: bool
    version_added: 2.3.0
    version_added_collection: community.general

Outputs

enabled:
  description: Whether the jenkins job is enabled or not.
  returned: success
  sample: true
  type: bool
name:
  description: Name of the jenkins job.
  returned: success
  sample: test-job
  type: str
state:
  description: State of the jenkins job.
  returned: success
  sample: present
  type: str
url:
  description: Url to connect to the Jenkins server.
  returned: success
  sample: https://jenkins.mydomain.com
  type: str
user:
  description: User used for authentication.
  returned: success
  sample: admin
  type: str