我有一个函数,该函数调用api以返回相应的构建选项。请注意:
C:\> $build = get-builds sharptop vNext_test_VL -Count 1 -Verbose -BuildStatus completed
VERBOSE: GET
http://tdc1tfsapp01.dayforce.com:8080/tfs/DefaultCollection/sharptop/_apis/build/definitions?name=vNext_test_VL&api-version=5.0 with
0-byte payload
VERBOSE: received 2245-byte response of content type application/json; charset=utf-8; api-version=5.0
VERBOSE: GET
http://tdc1tfsapp01.dayforce.com:8080/tfs/DefaultCollection/sharptop/_apis/build/builds?api-version=5.0&queryOrder=finishTimeDescendin
g&statusFilter=completed&maxBuildsPerDefinition=1&definitions=5963 with 0-byte payload
VERBOSE: received 5287-byte response of content type application/json; charset=utf-8; api-version=5.0
C:\> $build | ft buildNumber,result,parameters
buildNumber result parameters
----------- ------ ----------
58.0.0.29010 succeeded
C:\>
((我用冗长的文字显示了请求)
所以,我们如何获得它们?
问题可能是虽然buildNumber
和result
都是简单的字符串,但parameters
是一个具有多个值的对象,并且您的脚本在绘制它时无法处理它?
例如,这是我通过邮递员为我的一个建筑调用类似请求时得到的:
"buildNumber": "20191017.1",
"result": "failed",
"parameters": "{\"BuildConfiguration\":\"release\",\"BuildPlatform\":\"any cpu\",\"system.debug\":\"false\"}",