Skip to content

Instantly share code, notes, and snippets.

@lucaswilric
Last active April 16, 2019 06:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucaswilric/a4253a7b667ae531524a to your computer and use it in GitHub Desktop.
Save lucaswilric/a4253a7b667ae531524a to your computer and use it in GitHub Desktop.
Open Buildkite for the current repo and branch
#!/usr/bin/env ruby
# Open Buildkite builds for the current repo and branch
# Tested on OSX 10.10.5
repo = `git info | grep remote.origin.url | sed -nE 's/.*github\.com[\:\/](.*)\.git/\\1/p'`.chomp
buildkite_slug = repo.gsub('_', '-')
branch = ARGV.length > 0 ? ARGV[0] : `git rev-parse --abbrev-ref HEAD`.chomp
`open https://buildkite.com/#{buildkite_slug}/builds?branch=#{branch}`
@jonhiggs
Copy link

That's really cool. Here's another in shell.

#!/usr/bin/env bash
BRANCH=${1:-$(git rev-parse --abbrev-ref HEAD)}
REPO=$(
  git config --get remote.origin.url \
    | awk '
        {
          sub(/.*github.com:?/, "", $0)
          sub(/\.git$/,"",$0)
          gsub(/_/,"-",$0)
          print $0
        }
      '
)

open "https://buildkite.com/${REPO}/builds?branch=${BRANCH}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment