The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use secret keys with pipelines?

Moe Han
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 13, 2016

Hello,

In my repo, I have a `keys.py` file which I do not commit to Bitbucket. Inside that, I have AWS_SECRET and etc.

Then I do like `keys.AWS_SECRET` to access those keys.

How do I do that so that I can still test using pipelines without changing much to my codebase?

 

Thanks.

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 16, 2016

I had added this as a comment to Philip's answer, but the code sections don't seem to display correctly in a comment.

If you really want to minimise the changes to your code you could try putting your entire "keys.py" file into a single secure variable by base64-encoding it.

base64 < keys.py

Paste the output of that command into the value of a secure variable named "KEYS_PY" and then in your bitbucket-pipelines.yml script:

echo $KEYS_PY | base64 --decode > keys.py

This may or may not work depending on how large "keys.py" is.

 

Peter Havenga
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 1, 2017

In my case this was needed:

echo "$KEYS_PY" | base64 --decode &gt; keys.py

(including " ").

Like # people like this
1 vote
arvinds
January 3, 2020

For binary files like P12 how it can be stored? 

argentum47
May 17, 2021

Hi Arvinds,

 

Were you able to how P12 files can be stored using secrets?

1 vote
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 13, 2016

Hi Moe,

You can use a secured environment variable for to achieve this. 

Variables in pipelines - Atlassian Documentation

The variable value will be masked from all log output if you mark it as a "secured" variable on creation. 

By the sounds of it, the only thing you will have to change is that you read in these values as an environment variable, instead of from a file. 

Thanks. 

Olve Hansen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 25, 2019

Link is dead

Like # people like this
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 27, 2019

The link is now fixed, thank you for pointing that out @Olve Hansen

Like alistersneddon likes this

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events