Finish Build trigger: get build Id from triggered build

Ideally the teamcity.build.triggeredBy field would provide me with a build Id which I could then use with the REST API to get full details on the build which triggered this one.

As it is, I get a build project and configuration along with a build number. I have not been able to use this information to lookup the build Id with the REST API. Can you give me an example of how to do this?

FYI: I don't want to have a snapshot dependency because I want to have one 'status update' build which is triggered by multiple other build configurations.

Thanks,

Rob.

0
5 comments

Hello Rob,

Do you use finish build trigger? If yes, then "teamcity.build.triggeredBy" parameter contains information about the build that triggered this one. You can parse this parameter in build script and use in REST API request.

Why do you need to access build using REST API? What information you are interested in?

0
Avatar
Permanently deleted user

Hello, Alina. 

I was wondering, is it possible to get the build Id number without using the artifact dependencies?  I have set up my pipeline using the scenario below. 

Main Pipeline --> Once the build is finished --> Trigger another build pipeline (I need to get the build ID from the previous build to send my notification)  

Hope you can provide some insights. 

Thank you. 

Boom

 

 

 

 

0

Hi,

Is there a specific reason for you not to want to have dependencies? As Alina mentioned, the "triggered by" when using the Finish build trigger might provide information about it, but it would make more sense to use snapshot dependencies (which is a built-in mechanism so that you can run a build, and once it finishes, run another one) and you will get access to a large amount of information, including dependency parameters, from where you could identify a build: https://confluence.jetbrains.com/display/TCD18/Snapshot+Dependencies

0
Avatar
Permanently deleted user

hi Denis Lapuente,

snapshot dependencies does not work for below scenario. 

If Build A could be triggered by either build B completion or build C completion, then have to set two Finish Build trigger for Build A with Build B and Build C. And Build A needs to use a parameter P1 that's defined in Build B and Build C with different value.

The question is how can i reference the value of P1 in Build A?  

for above case, snapshot dependencies can not be set, for example, if Build B completion, Build A will be triggered, then Build C will also be triggered which is not expected.

0

There are multiple ways to achieve that.

The recommended approach is to set up a build template based on A, and have A1 and A2 depending independently on B and C respectively. That way you can easily reference the parameter via dependency parameter, plus have better reporting on whether A failed because of B or because of C.

A snapshot dependency will only trigger a new build if changes are available (unless you configure it to always trigger a new build). Snapshot dependencies in this instance also remove the need for the finish build trigger.

Artifact dependencies also give you the ability to pick up a parameter from a depended build. You can also publish the data as an artifact and then pick it up.

 

Referencing P1 in A is trivial with dependencies: https://confluence.jetbrains.com/display/TCD18/Predefined+Build+Parameters#PredefinedBuildParameters-DependenciesProperties

0

Please sign in to leave a comment.