集成Web tfs和Python3

问题描述 投票:1回答:1

从python中插入数据到web tfs的正确方法是什么?我有来自Jenkins Automation的特定套件和测试用例的结果,我已经将结果以Json的形式提取到一个python脚本中。 我想在Web tfs中改变相同测试用例的结果。请告知

python tfs
1个回答
0
投票

不知道是否完全明白你的意思。似乎你只是想更新TFS测试用例的结果。使用休息API 来处理这个问题。 它将在测试运行中更新测试结果。

PATCH https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/results?api-version=5.1

由于你使用的是Python,所以它能够使用Python脚本来访问Team Foundation Server (TFS) Rest API。

首先,你需要使用Python来连接你的TFS服务器。TFS使用 NTLM认证协议 你应该使用HTTP NTLM认证,使用 请求 库。

代码Snippet。

import requests

from requests_ntlm import HttpNtlmAuth



username = '<DOMAIN>\\<UserName>'

password = '<Password>'

tfsApi = 'https://{myserver}/tfs/collectionName/_apis/projects?api-version=2.0'



tfsResponse = requests.get(tfsApi,auth=HttpNtlmAuth(username,password))

if(tfsResponse.ok):

    tfsResponse = tfsResponse.json()

    print(tfsResponse)

else:

    tfsResponse.raise_for_status()

更多细节请看这个 博客.

© www.soinside.com 2019 - 2024. All rights reserved.