Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Where to store API Key on bitbucket?

I am trying to set up a CI/CD process for Salesforce using Docker and SFDX. 

I got everything working except that I am not sure how to safely store the private key that SFDX uses to authenticate into salesforce.


Here's the command that I am using to authenticate:
sfdx force:auth:jwt:grant --clientid $CONSUMER_KEY --jwtkeyfile keys/server.key --username $SFDC_QA_USER --setdefaultdevhubusername --setalias testPipelines --instanceurl $SFDC_QA_URL


Where "CONSUMER_KEY" is a repository variable. 

However server.key is inside a "keys" folder in the branch itself.

I was wondering if there's something like "repository secret files" maybe? If not can I store an encrypted version of the server.key and have docker decrypt it and pass it to SFDX? I am really not sure how to approach this.

1 answer

0 votes
mwatson Atlassian Team Mar 18, 2019

Don't check the key into the repository - it will be in the history forever!

Instead, use the same approach we recommend for additional ssh keys.

See the section entitled Use multiple SSH keys in your pipeline in

@mwatson if you look at the command I posted the property --jwtkeyfile is mandatory and it requires that I specify a file afterwards for it to work. I don't see how adding a SSH key would overcome this. 

Is there really no way to store api key files in bitbucket?

mwatson Atlassian Team Mar 18, 2019

The docs section I linked shows how to store a key in a secure repository variable and then use a code fragment in your step to save it to a file and use it in your scripts. You can use the same approach for other keys, not just ssh keys.

e.g. if you take your key and run (on linux)

base64 -w 0 < keys/server.key

 then store the output in a secure repository variable called SERVER_KEY you can then do this in your step to get it onto your filesystem in your build:

- (umask  077 ; echo $SERVER_KEY | base64 --decode > keys/server.key)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Trello

Taco Tuesday: Your favorite Trello blog takeaway

Hello friends! From the community that brought you Welcome Wednesday, Throwback Thursday and Friday Fun, welcome to Taco Tuesday, a weekly discussion about all things Trello. The best part? One Tac...

89 views 7 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you