Add validation checks for GitHub pull requests

2019-02-26 14:00发布

问题:

I'd like to add a validation check on every PR for the master branch to my GitHub repo (for integration with our Bamboo CI).

That is, each push to the master branch will trigger a Bamboo build, which must pass prior to that push being ready to merge.

On the repo's Settings page under "Branch protection for master"-->"Require status checks to pass before merging"

I don't see a status check option for the Bamboo build. How can I add it?

I've already added the Bamboo service in the Webhooks & Services section of the repo settings, and tested that the service can properly trigger a Bamboo build with the "Test service" button.

回答1:

There is an old Bamboo plugin GitHub Status. You can try to install it.

If that doesn't help, there is always an option to add a couple of custom scripts which will post statuses via GitHub Status API.

In fact, it's very simple, all you need is just to make a POST request to your repo:

POST /repos/:owner/:repo/statuses/:sha
{
  "state": "success",
  "target_url": "https://example.com/build/status",
  "description": "The build succeeded!",
  "context": "continuous-integration/jenkins"
}

where :sha is a commit which triggered the build. It's stored in environment variable {bamboo.planRepository.revision}.



标签: github bamboo