質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

Circle CI

Circle CIは、クラウド上に簡単にCI環境を構築できるWebサービスです。GitHubと連携させ、CIしたいリポジトリーを選択しビルド・テストを行います。チャット等を利用して結果を確認することが可能です。

Q&A

解決済

2回答

508閲覧

CircleCi devise.secret_key was not set

Shika_Tech

総合スコア13

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

Circle CI

Circle CIは、クラウド上に簡単にCI環境を構築できるWebサービスです。GitHubと連携させ、CIしたいリポジトリーを選択しビルド・テストを行います。チャット等を利用して結果を確認することが可能です。

0グッド

0クリップ

投稿2020/03/02 13:06

環境

rails 5.0.7
ruby 2.5.1
devise
Circleci 2

エラー

circleciの設定をしておりますが、おそらくci時にdeviseの環境変数が読み込めずciでエラーが起きてしまいます。
.circleci/config.ymlで、どのように環境変数を読み込ませるのでしょうか?

#!/bin/bash -eo pipefail bin/rails db:schema:load --trace ** Invoke db:schema:load (first_time) ** Invoke environment (first_time) ** Execute environment DEPRECATION WARNING: #fog_provider is deprecated and has no effect (called from block in <top (required)> at /home/circleci/project/config/initializers/carrierwave.rb:7) rails aborted! Devise.secret_key was not set. Please add the following to your Devise initializer: config.secret_key = 'b0ccc

コード

config.yml

1version: 2 # use CircleCI 2.0 2jobs: # a collection of steps 3 build: # runs not using Workflows must have a `build` job as entry point 4 parallelism: 3 # run three instances of this job in parallel 5 docker: # run the steps with Docker 6 - image: circleci/ruby:2.5.1-node-browsers # ...with this image as the primary container; this is where all `steps` will run 7 environment: # environment variables for primary container 8 BUNDLE_JOBS: 3 9 BUNDLE_RETRY: 3 10 BUNDLE_PATH: vendor/bundle 11 PGHOST: 127.0.0.1 12 PGUSER: circleci-demo-ruby 13 RAILS_ENV: test 14 - image: circleci/mysql:5.7 15 environment: 16 MYSQL_ALLOW_EMPTY_PASSWORD: yes 17 MYSQL_ROOT_PASSWORD: '' 18 MYSQL_DATABASE: circleci 19 steps: # a collection of executable commands 20 - checkout # special step to check out source code to working directory 21 22 # Which version of bundler? 23 - run: 24 name: Which bundler? 25 command: bundle -v 26 27 # Restore bundle cache 28 # Read about caching dependencies: https://circleci.com/docs/2.0/caching/ 29 - restore_cache: 30 keys: 31 - rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }} 32 - rails-demo-bundle-v2- 33 34 - run: # Install Ruby dependencies 35 name: Bundle Install 36 command: bundle check --path vendor/bundle || bundle install --deployment 37 38 # Store bundle cache for Ruby dependencies 39 - save_cache: 40 key: rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }} 41 paths: 42 - vendor/bundle 43 44 - run: 45 name: Yarn Install 46 command: yarn install --cache-folder ~/.cache/yarn 47 48 # Store yarn / webpacker cache 49 - save_cache: 50 key: rails-demo-yarn-{{ checksum "yarn.lock" }} 51 paths: 52 - ~/.cache/yarn 53 54 - run: 55 name: Wait for DB 56 command: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s 57 58 - run: 59 name: Database setup 60 command: bin/rails db:schema:load --trace 61 62 - run: 63 name: Run rspec in parallel 64 command: | 65 bundle exec rspec --profile 10 \ 66 --format RspecJunitFormatter \ 67 --out test_results/rspec.xml \ 68 --format progress \ 69 $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) 70 71 # Save test results for timing analysis 72 - store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/ 73 path: test_results 74 # See https://circleci.com/docs/2.0/deployment-integrations/ for example deploy configs 75

ruby

1Devise.setup do |config| 2 config.secret_key = ENV["DEVISE_SECRET_KEY"] 3以下略

CircleCiを触るのは初めてです。
もしわかるかたいらっしゃれば教えてください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

.gitignoreにsecrets.ymlを設定していた事が原因でした。

投稿2020/03/05 15:19

Shika_Tech

総合スコア13

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

CIRCLE CI - プロジェクト内で環境変数を設定するこちらに書かれているように、コードに書きたくない値は、CircleCIの管理画面から環境変数を設定することができるので、このやり方がいいかなと思いました。

投稿2020/03/02 23:28

hatsu

総合スコア1809

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問