Build pull requests to specific branch using TeamCity and Github

前端 未结 3 822
余生分开走
余生分开走 2020-12-16 13:00

I want TeamCity to build all pull requests to specific target branch, e.g. develop.
So, I want to build following pull requests:

develop...f         


        
相关标签:
3条回答
  • 2020-12-16 13:19

    Currently it's not possible to differentiate pull request branches based on their target branch in TeamCity. Please watch/vote for the request https://youtrack.jetbrains.com/issue/TW-43759 which is planned for the upcoming release.

    0 讨论(0)
  • 2020-12-16 13:26

    Build Feature: Pull Request

    Pull request support is implemented as a build feature in TeamCity. The feature extends the VCS root’s original branch specification to include pull requests that match the specified filtering criteria.

    To configure the pull requests support for a build configuration, go to Build Configuration Settings | Build Features, click Add build feature, and select the Pull Requests feature from the dropdown list in the dialog.

    Source: https://blog.jetbrains.com/teamcity/2019/08/building-github-pull-requests-with-teamcity/

    So the filtering is done with the Build Feature: Pull Request, where By target branch: should be set to the targetet branch for example refs/head/master or refs/head/myspecialbranch

    0 讨论(0)
  • 2020-12-16 13:27

    I've written a script to work around this issue. It can be run as one of the first build steps in TC's build configuration. The script will ask for pull request details from Github, parse the response and inject source and target branch names as TeamCity parameters and environment variables. In the next build steps, you'll be able to abort the build or do whatever else you need based on these variables.

    https://gist.github.com/dzzh/a6d8631e9617777fb5237bc9ec7b356b

    For the script to work, you'll have to submit PR's id as a command-line argument. We use the recommended refspec (refs/pulls/*/head) to run our builds, I extract the PR id from it and invoke the script with it.

    0 讨论(0)
提交回复
热议问题