问题
I am using Visual Studio Online for continuous integration. I've also enabled integration with Slack (posting build status) and GitHub (validating pull requests).
In both of these integrations I am missing one feature - posting build error log to either Slack or GitHub (for example, as a comment to the pull request). This might substantially improve reaction time, since you don't need to go to the failed build (often re-login to VSO), find errors in the log, etc.
Did any of you guys manage to get this working somehow?
回答1:
You can use web hook to return VSTS build error message to slack or do some actions (create issue, close pull request etc) on github.
Prerequisite:
Web hook for VSTS build failed.
Develop a website to receive information, queue VSTS build and close pull request on github.
Add a build definition with Post To Slack task, when your VSTS build failed, your website will queue this build.
Create web hook:
VSTS project -> Service Hooks -> Create subscription -> Web hooks -> Next -> select Build completed to trigger this event -> select your CI build definition -> set Build Status to Failed -> Next -> set your website address to URL -> test if it works for your website -> Finish.
Develop functions on your website:
After your website receiving message from web hooks, trigger below actions:
- Queuing the build with Post To Slack task by REST API.
- Close a pull request on github by REST API v3.
来源:https://stackoverflow.com/questions/44443184/posting-build-errors-to-slack-or-github