15
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Travis CIでsecret valueを扱う

Posted at

Secure-environment-variablesのとおり。
やってみる。

準備

Travis Clientをインストールする。

$ gem install travis

Encrypt

公開鍵を使って暗号化するようです。ソース

$ cd my_project
$ travis encrypt MY_SECRET=super_secret
Please add the following to your .travis.yml file:

  secure: "Vl4wZ31VKVsF+w2Vowv1l/hC6p1a7BR8mwonSswcvpdbmz289dFE7oUW7gw3nwzE1lRe71Soh90YqMnGmMY6UASRWHMkDLbf4BACkt4jJKSfQyWRf+J1YmHS8l1lrhk6V+RUsQjNdGbOkuZ5PQVzpwsPzHut4UgrxuLfpW9SkIg="

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

--add env.globalのようにaddオプションを使うと.travis.ymlに自動で更新してくれますが、インデント崩れたりする。

試してみる

.travis.yml
env:
  global:
    - secure: "Vl4wZ31VKVsF+w2Vowv1l/hC6p1a7BR8mwonSswcvpdbmz289dFE7oUW7gw3nwzE1lRe71Soh90YqMnGmMY6UASRWHMkDLbf4BACkt4jJKSfQyWRf+J1YmHS8l1lrhk6V+RUsQjNdGbOkuZ5PQVzpwsPzHut4UgrxuLfpW9SkIg="
test/env_test.rb
def test_secret
  assert_equal "super_secret", ENV['MY_SECRET']
end

result

15
14
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
15
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?