简体   繁体   中英

Update Git repository of a jenkins jobs using rest

我从用户那里输入作业名称,git存储库,git用户名和密码作为输入。我能够使用rest创建一个jenkins作业,但是我无法设置该作业的git存储库路径。因此如何与一个使用休息的git存储库?

Maybe you can use the workaround presented in " How to create a job using the REST API and cURL "

First:

Create a job using the UI . This job can be used to create a base config that can be used to create new jobs.

To retrieve the job config.xml that you made via the UI, to use for creating new jobs:

curl -X GET http://developer:developer@localhost:8080/job/test/config.xml -o mylocalconfig.xml

Obviously, replace:

  • developer:developer with your username:password
  • localhost:8080 with your Jenkins URL
  • test with the name of the job that you created via the UI

Then,

use this config to create a new job:

curl -s -XPOST 'http://developer:developer@localhost:8080/createItem?name=yourJobName' --data-binary @mylocalconfig.xml -H "Content-Type:text/xml"

The idea is to:

  • use mylocalconfig.xml (from step 1) as a template,
  • change the content of mylocalconfig.xml with the right git repo path to use in Step 2 and create a job using the Remote access API .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM