How to retrieve the "from" branch in a pull-request build ?

Answered

Hi,

Building GitHub pull requests with TeamCity is a real nice feature ; and encourages to add many PR checks, like the SonarQube Pull Request Analysis.

Managing parameters for master / branch / PR builds could be a little tricky, and TeamCity offers many ways (Meta Runner, the official JetBrains SonarQube TeamCity plugin in the future: #69) to simplify that by auto-managing these parameters (e.g.: in sysenv) from TeamCity build parameters.

This kind of third-party integration could requires the original branch from which pull request is built (Here the 'sonar.pullrequest.branch' mandatory parameter for SonarQube analysis).

This information is displayed in TeamCity UI when you enable PR integration:

But this information (i.e.: 'refs/heads/branch-alix' here) can not be found in TeamCity (displayed) build parameters.

The TeamCity parameters 'teamcity.build.branch' contains the pull-request key (e.g.: 'pull/42') in this case (and used for SonarQube parameter 'sonar.pullrequest.key').

Is there a way to retrieve this information ? (perhaps in a hidden TeamCity parameter ?)

Many thanks
Best regards

2 comments
Comment actions Permalink
Official comment

Hi Alix,

Please review the following feature request that have been recently implemented and the respective feature will be included in TeamCity 2019.2: https://youtrack.jetbrains.com/issue/TW-61490  

There is an attachment in one of the last comments that contains a pre-release version of the Pull Requests plugin with this feature supported (please see the warnings in that comment prior to downloading though).

Cheers

Comment actions Permalink

Hi Anto,

Sorry for my bad search in TC bugtrack ; thanks for the link.

I'm going to test/use that ASAP !!!

Best regards

0

Please sign in to leave a comment.