0
votes

Hey all I'm new to the TFS api world so help would be great!

I am looking to gather information on my projects from the tfs version 15.112.26307.0 (2017) server.

My TFS web URL that lists ALL my projects is : http://tfsserv001:8080/tfs/prog/_projects

My TFS test app is this: http://tfsserv001:8080/tfs/prog/---2017

I am looking to get the build status from the Build & Release > Builds tab via API: enter image description here

And after its succeeded I would then like it to create a release: enter image description here

Are both above possible by using the TFS api?

1
What is insufficient about the build in release triggers?Daniel Mann
@daniel im just making it automated. thats my preference.StealthRT
The triggers you can set on a release are automated. The release is created when the trigger conditions are satisfied, with no user intervention.Daniel Mann
Hi StealthRT, any update on this? Have my solution help you figured out it?PatrickLu-MSFT

1 Answers

0
votes

There is related Rest API to get build result- include the status info

 "result": "succeeded",

You could also use Rest API to create(trigger) a release based on some info such as build ID.

For more details you could take a look at this blog shows how to use rest api in powershell:


Moreover, Daniel is right. You could check the Continuous deployment(create release and deploy whenever a build completes) when you create a new release definition or select in triggers of the release definition. TFS server will handle this automatically, without the need of user intervention.

enter image description here


Update

A example when you open a build result in the web portal just as: enter image description here

In the entire url there will include a buildID such as buildID=49. So according to above screenshot, you should use

 Get http://xxx:8080/tfs/DefaultCollection/ScrumMttApple/_apis/build/builds/49/?api-version=2.0

Then will get below JSON result:

  "id": 49,
  "buildNumber": "20170525.5",
  "status": "completed",
  "result": "succeeded",
  "queueTime": "2017-05-25T19:17:39.6545026Z",
  "startTime": "2017-05-25T19:17:42.2482602Z",
  "finishTime": "2017-05-25T19:25:15.6808731Z",
  "url": "http://win-kev0061habi:8080/tfs/DefaultCollection/bdd4809b-e6dd-4cb8-8e60-762373b20cdc/_apis/build/Builds/49",
  "definition": {
    "path": "\\",
    "type": "build",
    "revision": 5,
    "id": 14,
    "name": "OrdertTest", 
.....