Skip to content

jenkins_job Jenkins任务管理模块

1. 概述

2. 参数

参数描述
config stringxml配置文件,如果job作业不存在时,需要设置本参数
enable boolean作业是否启用
name string required作业名称
password string连接jenkins服务器认证使用的密码
state string指定作业是否创建或删除,可选值,present默认、absent
token stringAPI令牌
url stringJenkins服务器的URL
user string连接jenkins服务器的用户名
validate_certs boolean是否验证SSL证书,默认yes

3. 官方示例

yaml
- 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

本首页参考 https://notes.fe-mm.com/ 配置而成