Build chain off of pull request branches

We have a build chain set up to trigger off of pull requests into the master branch. Right now there is 1 initial build configuration that does the actual building, then two more configurations that have to wait until the Build is finished, but those two have never triggered automatically. For simplicity I'll refer to these simply as Build 1, Build 2, and Build 3.

Build 1
 - VCS: a default branch of master and additional branch specification of +|-:*
 - Trigger: VCS trigger, filter is +:* and -:refs/heads/master
 - Build Features: Pull Requests, by target branch master
So far this has been firing every time that a pull request going into master is created/updated. It does not report back the status to the group as success/failure, but that's because that's how TeamCity works. It would be nice to have it, but not a deal-breaker.

Builds 2 and 3
 - VCS: identical to Build 1
 - Trigger: Finish Build Trigger, targeting Build 1
 - Build Features: identical to Build 1
 - Dependencies:
    - Snapshot: Depends on Build 1, enforces revisions synchronization
    - Artifact: Depends on Build 1, when trying to use the browser I don't get the builds except for the one time Build 1 ran off of master

So I can manually start Builds 2 and 3 in the chain and they work just fine, but they will never fire automatically. From what I've found online, because they aren't the default branch then the status of the build isn't reported to the group as a success or failure. I believe that Builds 2 and 3 have to wait until they get a completed build, and since the default branch is never being built then they don't get triggered. Should I change my default branch to target * instead of master? Or is there some other configuration that I don't have/messed up that can accomplish this?

2 comments
Comment actions Permalink

Hi, Cody. I have duplicated the build configurations you've described and it seems to work for me as is. There are a couple of items you could look into.

You mentioned having the VCS root of Build 1 with a branch specification of +|-:*, which doesn't make sense. Please change this to +:* to include all branches or -:* to exclude all branches. It is important that the branch specification does not include the pull request branches. You can simply leave the branch specification field empty and TeamCity will monitor only the default branch. The pull request build feature will separately monitor for pull request branches. For additional information, please see Pull Request Build Feature.

Please share your settings for the Finish Build Trigger. There should be a Branch Filter field and a tick-box for successful builds only. It would be important for the branch filter to include all branches or at least match the pattern of your pull request branches.

Regarding the status not being reported, I'm not sure what you mean by this. Are you also using the Commit Status Publisher build feature?

0
Comment actions Permalink

I removed the branch specification and reran Build 1 but still don't get either of the other two to kick off.

For my Finish Build trigger the only other thing I didn't include is that I'm currently ignoring the successful builds checkbox because I got desperate to try to make these run no matter what. I don't have a branch filter as an option in that dialog (I am running 2021.2.3)

I am using the Commit Status Publisher feature, but I didn't include it in my original post because that's completely independent of what's going on. I will try to explain it as best as I can. Normally when a build completes it is marked as successful or failed, the color of the build indicates the status, and the project that contains the build will also update its color depending on if all builds passed or a single one failed. My setup has the three builds in their own project, but since they aren't using the building from the default branch in the VCS then the status is not reported back to the project. The project icon is just gray until the default branch is used.

There was one time that I built from the default branch and that the color of the branch is darker. The Build also reports that specific build as the success/failure status. In other words, when using the default branch, Build 1 succeeded and Build 2 failed. Even though the most recent build in Build 2 was successful, the status still reports a failure. I added a snippet to show a little bit of what I mean.

I'm having a little bit of trouble finding the post again, but a while back I stumbled on someone asking how to get the feature branch build status to report as the Build status and the response was that, since it's not listed as the default branch, the status is ignored.

Edit: Just found it in documentation.


0

Please sign in to leave a comment.