2

Is there a way in Teamcity REST API to get the agent name of the last successful build. I am using Teamcity 8.0.6. I tried this

http://<TeamcityServer>/httpAuth/app/rest/buildTypes/id:BuildId/builds?status=SUCCESS

But the result returned doesn't contain Agent name.

Mohammad Nadeem
  • 9,134
  • 14
  • 56
  • 82

1 Answers1

3

The following will give you the last successful build details for a given build type (where BUILDTYPE is the btxxx id):

http://<TeamcityServer>/httpAuth/app/rest/builds/buildType:(id:BUILDTYPE),status:SUCCESS

The response contains the agent details in the /build/agent element.

SteveChapman
  • 3,051
  • 1
  • 22
  • 37
  • 2
    Slightly modified, it to get just the agent name. http:///httpAuth/app/rest/builds/buildType:(id:BuildId),status:SUCCESS/resulting-properties/system.agent.name – Mohammad Nadeem Jun 18 '14 at 05:14
  • Just for good measure, on command line using curl and xmlstarlet: `curl -g "http:///guestAuth/app/rest/builds/buildType:(id:BUILDTYPE),status:SUCCESS" -s | xml sel -t -m "/build/agent" -v "@name"` – SteveChapman Jun 18 '14 at 05:36