Search code examples
gitlab-cicicdsshpass

Passing gitlab variables in sshpass script


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


Solution

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

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