Trigger another build using a specific branch

Answered

Hi,

I have 2 build configurations in Teamcity which both work independently. Now I would like to trigger ProjectA whenever the Build of ProjectB is started with respect to there branch names.

ProjectA uses branches like ProjectA-x.x.x where x.x.x is the version number

and Project B uses the same branch names except the prefix is ProjectB. Version number is the same.

So when starting ProjectB with branch ProjectB-1.0.1 then ProjectA should be started as well using branch ProjectA-1.0.1

How can I achieve this ?

 

 

2 comments
Comment actions Permalink

Hi Marco,

 

when you have builds connected via snapshot dependencies, forming a build chain, it tries to match the branches via what we call a logical branch name https://www.jetbrains.com/help/teamcity/working-with-feature-branches.html#WorkingwithFeatureBranches-Logicalbranchname .

 

A possibility in your scenario would be to set your default branch with whatever value you want to fall back (typically master, dev, production, etc), then your branch specification could look something like this:

ProjectA Branch specification:

refs/heads/ProjectA-*

ProjectB Branch specification:

refs/heads/ProjectB-*

Then have ProjectA have a snapshot dependency on ProjectB, that way everytime ProjectA is triggered, it will automatically trigger a ProjectB build. In this situation, if branch "ProjectA-1.0.1" is triggered, it will try to match the "1.0.1" from project B, matching it to refs/heads/ProjectA-1.0.1, in case the branch exists.

 

The other option would be for you to manually parse the branch name, or pick up the pattern that forms the branch from some other variable and trigger it via REST: https://www.jetbrains.com/help/teamcity/rest-api.html#RESTAPI-TriggeringaBuild

0
Comment actions Permalink

Hi Denise,

thanks for your answer but I vave wrongly expressed what I wanted to achive.
In the above scenario I have ProjectA with a branch called Project-1.0.0 and a user checks in a change to this branch.
Now the build should start for this change in ProjectA and afterwards it should start a build in ProjectB using branch ProjectB-1.0.0.
I have no idea if this scenario is possible in Teamcity.

0

Please sign in to leave a comment.