使用秘密API密钥特拉维斯慈 [英] Using secret api keys on travis-ci

查看:226
本文介绍了使用秘密API密钥特拉维斯慈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用特拉维斯-CI 为我的项目的。

该项目是一个API包装,这么多的测试依赖于使用秘密API密钥。在本地测试,我只是将它们存储为环境变量。什么是使用上特拉维斯这些密钥安全的方式?

The project is an API wrapper, so many of the tests rely on the use of secret API keys. To test locally, I just store them as environment variables. What's a safe way to use those keys on Travis?

推荐答案

特拉维斯有一个功能,加密环境变量(的安全环境变量)。这可以用来保护你的秘密API密钥。我已经成功地用这为我的Heroku API密钥。

Travis has a feature to encrypt environment variables ("Secure environment variables"). This can be used to protect your secret API keys. I've successfully used this for my Heroku API key.

所有你需要做的就是安装特拉维斯宝石,加密你想要的字符串,并在 .travis.yml 添加加密的字符串。加密仅适用于一个存储库。在特拉维斯命令获取你的公钥对你的回购,然后就可以在生成过程中解密字符串。

All you have to do is install the travis gem, encrypt the string you want and add the encrypted string in your .travis.yml. The encryption is only valid for one repository. The travis command gets your public key for your repo and can then decrypt the string during the build.

gem install --user travis
travis encrypt MY_SECRET_ENV=super_secret -r my_username/my_repo

这为您提供了以下的输出:

This gives you the following output:

Please add the following to your .travis.yml file:

  secure: "OrEeqU0z6GJdC6Sx/XI7AMiQ8NM9GwPpZkVDq6cBHcD6OlSppkSwm6JvopTR\newLDTdtbk/dxKurUzwTeRbplIEe9DiyVDCzEiJGfgfq7woh+GRo+q6+UIWLE\n3nowpI9AzXt7iBhoKhV9lJ1MROrnn4DnlKxAEUlHTDi4Wk8Ei/g="

这篇关于使用秘密API密钥特拉维斯慈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆