Help us understand the problem. What is going on with this article?

TravisCIで環境変数を使いたい場合

More than 5 years have passed since last update.

通常の環境変数

TravisCIで以下のような環境変数を使いたい場合は、.travis.ymlenvとして記述すれば良い。

$ export TEST_HOGE='hogehoge'
travics.yml
env:
  global:
    TEST_HOGE='hogehoge'

暗号化した環境変数

DB接続情報やAPIキーなど暗号化したい環境変数がある場合はtravisコマンドで暗号化したものを.travics.ymlに設定すれば良い。

travisコマンドはgemでインストールできる。

$ gem install travis

例えば、以下のようなAPIキーを環境変数で使いたい場合

$ export API_KEY=hogehoge_api_key

travisコマンドで暗号化する。

$ travis encrypt -r shu1/my_repository API_KEY=hogehoge_api_key
Please add the following to your .travis.yml file:

  secure: "jDyFo5FIQi3orZeug2Gxg6Fq0EHG+JzfvB/5W9Y5WGT97azmD/Iuy3W4M6Fx2By4sqVLJ02QSjqSlQHidtBrLTY1lcsuJY3p5/I8zlPO/m4S66XxAGXyPl82PTGtFgxKu4vtNSumCKwVNq5GeBSFDbsPzaUaigMgeZDaFcfXf20="

Pro Tip: You can add it automatically by running with --add.

-rオプションで リポジトリを指定する。
暗号化したものを.travis.ymlに入れる。

travics.yml
env:
  global:
    - secure: jDyFo5FIQi3orZeug2Gxg6Fq0EHG+JzfvB/5W9Y5WGT97azmD/Iuy3W4M6Fx2By4sqVLJ02QSjqSlQHidtBrLTY1lcsuJY3p5/I8zlPO/m4S66XxAGXyPl82PTGtFgxKu4vtNSumCKwVNq5GeBSFDbsPzaUaigMgeZDaFcfXf20=

参考URL

sansan
法人向け名刺管理サービスSansan及び個人向け名刺管理サービスEightを企画・開発・販売するベンチャー
http://jp.corp-sansan.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした