Build pull requests to specific branch using TeamCity and Github

对着背影说爱祢 提交于 2019-12-18 04:33:16

问题


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

develop...foo_branch
develop...bar_branch

and skip this:

master...foo_branch
master...bar_branch

In TeamCity I can define branch specification to build all pull requests:

+:refs/pull/*/head

or define filter by source branch:

-:refs/heads/(spikes-*)

But I need filter by target branch. Is it possible?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/32483842/build-pull-requests-to-specific-branch-using-teamcity-and-github

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!