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

2
  • Is this similar to my previous answer? Commented Feb 7, 2023 at 7: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 Commented Feb 7, 2023 at 11:24

1 Answer 1

1

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

sshpass -p "password" ssh -o "StrictHostKeyChecking=no" user@SERVER \
        "echo $ARTIFACTORY_ADDRESS"
       ^^^                       ^^^
Sign up to request clarification or add additional context in comments.

1 Comment

Yeah adding double quotes worked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.