有誰知道如何將構建信息添加到現有的Jenkins構建中?使用REST在Jenkins中添加構建信息
我想要做的是用構建代表的實際完整版本號替換#1內部版本號。我可以通過轉到http:// MyJenkinsServer/job/[jobname]/[buildnumber]/configure
手動執行此操作我試圖使用chrome反向工程來查看它發送給服務器的內容,如下:
Request URL:http://<server>/job/test_job/1/configSubmit
Request Method:POST
Status Code:200 OK
Request Headers view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:192
Content-Type:application/x-www-form-urlencoded
Cookie:hudson_auto_refresh=false; JSESSIONID=qbn3q22phkbc12f1ikk0ssijb; screenResolution=1920x1200
Referer:http://<server>/job/test_job/1/configure
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4
Form Data view URL encoded
displayName:#1
description:test4
core:apply:true
json:{"displayName": "#1", "description": "test4", "": "test4", "core:apply": "true"}**
Response Headers view source
Content-Length:155
Content-Type:text/html;charset=UTF-8
Server:Jetty(8.y.z-SNAPSHOT)
這至少給我的表單參數,我需要POST。所以從這個,我想出了以下python3代碼:
import requests
params={"displayName":"Hello World",
"description":"This is my description",
"":"This is my description",
"core:apply":"true"}
a = requests.post("http://myjenkinsserver/job/test_jira_job_update/1/configSubmit", data=params, auth=(username, pwd), headers={"content-type":"text/html;charset=UTF-8"})
if a.raw.status != 200:
print("***ERROR***")
print(a.raw.status)
print(a.raw.reason)
但遺憾的是這種失敗,出現以下錯誤:
***ERROR***
400
Nothing is submitted
任何想法我做錯了嗎?我對這個問題的方法完全錯了嗎?
謝謝戴夫,刪除所有其他代碼後,「噪音」和標題都工作。 – DelboyJay