How to get the build id of a snapshot dependency?

I have build B depending on build A via snapshot dependency.
In build B build step I need the build id of A to invoke via http %teamcity.serverUrl%/downloadBuildLog.html?buildId=<buildId of A>

I see I can get the build number like so:
%dep.A.build.number%

But I need the build id, unfortunately %dep.A.build.id% seems not accessible from build B. The build id of A seems only accessible from build A.

How can I get the build id of A in build B?
Or, how else can I download the build log of A from build B ?

0
1 comment

Hello,

If you just need the build log and you don't need to invoke it via http %teamcity.serverUrl%/downloadBuildLog.html?buildId=<buildId of A>
, you could add an artifact dependency and add a dependency to the build log (you can pick it from the hidden artifacts. 

As an alternative, perhaps you could explore the REST API?

First to get the snapshot dependencies:

https://TCSERVER/app/rest/buildTypes/BUILDCONFIGURATIONID/snapshot-dependencies

And from the snapshot depencency data, retrieve the build id that you need with a call such as the one below to retrieve the last build from a given build configuration:

https://TCSERVER/app/rest/builds?locator=status:SUCCESS,state:finished,defaultFilter:False,buildType:BUILDTYPEID

Here is the documentation regarding the REST API if you want to explore it further:

https://www.jetbrains.com/help/teamcity/rest/snapshotdependencies.html

https://www.jetbrains.com/help/teamcity/rest/build.html

Thank you,

Guilherme

0

Please sign in to leave a comment.