我似乎无法找到任何谈论如何允许travis ci编码env变量为github上的其他用户工作的地方。我正在使用travis ci和django项目。 当前.travis.yml文件:
language: python
python:
- 3.6
env:
global:
- secure: # encrypted string for SECRET_KEY
- secure: # encrypted string for another settings KEY
- secure: # encrypted string for another settings KEY
install:
- pip install -r requirements/requirements.txt
script:
- flake8 --count --quiet
- python manage.py migrate --run-syncdb
- python manage.py test
当我推送补丁时,这对我来说很好,travisci运行检查很好。但是当其他人(甚至我使用另一个github帐户)时,travis ci无法说它找不到SECRET_KEY,这是我在.travis文件中安全编码的env变量之一。
答案 0 :(得分:0)
我真的不知道为什么这不起作用,但以下工作。
转到Travis上的项目设置:
https://travis-ci.org/USER/REPO/settings
或强>
https://travis-ci.com/USER/REPO/settings
取决于您的Travis版本。
然后,您只需在此部分添加您的秘密变量:
环境变量
请记住检查构建日志中的"显示值" tile未设置为true。
以下是我项目之一的示例:
请记住不加密这些变量。
然后,您可以在.travis.yml中使用它们,并使用您在设置页面上输入的名称。
(在我的情况下:CLIENT_ID等)
您不需要在.travis.yml文件中声明它们。
希望这有帮助。