LoginSignup
19
19

More than 5 years have passed since last update.

CI ビルド URL を開く ciopen コマンド

Posted at

元ネタは Quipper の CTO (@tomo) が社内向けにシェアした zsh コマンド。別途 hub をインストールしてください。
https://hub.github.com/

# 使い方:
# 1. 以下を .bashrc などにコピペして保存 -> 端末・シェル再起動または .bashrc 再読み込み
# 2. Git リポジトリを clone したディレクトリに移動 -> Pull Request と紐付いているブランチを checkout
# 3. $ ciopen [COMMIT]
#    $ ciopen head
#    $ ciopen head^
#    $ ciopen head~2
ciopen() {
  commit=$1
  result=$(hub ci-status -v $commit)
  if [ $? == 3 ]; then
    echo $result
  else
    open $(echo $result | awk '{print $2}')
  fi
}

Untitled.gif

元ネタとの差分:

  • 元ネタは zsh 用で precmd を使っていたが自分は bash ユーザーなので zsh 依存を無くした
  • 元ネタは git サブコマンドを駆使して repo, branch を特定していたが hub ci-status コマンドを使うように変更した(その結果 hub に依存するようになった)
  • 元ネタは https://circleci.com/gh/circleci/frontend/tree/levlaz_docker_docs のような URL を開くが hub ci-status -v で得られる CI ビルドの permalink を開くように変更した

どうぞご利用ください。

hub コマンドを使っていない方はこの機会にぜひお試しを。 hub ci-status 以外にも hub browsehub compare など便利なコマンドがあるのでおすすめです。

19
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
19