LoginSignup
0
1

More than 5 years have passed since last update.

TravisのAccess tokenを取得したかった

Posted at

ビルドの定時実行をしたかったので

ニフティクラウドタイマーを使ってTravis CIで定期的にビルドを実行する - higeblog

↑にある通り

curl -s -X POST -H 'Content-Type: application/json' -H 'Accept: application/vnd.travis-ci.2+json' https://api.travis-ci.org/auth/github -d '{"github_token":"GITHUB_TOKEN"}'

としても

you are currently not allowed to perform this request. please contact support@travis-ci.com.

トークンくれなかったので
こう

gem install travis
travis login --github-token GITHUB_TOKEN
travis token

もらえた。

疎通テスト

body='{
"request": {
  "branch":"master"
}}'

curl -s -X POST \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Travis-API-Version: 3" \
  -H "Authorization: token {TRAVIS_TOKEN}" \
  -d "$body" \
  https://api.travis-ci.org/repo/{ACCOUNT}%2F{REPOSITORY}/requests

(備考)rubyが古い場合

Macなのでrubyが古く(2.0.0)、travisコマンドが入らなかったのでアップグレードした。

brew install rbenv
rbenv install 2.3.0
rbenv global 2.3.0
echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
ruby -v

MacでRuby開発環境設定:デフォの1.8.7→1.9.3にする&rbenvも - Qiita

(備考2)

Travisのアカウントページ上に表示されるトークンは関係ない(別のもの)。

0
1
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
0
1