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

Repository variable is null when used in a script

I have created a repository variable MY_VARIABLE in Settings/Pipelines/Repository Variable. Using the pipe: atlassian/ssh-run:0.2.2 I execute an script with 


the script just prints "This is MY_VARIABLE:"

How can I solve this issue?


1 answer

0 votes

Hi @jcguevara ,

Please confirm your variable meets all conditions under User-defined variables 

Yes, I have even used one of the default variables and I'm getting the same null result. I have used $BITBUCKET_BRANCH.

edwin Community Leader Jan 15, 2020

The variables for pipe: atlassian/ssh-run are defined as follows

  - pipe: atlassian/ssh-run:0.2.3
      SSH_USER: 'ec2-user'
      SERVER: ''


My script is the following one:

cd /value_iq/git/etl
git pull
CP_OUTPUT=$(cp -uRv /value_iq/git/etl/* /value_iq/etl/)
echo "-------------------------------" >> /value_iq/bitbucket_deployment.log
echo "$(date +"%Y-%m-%d %H:%M:%S") Bitbucket $BITBUCKET_BRANCH deployed Commit: $BITBUCKET_COMMIT. " >> /value_iq/bitbucket_deployment.log
echo "$CP_OUTPUT" >> /value_iq/bitbucket_deployment.log
mysql --user=$DB_USER --password=$DB_PASSWD value_iq << EOF
INSERT INTO bitbucket_deployments (branch, commit, log, created_by) VALUES ("$BITBUCKET_BRANCH", "$BITBUCKET_COMMIT", "$CP_OUTPUT", "$VIQ_USER");

The script is executed by the following pipe:

- pipe: atlassian/ssh-run:0.2.3
   SSH_USER: 'bitbucket'
   SERVER: ''
   COMMAND: ''
   MODE: 'script'
   PORT: '22'

Non of the variables used in the script have a value, except for $CP_OUTPUT that is created within the script.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

3,989 views 69 21
Read article

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