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,455,950
Community Members
 
Community Events
176
Community Groups

How do I approach environment variables in continuous integration via pipelines?

Platform.sh was my first introduction to CI. I love that per branch I can assign environment variables so that with each push the branch deployment responds to its respective environment values.

I am now moving away from Platform.sh and trying to set up my own CI. Of course, I do not want every branch to be deployed using production variables and at the same time, I do not want to create variables named {BRANCH}_SSH_USER. I'd much prefer to have one variable called SSH_USER and have each branches value be different so that my deployment script does not have to be hardcoded to MASTER_SSH_USER or STAGING_SSH_USER.

Am I approaching this the wrong way? If so, how should I be?

1 comment

Hi Tyler I faced a similar situation and ended up doing some workaround, see if it works for you. I created a json environment variable named SSH_USER with value: 

{ "SSH":{"development": { "user": "devuservalue"}, "staging": {"user": "staginguservalue"}}}

This value was set with Secured attribute set; then I user jq to read the value according to the current branch.

sshuser=$(echo $SSH_USER | jq -r ".SSH.${BITBUCKET_BRANCH}.user")

and that did the trick for me, I have a single env variable for any branch, and can be read in a "contextual" manner with the current branch value.

Comment

Log in or Sign up to comment
TAGS

Atlassian Community Events