简体   繁体   English

Rails-无法使Travis CI掌握我的S3凭据

[英]Rails - can't get Travis CI to grasp my S3 credentials

I got completely jammed at trying to get AWS S3 to work together with Travis using Figaro. 我完全想尝试使用Figaro使AWS S3与Travis一起使用。

This all works fine in dev mode: 所有这些在开发模式下都可以正常工作:

picture.rb picture.rb

class Picture < ApplicationRecord
  acts_as_list
  belongs_to :imageable, polymorphic: true

  has_attached_file :image,
    :storage    => :s3,
    :bucket     => Figaro.env.s3_bucket,
    :s3_region  => 'eu-west-1',
    :s3_credentials => {
      :access_key_id      => Figaro.env.aws_access_key_id,
      :secret_access_key  => Figaro.env.aws_secret_access_key
    }

  do_not_validate_attachment_file_type :image
end

application.yml application.yml

aws_access_key_id: 'xxx'
aws_secret_access_key: 'xxx'
aws_region: 'eu-west-1'

development:
  s3_bucket: 'company-name-dev'

production:
  s3_bucket: 'company-name-prod'

Obviously Travis needs access to these keys: 显然,Travis需要访问以下密钥:

.travis.yml .travis.yml

language: ruby
before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
rvm:
- 2.4.0
bundler_args: "--jobs=2"
script:
- bundle exec rake db:setup
- bundle exec rake spec
cache: bundler
services:
- postgresql
addons:
  postgresql: '9.4'
deploy:
  provider: heroku
  api_key:
    secure: verlongherokukey
  app: imkerij
  on:
    repo: MyGitHub/MyRepoName
  skip_cleanup: true
env:
  matrix:
  - s3_bucket='company-name-dev'
  global:
  - secure: verylongkey
  - secure: anotherverylongkey

I keep on getting AWS missing credentials errors or Figaro MissingKeys errors in Travis. 我一直在Travis中不断遇到AWS缺少凭证错误或Figaro MissingKeys错误的情况。

Figaro::MissingKeys: Missing required configuration keys: ["aws_access_key_id", "aws_secret_access_key"]

Which only happened btw after adding: 在添加之后才发生:

Figaro.require_keys("aws_access_key_id", "aws_secret_access_key")

Before that I got AWS credentials missing or something, all the time. 在此之前,我一直都缺少AWS凭证或其他东西。

Seems like the keys are not getting through. 好像按键没有通过。 Also not when using the ENV form of writing them down. 当使用ENV形式写下它们时也不是。 Then even in development stuff doesn't work anymore. 然后,即使在开发中,东西也不再起作用。

Any help is certainly appreciated. 任何帮助当然是感激的。 Got me stuck for days. 让我困了好几天。 Also another solution, just using secrets I would appreciate. 还有另一种解决方案,只使用秘密,我将不胜感激。

I solved this by going inside my Travis CI project settings, where I could add the keys. 我通过进入Travis CI项目设置来解决此问题,在其中可以添加密钥。 Worked immediately. 立即工作。

Using the travis encrypt function for my .yml in each and every way did not. 没有以任何方式为我的.yml使用travis encrypt功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM