Forums

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

Repository variable is null when used in a script

jcguevara January 15, 2020

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 

echo "This is MY_VARIABLE: $MY_VARIABLE"

the script just prints "This is MY_VARIABLE:"

How can I solve this issue?

Thanks.

1 answer

0 votes
Edwin Kyalangalilwa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 15, 2020 edited

Hi @jcguevara ,

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

jcguevara January 15, 2020

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

Edwin Kyalangalilwa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 15, 2020

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

script:
  - pipe: atlassian/ssh-run:0.2.3
    variables:
      SSH_USER: 'ec2-user'
      SERVER: '127.0.0.1'
      COMMAND: 'Echo $HOSTNAME'

ssh-run 

jcguevara January 22, 2020 edited

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
  variables:
   SSH_USER: 'bitbucket'
   SERVER: 'hostname.com'
   COMMAND: 'deploy.sh'
   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
TAGS
atlassian, compass, developer experience, devex, platform engineering, internal developer platform, component catalog, atlassian learning, productivity tools, developer productivity, software architecture, compass webinar, engineering teams

Discover how Compass drives DevEx and productivity at Atlassian 🏃🏻‍♂️

Learn why Compass was built to tackle dev experience at scale. See how Atlassian uses it to boost visibility, reduce cognitive load, and drive consistency—plus tips to get started and customize your IDP for stronger team engagement.

Join the webinar ✨
AUG Leaders

Atlassian Community Events