Problems accessing rails 5 credentials

I have continuous delivery setup using travisCI and capistrano for a rails 5 app. As part of the capistrano deploy it sends notifications to a slack channel. This is failing when it tries to access the rails encrypted secrets. For the notifications i’m using capistrano-slackify

I’ve done the following:

added the master.key file to travisci as an encrypted file which contains the slack webhook Added the config for capistrano-slackify to capistrano.

I’ve confirmed that this is working outside of travis as I can deploy and receive notifications, inside of slack, it’s just not working when called inside of travis.

Has anyone experienced this before?

Capfile:

require 'capistrano/slackify'

Deploy.rb

set :slack_url, YAML.load(rails credentials:show)['WEBHOOK'] `
set :slack_channel, ['#devops']

travis.yml

- openssl aes-256-cbc -K $encrypted_8ad82cc635a3_key -iv $encrypted_8ad82cc635a$ -in master.key.enc -out config/master.key -d

Error in build


ruby-2.0.0-p481

ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]

00:00 slack:notify_started

      Notifying Slack of deploy starting

(Backtrace restricted to imported tasks)

cap aborted!

:slack_url is not set

Tasks: TOP => deploy:starting => slack:notify_started

(See full trace by running task with --trace)

The deploy has failed with an error: :slack_url is not set

** DEPLOY FAILED

Hey @strtwtsn,

Have you tried clearing the Travis cache?

Tried that…no luck…my thinking is that travis is decrypting the master.key before the clone stage of the deploy is called…the config/ directory therefore doesn’t exist.

Solved…I moved the variable out of the master.key and added it to the travis encrypted ones.

Imprint