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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,465,239
Community Members
 
Community Events
176
Community Groups

Best practice for secret files

Is there really no straight-forward way to inject secret files into a build with Bitbucket pipelines? Coming from Jenkins, this feels like a massive oversight.

I have seen people say "save it as an env variable", however I tried this with some TLS certificates and the indentation got messed up and the certificate became invalid.

I thought this was such an obvious use case that it would have direct support. I don't really want to have to go around creating sFTP servers to go with each repo just to copy in some secret certificates here and there.

Was this discussed at some point and the community decided on "will not fix"? If Jenkins can manage it easily enough then why can't Bitbucket?

1 answer

1 vote
Patrik S Atlassian Team Jul 21, 2022

Hello @Steven Gillies ,

Thank you for reaching out to Atlassian Support.

Secret environment variables are indeed the way to go if you want to inject secret contents into your build. The reason why the indentation got messed up in your attempt is because pipelines do not currently support line breaks in environment variables, so you will need to base-64 encode the content of the file before saving it to the environment variable:

  • Linux :
$ base64 -w 0 < my_file.txt
  • MacOS :

$ base64 < my_file.txt

Then, within your pipeline script, you can decode the variable value and save it to a file :


pipelines:  

  default:

    - step:

        script:

           - (umask  077 ; echo $MY_SECRET_VAR | base64 --decode > ~/my_file.txt)

 Would you please try the suggestion above and let us know how it goes ? 

Thank you, @Steven Gillies .

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events