Using REST API to find dependant build

Answered

Hi,

 

I was planning to use REST API to find check-in owner of chained build and get their email id. Is there anyone who implemented these kind of situation using REST.

Can i use REST API in a build step. I am planning to use REST to get all details after execution is completed.

Eg : I have a scenario : 

If Smoketest1 is the build which was triggered due to dependency with Devbuild1, then i need to know whose checkin caused trigger for Devbuild1 and their email.

Any help appreciated.

 

Thanks,

VVP

5 comments

Hello Vishnu,

You can get the usernames of users who committed into the Devbuild1 build using REST API. For example, you can get the build details of the build by it's id stored in %dep.<buildTypeID>.teamcity.build.id% parameter using:

http://teamcity/httpAuth/app/rest/builds/id:<buildID>/

And then iterate through the list of changes, e.g.

http://teamcity/httpAuth/app/rest/changes/id:<changeID>

Also using REST API you can get user's email within TeamCity build: https://confluence.jetbrains.com/display/TCD9/REST+API#RESTAPI-RESTAuthentication.
Another option is to enable "Show changes from snapshot dependencies" option and configure notification rules for "Builds affected by my changes". It this case if build fails the user who committed into Devbuild1 will be notified.

0

Hi Alina,

Thanks for your reply.

But what if multiple people committed to Devbuild. Can we get that as well using this above method.

 

Thanks,

VVP

0

Sorry, I corrected the answer above.

0

Hi Alina,

 

Thanks for the answer. However for reading the xml, we have to download first right. And i need credentails for that. So i have to hardcode my username and password.

Any method for reading xml without credentials? I tried below steps. But was not working. 

 $user = "%system.teamcity.auth.userId%"
$pass= "%system.teamcity.auth.password%"

Any suggestions?

0

Hi Vishnu,

There several options:

  1. Enable guest authentication: include "guestAuth" before the "/app/rest" part: e.g.: http://teamcity:8111/guestAuth/app/rest/builds
  2. If you perform a request from TeamCity build, you can use %teamcity.auth.userId%/%teamcity.auth.password% system properties as credentials.

For more details see the section.

0

Please sign in to leave a comment.