十三、禅道提交版本/编辑版本接口
1. 禅道的登录接口或者叫获取tokens接口
"""
-------------------------------------------------------------------------------
File : zentao_login.py
Time : 2023/6/29 13:55
author : mojin
Email : 397135766@qq.com
-------------------------------------------------------------------------------
"""
import requests
url = "http://192.168.1.52:81/zentao/api.php/v1/tokens"
payload = {
"account": "Jenkins",
"password": "Jenkins135766"
}
headers = {}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)
响应结果:{"token":"pkbvni9f2l86dutboguq0n4373"}
2. 禅道新增版本的接口
"""
-------------------------------------------------------------------------------
File : add_version.py
Time : 2023/4/11 12:05
author : mojin
Email : 397135766@qq.com
-------------------------------------------------------------------------------
"""
import requests
url = "http://192.168.1.52:81/zentao/build-create-3.json"
payload={
'execution': '3',
'product': '2',
'name': '名称编号4',
'builder': 'Jenkins',
'date': '2023-04-12',
'scmPath': '代码地址',
'filePath': '下载地址',
'labels[]': 'server-admin.jar',
'desc': '<span style="font-weight:700;background-color:#FFFFFF;">描述</span><span style="font-weight:700;background-color:#FFFFFF;">描述</span>',
}
files=[
('files[]',('server-admin.jar',open('E:/java_xm/server-admin.jar','rb')))
]
headers = {
'Cookie': 'zentaosid=bbfaiimjlfes3pb41vl29cc7s6'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.json())
3. 禅道编辑版本的接口
"""
-------------------------------------------------------------------------------
File : edit_version.py
Time : 2023/4/11 12:05
author : mojin
Email : 397135766@qq.com
-------------------------------------------------------------------------------
"""
import requests
url = "http://192.168.1.52:81/zentao/build-edit-367.json"
payload= {
'product': '2',
'branch[]': ' 0',
'execution': '3',
'name': '名称编号22',
'builder': 'Jenkins',
'date': '2023-04-12',
'scmPath': '代码地址',
'filePath': '下载地址',
'labels[]': '文件名称.xlsx',
'desc': '<span style="font-weight:700;background-color:#FFFFFF;">描述</span><span style="font-weight:700;background-color:#FFFFFF;">描述</span>',
'uid': '6436106b62817'
}
files=[
('files[]',('server-admin.jar',open('E:/java_xm/server-admin.jar','rb')))
]
headers = {
'Cookie': 'zentaosid=2br2egmbcgasrepbn1f13fbla7'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.json())