Forums

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

Can I insert variables from a bitbucket into a script when I use atlassian/ssh-run?

creox-bitbucket
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 20, 2019

Can you advise me how to insert a bitbucket variables into the script I have locally and run it via atlassian / ssh-run in pipelines? Snímek obrazovky 2019-10-20 v 21.40.24.pngIn this .contrib file I want use bitbucket variables, but does not work nothing, i tried $VARIABLE, ${VARIABLE}, but without success. 

is there any way to get them there?

or do you have any other better solution?

1 answer

0 votes
Alexander Zhukov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 6, 2019

Hi @creox-bitbucket , using envsubst is probably the easiest solution.

 

- step:
script:
- envsubst < .contrib/deploy.sh > deploy-out.sh

- pipe: atlassian/ssh-run:0.2.2
varialbes:
SSH_USER: $STAGE_USER
SERVER: $STAGE_SERVER
MODE: 'script'
COMMAND: 'deploy-out.sh'

What envsubst will do is it'll basically hardcode your environment variables into your script right where you reference them.

zihang xia
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!
December 30, 2019

Hi @Alexander Zhukov , I tried to use envsubst in the yaml but it failed because of `envsubst` not found. any thoughts about this? thanks

Alexander Zhukov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 16, 2020

You have to install the envsubst package in your step

https://command-not-found.com/envsubst

masernet-atlassian
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!
March 4, 2020

Hey @Alexander Zhukov, not sure if only installing in my step helps. Image needs also to be updated. To be honest, I was expecting this to be "there" because bitbucket-pipelines support aws-ecs pipeline which practically relies on this transformation.

Like # people like this
JannieT June 29, 2020
Pratap Kansara
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!
July 23, 2024

if you are getting `envsubst` not found

- step:
script:
 - apt-get update && apt-get install -y gettext-base
- envsubst < .contrib/deploy.sh > deploy-out.sh

- pipe: atlassian/ssh-run:0.2.2
varialbes:
SSH_USER: $STAGE_USER
SERVER: $STAGE_SERVER
MODE: 'script'
COMMAND: 'deploy-out.sh'

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events