fzngagan
(Faizaan Gagan)
2 سبتمبر 2020، 12:20م
1
Some client libraries like GitHub - googleapis/google-auth-library-ruby: Google Auth Library for Ruby require the authentication credentials to be set as environment variables. Is it possible to pass them via the yml file.
I tried
Adding export VAR=VALUE to the custom commands section of the yml file.
Adding VARIABLE: VALUE to the env section of the yml.
fzngagan
(Faizaan Gagan)
2 سبتمبر 2020، 1:32م
2
@merefield pointed out to me that its indeed possible.
in the custom commands section do
# adds the variable to .bashrc file
exec: echo 'export VAR=value' >> ~/.bashrc
...
# reloads the file
exec: source ~/.bashrc
I can confirm that this approach indeed works.
p.s.
Somehow the source ~/.bashrc doesn’t update the environment. Maybe its being called too early.
Also tried,
- exec: /bin/bash -c "source ~/.bashrc"
6 إعجابات
justin
(Justin DiRose)
2 سبتمبر 2020، 4:28م
3
Can’t you use the env: section of the container definition for this? That should create an environment variable the Rails app can access.
So like
env:
CUSTOM_ENV: "value"
Otherwise it looks like pups already pipes in env variables on the host , too.
5 إعجابات
fzngagan
(Faizaan Gagan)
2 سبتمبر 2020، 4:41م
4
That gives me an error related to docker. That would be very intuitive if it worked like that. Or I’m crazy. I think there’s a rule to accept custom vars starting with DISCOURSE_.
إعجابَين (2)
fzngagan
(Faizaan Gagan)
2 سبتمبر 2020، 5:00م
5
I’ll try the env thing once again when I get at my desk tomorrow.
3 إعجابات
fzngagan
(Faizaan Gagan)
2 سبتمبر 2020، 6:02م
6
So, I was crazy. This works fine. The issue was due to a multiline value. I removed it and the build suceeded. But the question is, how to use multiline values?
3 إعجابات
fzngagan
(Faizaan Gagan)
3 سبتمبر 2020، 9:24م
7
Yuhoo, I was able to make it work. The issue was that I was using a RSA Private key as an environment variable. This is what needs to be done to make that work.
wrap your key in single quotes '' and add an extra \ with all the \n appearing in the key. i.e. \n would be come \\n.
إعجاب واحد (1)
just FYI, there are easier ways of doing that then updating all of the \n directly.
Something like this:
key: |
---BEGIN SECRET KEY---
SHH do not read this is secret
---END SECRET KEY---
إعجابَين (2)
fzngagan
(Faizaan Gagan)
3 سبتمبر 2020، 10:49م
9
featheredtoast:
Something like this:
Do you mean pasting the middle part of the key as it is? That would be somewhat more cleaner.
I mean that yml has multiline support starting with the | character (and optional variations)
You can then paste the key as-is with no edits (aside from prefixed spaces).
إعجاب واحد (1)
fzngagan
(Faizaan Gagan)
3 سبتمبر 2020، 10:53م
11
I tried a silly thing I added | and an actual new line instead of each \n which didn’t work.