Jenkins API 笔记
文章目录
检测Job是否存在
|
|
创建Job
|
|
删除Job
|
|
获取Job当前配置
|
|
更新Job配置
|
|
构建Job
|
|
参数化构建Job
|
|
或者
|
|
示例
-
检测Job是否存在
1 2
➜ ~ curl -XGET http://admin:117fd7d3aae52a3ce02ace7d783d3bbd9d@jenkins.dianduidian.com/checkJobName?value=test <div class=error><img src='/static/0c8c91ca/images/none.gif' height=16 width=1>A job already exists with the name ‘test’</div>%
-
创建job
1
curl -s http://admin:117fd7d3aae52a3ce02ace7d783d3bbd9d@jenkins.dianduidian.com/job/test/config.xml | curl -X POST 'http://admin:117fd7d3aae52a3ce02ace7d783d3bbd9d@jenkins.dianduidian.com/createItem?name=test2' -H "Content-Type: application/xml" -d @-
-
删除job
1
curl -XPOST http://admin:117fd7d3aae52a3ce02ace7d783d3bbd9d@jenkins.dianduidian.com/job/test2/doDelete
-
获取Job当前配置
1
curl -XGET http://admin:117fd7d3aae52a3ce02ace7d783d3bbd9d@jenkins.dianduidian.com/job/test/config.xml
-
更新Job配置
1
curl -XPOST http://admin:117fd7d3aae52a3ce02ace7d783d3bbd9d@jenkins.dianduidian.com/job/test/config.xml -d "@test.xml"
-
构建Job
1
curl -XPOST http://admin:117fd7d3aae52a3ce02ace7d783d3bbd9d@jenkins.dianduidian.com/job/test/build
-
参数化构建Job
1 2 3
curl -XPOST http://admin:117fd7d3aae52a3ce02ace7d783d3bbd9d@jenkins.dianduidian.com/job/test/build --data-urlencode json='{"parameter": [{"name":"NAME","value":"11111"}]}' curl -X POST http://admin:117fd7d3aae52a3ce02ace7d783d3bbd9d@jenkins.dianduidian.com/job/test/build \ --form json='{"parameter": [{"name":"branch_name","value":"k8s"}]}'
参考:
https://stackoverflow.com/questions/8424228/export-import-jobs-in-jenkins
文章作者 XniLe
上次更新 2023-10-10