使用 rest 更新 Git 个 jenkins 作业的存储库
Update Git repository of a jenkins jobs using rest
我正在使用工作名称、git 存储库、git 用户名和密码作为输入 user.I 我能够使用 rest 创建一个 jenkins 工作,但我不能设置作业的 git 存储库 path.So 如何使用 rest 将 jenkins 作业与 git 存储库连接?
也许您可以使用“How to create a job using the REST API and cURL ”
中提供的解决方法
第一个:
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
然后,
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"
想法是:
- 使用
mylocalconfig.xml
(来自第 1 步)作为模板,
- 使用正确的 git 回购路径更改
mylocalconfig.xml
的内容以在步骤 2 中使用,并使用 Remote access API. 创建作业
我正在使用工作名称、git 存储库、git 用户名和密码作为输入 user.I 我能够使用 rest 创建一个 jenkins 工作,但我不能设置作业的 git 存储库 path.So 如何使用 rest 将 jenkins 作业与 git 存储库连接?
也许您可以使用“How to create a job using the REST API and cURL ”
中提供的解决方法第一个:
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
然后,
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"
想法是:
- 使用
mylocalconfig.xml
(来自第 1 步)作为模板, - 使用正确的 git 回购路径更改
mylocalconfig.xml
的内容以在步骤 2 中使用,并使用 Remote access API. 创建作业