Skip to content

Instantly share code, notes, and snippets.

@ysbaddaden
Created April 16, 2014 21:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ysbaddaden/10936771 to your computer and use it in GitHub Desktop.
Save ysbaddaden/10936771 to your computer and use it in GitHub Desktop.
Magnum CI Web Hook to report build status back to GitHub
require "./server"
run MagnumCIGitHubIntegration
source 'https://rubygems.org'
gem "json"
gem 'sinatra', "~> 1.3.5"
gem "octokit", "~> 3.0"
require "json"
require "sinatra"
require "octokit"
class MagnumCIGitHubIntegration < Sinatra::Base
post "/post_event/:github_token" do |github_token|
@payload = JSON.parse(params[:payload])
@github = Octokit::Client.new(access_token: github_token)
repo = (@payload["commit_url"] =~ %r(github\.com/(.+?/.+?)/) and $1)
status = case @payload["status"]
when "pass" then "success"
when "fail" then "failure"
end
@github.create_status(repo, @payload["commit"], status,
accept: "application/vnd.github.she-hulk-preview+json",
context: "continuous-integration/magnum-ci",
description: @payload["title"],
target_url: @payload["build_url"]
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment