Reputation: 62746
I have a function that invokes the api to return the respective build option. Please, observe:
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:\>
(I used verbose to show the requests)
But the returned build does not contain any parameters, even though they exist:
So, how can we get them?
EDIT 1
Running on the Powershell command line:
C:\> $url = "http://tdc1tfsapp01.dayforce.com:8080/tfs/DefaultCollection/sharptop/_apis/build/builds?api-version=5.0&queryOrder=finishTimeDescending&statusFilter=completed&maxBuildsPerDefinition=1&definitions=5963"
C:\> $b = Invoke-RestMethod $url -UseDefaultCredentials
C:\> $b
count value
----- -----
1 {@{_links=; properties=; tags=System.Object[]; validationResults=System.Object[]; plans=System.Object[]; triggerInfo=; id=602252; buil...
C:\> $b.value|ft buildNumber,result,parameters
buildNumber result parameters
----------- ------ ----------
58.0.0.29011 succeeded
C:\>
EDIT 2
We use on-premise Azure DevOps 2019.
EDIT 3
The full response is:
{
"_links": {
"self": {
"href": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/ecff38d6-a219-4739-8b97-5e5d8d00e7ed/_apis/build/Builds/602252"
},
"web": {
"href": "http://tdc1tfsapp01:8080/tfs/DefaultCollection/ecff38d6-a219-4739-8b97-5e5d8d00e7ed/_build/results?buildId=602252"
},
"sourceVersionDisplayUri": {
"href": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/ecff38d6-a219-4739-8b97-5e5d8d00e7ed/_apis/build/builds/602252/sources"
},
"timeline": {
"href": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/ecff38d6-a219-4739-8b97-5e5d8d00e7ed/_apis/build/builds/602252/Timeline"
},
"badge": {
"href": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/ecff38d6-a219-4739-8b97-5e5d8d00e7ed/_apis/build/status/5963"
}
},
"properties": {
},
"tags": [
],
"validationResults": [
],
"plans": [
{
"planId": "93fdbc13-a822-4237-beab-504bdae399a3"
}
],
"triggerInfo": {
},
"id": 602252,
"buildNumber": "58.0.0.29011",
"status": "completed",
"result": "succeeded",
"queueTime": "2019-10-17T15:42:14.6046801Z",
"startTime": "2019-10-17T15:42:16.042188Z",
"finishTime": "2019-10-17T17:02:25.934717Z",
"url": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/ecff38d6-a219-4739-8b97-5e5d8d00e7ed/_apis/build/Builds/602252",
"definition": {
"drafts": [
],
"id": 5963,
"name": "vNext_test_VL",
"url": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/ecff38d6-a219-4739-8b97-5e5d8d00e7ed/_apis/build/Definitions/5963?revision=4",
"uri": "vstfs:///Build/Definition/5963",
"path": "\\devOps",
"type": "build",
"queueStatus": "enabled",
"revision": 4,
"project": {
"id": "ecff38d6-a219-4739-8b97-5e5d8d00e7ed",
"name": "SharpTop",
"description": "html cannot search",
"url": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_apis/projects/ecff38d6-a219-4739-8b97-5e5d8d00e7ed",
"state": "wellFormed",
"revision": 32574427,
"visibility": "private"
}
},
"project": {
"id": "ecff38d6-a219-4739-8b97-5e5d8d00e7ed",
"name": "SharpTop",
"description": "html cannot search",
"url": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_apis/projects/ecff38d6-a219-4739-8b97-5e5d8d00e7ed",
"state": "wellFormed",
"revision": 32574427,
"visibility": "private"
},
"uri": "vstfs:///Build/Build/602252",
"sourceBranch": "refs/heads/arch/NugetPackageConsolidation",
"sourceVersion": "866fc3b5cecf7648537af0d91172c5c445859cb8",
"queue": {
"id": 3264,
"name": "TDC5DFC1BLD20-CI-feature",
"pool": {
"id": 131,
"name": "TDC5DFC1BLD20-CI-feature"
}
},
"priority": "normal",
"reason": "batchedCI",
"requestedFor": {
"displayName": "Doe, John",
"url": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_apis/Identities/91f94f95-d229-4e55-bfa3-7e33ff1132af",
"_links": {
"avatar": "@{href=http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_apis/GraphProfile/MemberAvatars/win.Uy0xLTUtMjEtNDg3MjU1NDc3LTE2MzE1MjcwMjItMzUxNzQ0NDQyLTEzMzY0}"
},
"id": "91f94f95-d229-4e55-bfa3-7e33ff1132af",
"uniqueName": "xyz\\P123958",
"imageUrl": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_api/_common/identityImage?id=91f94f95-d229-4e55-bfa3-7e33ff1132af",
"descriptor": "win.Uy0xLTUtMjEtNDg3MjU1NDc3LTE2MzE1MjcwMjItMzUxNzQ0NDQyLTEzMzY0"
},
"requestedBy": {
"displayName": "Microsoft.TeamFoundation.System",
"url": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_apis/Identities/000007f5-0000-8888-8000-000000000000",
"_links": {
"avatar": "@{href=http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_apis/GraphProfile/MemberAvatars/s2s.MDAwMDA3RjUtMDAwMC04ODg4LTgwMDAtMDAwMDAwMDAwMDAwQDAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMA}"
},
"id": "000007f5-0000-8888-8000-000000000000",
"uniqueName": "000007F5-0000-8888-8000-000000000000@00000000-0000-0000-0000-000000000000",
"imageUrl": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_api/_common/identityImage?id=000007f5-0000-8888-8000-000000000000",
"descriptor": "s2s.MDAwMDA3RjUtMDAwMC04ODg4LTgwMDAtMDAwMDAwMDAwMDAwQDAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMA"
},
"lastChangedDate": "2019-10-17T17:02:26.297Z",
"lastChangedBy": {
"displayName": "Microsoft.TeamFoundation.System",
"url": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_apis/Identities/000007f5-0000-8888-8000-000000000000",
"_links": {
"avatar": "@{href=http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_apis/GraphProfile/MemberAvatars/s2s.MDAwMDA3RjUtMDAwMC04ODg4LTgwMDAtMDAwMDAwMDAwMDAwQDAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMA}"
},
"id": "000007f5-0000-8888-8000-000000000000",
"uniqueName": "000007F5-0000-8888-8000-000000000000@00000000-0000-0000-0000-000000000000",
"imageUrl": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/_api/_common/identityImage?id=000007f5-0000-8888-8000-000000000000",
"descriptor": "s2s.MDAwMDA3RjUtMDAwMC04ODg4LTgwMDAtMDAwMDAwMDAwMDAwQDAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMA"
},
"orchestrationPlan": {
"planId": "93fdbc13-a822-4237-beab-504bdae399a3"
},
"logs": {
"id": 0,
"type": "Container",
"url": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/ecff38d6-a219-4739-8b97-5e5d8d00e7ed/_apis/build/builds/602252/logs"
},
"repository": {
"id": "ed3ba028-9f6d-44a0-9274-a9c7dcdae79c",
"type": "TfsGit",
"name": "xyz",
"url": "http://tdc1tfsapp01.xyz.com:8080/tfs/DefaultCollection/SharpTop/_git/xyz",
"clean": null,
"checkoutSubmodules": false
},
"keepForever": false,
"retainedByRelease": false,
"triggeredByBuild": null
}
Upvotes: 2
Views: 309
Reputation: 1096
Could the issue be that while both buildNumber
and result
are simple strings, the parameters
is an object with multiple values and your script isn't able to handle that while plotting it?
For example this is what I get when I invoke a similar request for one of my builds via postman:
"buildNumber": "20191017.1",
"result": "failed",
"parameters": "{\"BuildConfiguration\":\"release\",\"BuildPlatform\":\"any cpu\",\"system.debug\":\"false\"}",
Edit
Ok it seems that the parameters
are not sent for builds that were triggered via Continuous Integration.
Respectively the parameters
property of the specific build contains only the parameters that were set by the user (so the things that are settable at queue time). For automatically triggered builds nothing will ever be set at queue time so it is skipped.
If nothing is specified it will then take the value of the variable defined in the build definition - you can access this by fetching the definition and check the variables
:
http://tdc1tfsapp01.dayforce.com:8080/tfs/DefaultCollection/sharptop/_apis/build/definitions/5963
In your response you should find the variables defined as follows:
"variables": {
"system.debug": {
"value": "false",
"allowOverride": true
},
"BuildConfiguration": {
"value": "debug",
"allowOverride": true
},
"BuildPlatform": {
"value": "any cpu",
"allowOverride": true
},
...
}
So your script would need to setup 2 requests, one for the build itself and one for the definition and then you can compile a list of the parameters used for your build.
I also tested what happens if you queue a build via the REST API and pass some parameters via this request - they do show up in the build as parameters
as if you would have manually set them at queue time.
Upvotes: 1