jenkinsfile自动部署接口

复制创建新流水线

  1. 从预先创建的job中获取 config.xml 或根据需要创建另一个
curl -X GET http://xxx.xxx.xxxx.com/job/backup-data/config.xml -u test:xxxxxxxxxxxxxxxxxx-o config.xml

  1. 生成Crumb
CRUMB=$(curl -s 'http://xxxxxxx.xxx.xxx.com/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)' -u test:xxxxxxxxxxxxxx)

echo $CRUMB

  1. 使用 xml 创建另一个 jenkins job
curl -s -XPOST 'http://xxxxx.xxx.xxx.com/createItem?name=api-job-test' -u test:xxxxxxxxxxxxxxxxxx--data-binary @config.xml -H "$CRUMB" -H "Content-Type:text/xml"

更新流水线

拉取新的config.xml

curl -X GET http://xxxx.xxx.xx.com/job/check-master-status/config.xml -u test:xxxxxxxxxxxxxxxxxxxx-o config.xml

将更新的config.xml发布到需要更新的job URL

curl -s -XPOST 'http://xxxx.xx.xx.com/job/api-job-test/config.xml' -u test:xxxxxxxxxxxxxxxx--data-binary @config.xml -H "$CRUMB" -H "Content-Type:text/xml"

你可能感兴趣的:(jenkins,servlet,jenkins,运维)