LoginSignup
4
5

More than 5 years have passed since last update.

Travis CIとSlackの連携

Posted at

iOSアプリ開発でのTravis CIを試すの続きでTravis CISlackを連携させる。
SlackでTravisCIからの通知を受け取るを参考にそのままだが備忘録として残しておく。

Slackでの設定

  1. アカウント名をクリックして表示されるメニューからApps & integrationsを選択
  2. https://xxx.slack.com/appsのフォームからtravisでインクリメントサーチ結果として表示されるTravis CIを選択
  3. installボタンを押下
  4. Post to Channelでchannelを選択してAdd Travis CI integrationボタンを押下

Travis CI側の設定

「Browse Apps > Travis CI > Edit configuration」の「Setup Instructions」をもとに設定。
表示されている内容(Token)をそのまま.travis.ymlに記載するとセキュリティに十分でないので、Travis CI command line clientを利用して認証情報を暗号化する。

install

$ gem install travis --no-rdoc --no-ri

login

特に必要ない?
参考サイトに記載があったので実行

$ travis login
We need your GitHub login to identify you.
This information will not be sent to Travis CI, only to api.github.com.
The password will not be displayed.

Try running with --github-token or --auto if you don't want to enter your password anyway.

Username: <username>
Password for <username>: ********
Successfully logged in as <username>!

Encrypting your credentials

$ travis encrypt "<team>:<token>" --add notifications.slack
Detected repository as {github repository}, is this correct? |yes| yes

もしforkしたプロジェクトだったり複数のリポジトリがあって一つのリポジトリを特定できない場合だったり?した場合は、明示的にリポジトリを指定する必要がある

$ travis encrypt "<team>:<token>" --add notifications.slack -r accountName/repoName

.travis.ymlの設定

上記の暗号化コマンドを実行すると.travis.ymlに以下の項目が追記される。
しかも空行やコメントが削除された。

travis.yml
...
notifications:
  slack:
    secure: Eywg....

ちなみに特に暗号化コマンドを実行するディレクトリの指定はなく、たまたまプロジェクトルートで暗号化コマンドを実行したけど、適当なディレクトリだとしても追記されるんだろうか?

通知結果

travisci-slack.png

参考

4
5
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
4
5