【问题标题】:Preserve API key integrity with Travis-CI build-notification hooks in a public repository在公共存储库中使用 Travis-CI 构建通知挂钩保持 API 密钥完整性
【发布时间】:2012-12-14 21:39:39
【问题描述】:

背景:

我有 open-sourced a repository,这是由 Travis-CI 测试的。 Travis 为测试运行提供了build-notification 挂钩,因此您可以在 IRC、Flowdock、Campfire 和 HipChat 中获得通知。要配置这些挂钩,您必须将设置添加到您的 .travis.yml 配置文件中,该文件是公开的。对于 Hipchat,它看起来像这样:

notifications:
  hipchat: [api token]@[room name]

如果我只是将我的令牌以纯文本形式放在那里,每个人都可以看到我的 API 令牌并访问/发送垃圾邮件我的聊天室。这也是 Travis 添加secure environemt variables 的原因。基本上,您可以使用您的密钥加密字符串并将它们专门绑定到存储库,以便 Travis 可以访问秘密 API 密钥。

你在本地做什么:

gem install travis
travis encrypt github-user/repo MY_SECRET_ENV=super_secret

您在.travis.yml 中输入的内容

secure: <encrypted string here>

问题:

不幸的是,文档并不过分冗长,谷歌没有帮助,stackoverflow 没有帮助,我无法让它工作。

Here is my first try:

travis encrypt github-user/repo HIPCHAT=super_secret

secure: <encrypted string here>
notifications:
  hipchat: <%= ENV['HIPCHAT'] %>@hipchat-room

由于这不起作用,我去了 freenode 上的 travis irc 和 that's what they suggested

travis encrypt github-user/repo key@hipchat-room

notifications:
  hipchat:
    secure: <encrypted string here>

正如您可能已经猜到的那样(我为什么要再次写这个问题?)这也不起作用。 我希望你能帮我解决这个问题。非常感谢

编辑:我很怀疑自己。我对 API 密钥进行了三次检查,它正在工作。这取决于特拉维斯。

2Edit:因为这似乎是一个错误,所以这里是对应的GitHub issue

【问题讨论】:

标签: encryption continuous-integration environment-variables yaml travis-ci


【解决方案1】:

斯蒂芬,

你能试试这个吗:

notifications:
  hipchat:
    - secure: "encrypted string"

如果你不想弄乱你的提交历史,你可以将它推送到一个单独的分支上,Travis 应该为你测试那个分支。

--亨里克

【讨论】:

  • 字符串的解密方式存在错误,因此任何通知引擎都无法访问解密的字符串。现在已修复此问题。
猜你喜欢
  • 1970-01-01
  • 2012-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多