Jenkins - API详解 (2)

在user的configure页面,创建API token,然后记录下token name对应的密文,保存设置并退出。

Jenkins - API详解


Jenkins - API详解

5.2 配置job的触发条件

Jenkins - API详解

5.3 配置权限

Job和所在project对匿名用户开放build权限

Jenkins - API详解

5.4 配置测试参数

Jenkins - API详解


Jenkins - API详解

5.5 远程触发job

这里是通过curl命令

# 方式-1:cookie crumb=$(curl -c cookies.txt -s \'https://<JENKINS_USER_ID>:1110e7943aeaa4316950dc423f5b15b114@<JENKINS_SERVER_URL>/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)\') curl --cookie cookies.txt --user "<JENKINS_USER_ID>:1110e7943aeaa4316950dc423f5b15b114" -H $crumb -X POST -s https://<JENKINS_JOB_URL>/buildWithParameters?token=testuser # 方式-2:https dns crumb=$(curl -k -u "<JENKINS_USER_ID>:1110e7943aeaa4316950dc423f5b15b114" \'https://<JENKINS_SERVER_URL>/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)\') curl -u "<JENKINS_USER_ID>:1110e7943aeaa4316950dc423f5b15b114" -H $crumb -X POST -s https://<JENKINS_JOB_URL>/buildWithParameters?token=testuser # 方式-3:https dns Parameters crumb=$(curl -k -u "<JENKINS_USER_ID>:1110e7943aeaa4316950dc423f5b15b114" \'https://<JENKINS_SERVER_URL>/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)\') curl -u "<JENKINS_USER_ID>:1110e7943aeaa4316950dc423f5b15b114" -H $crumb -X POST -s https://<JENKINS_JOB_URL>/buildWithParameters?token=testuser\&TEST_ONE=\'test123\'\&TEST_TWO=\'test789\' # 方式-4:http ip:port crumb=$(curl -k -u "<JENKINS_USER_ID>:1110e7943aeaa4316950dc423f5b15b114" \'http://<IP:PORT>/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)\') curl -u "<JENKINS_USER_ID>:1110e7943aeaa4316950dc423f5b15b114" -H $crumb -X POST -s <IP:PORT>/<JOB_PATH>/buildWithParameters?token=testuser 5.6 查看结果

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzxfyf.html