1

Is there a way to add gitlab variables to the command ?

eg: variables: ARTIFACTORY_ADDRESS: "a.com"

script:

sshpass -p "password" ssh -o "StrictHostKeyChecking=no" user@SERVER 'echo $ARTIFACTORY_ADDRESS'

Currently its not taking the value from the variable and printing $ARTIFACTORY_ADDRESS in the console. I want the value to be printed in the console

neel jain
  • 23
  • 7
  • Is this similar to [my previous answer](https://stackoverflow.com/a/69249910/6309)? – VonC Feb 07 '23 at 07:45
  • No... I am not trying to save the ssh output in a variable. My ssh script is getting executed but I need to pass a gitlab variable to that ssh script – neel jain Feb 07 '23 at 11:24

1 Answers1

1

Check first if using double-quotes would help enabling variable substitution:

sshpass -p "password" ssh -o "StrictHostKeyChecking=no" user@SERVER \
        "echo $ARTIFACTORY_ADDRESS"
       ^^^                       ^^^
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250