TeamCity trigger for Github comment on pull request

不羁的心 提交于 2019-12-08 04:18:46

问题


I have my CI on TeamCity. It currently triggers builds on different events (Pull Request creations, merges into Develop branch, etc.). However, I was wondering if it is possible to trigger a specific build as a result of writing a specific comment/labelling a Pull Request.

The goal is to run a set of Automated UI tests when a Pull Request has been approved (from a coding correctness point of view) and that branch is ready to be merged into Develop. I don't want to run that set of Automated UI tests for every commit on that branch as it takes around 1h to run them and I don't want to run it only after merging that PR so we avoid merging anything that breaks the UI tests into Develop.

The desired flow would be to write a special comment on that PR such as run_UI_test or labelling the PR with a custom label so the tests are executed on CI and the feedback is displayed on the PR on Github.

Thank you very much in advance.


回答1:


I don't believe TeamCity has any awareness of the comments on Github since the comments themselves aren't stored directly in the branch(es). My assumption is that you have a VCS Root similar to this:

+:refs/heads/master
+:refs/heads/develop
+:...
+:refs/pull/*/head

It is possible to access the comments of a pull request through the GitHub "Issues API", however, I think this would add unnecessary complexity to your build process and it would obscure how the builds are getting triggered.

My suggestion would be to follow a more tradition CI process and create another layer of "integration" through a new branch. So basically your flow would look like this:

  • master (merge pull requests for release)
  • integration (Run UI automation test)
  • develop (Run basic unit tests and other stuff)

So basically all of your development happens on develop or some other "feature" branch. When all basic tests are passing and you are ready to "promote" you could merge into the integration branch which will then trigger your UI tests. I also want to point out that this "integration" branch could in fact just be "pull requests" and no static branch is actually required depending on how you have your development flow setup.

it's much easier to setup trigger rules and branch filters in TC then it would be to write some custom REST API script to work with the GitHub Issues API.




回答2:


You can achieve similar functionality by setting up a separate build configuration which utilizes a specific VCS Trigger to run the UI tests. This build configuration would also have different build steps which would include the commands to execute your tests.

For example: In Triggers, you can add a new VCS Trigger with +:comment=presubmit:** This would look for any commit message that contains "presubmit" and would trigger your UI test suite to run.

I have seen a few repositories use tools such as https://danger.systems to write custom rules which can look for the text in Github comments and trigger interactions based on the comment.



来源:https://stackoverflow.com/questions/34416556/teamcity-trigger-for-github-comment-on-pull-request

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