Pass variable in remote SSH-command in Jenkins-job
7,104
Resolved.
Via this:
ssh jenkins@srv1 "mkdir D:\myfolder\\$test"
So, we have to add \
before our variable
Related videos on Youtube
Author by
Piduna
Updated on September 18, 2022Comments
-
Piduna over 1 year
i have a little test job:
touch 22.txt echo "wwe" > 22.txt test=$(echo ${BUILD_NUMBER}) echo $test ssh jenkins@srv1 "mkdir D:\myfolder\$test" ssh jenkins@srv1 "dir D:\myfolder\"
BUILD_NUMBER
means build number of job in Jenkins
What i have in output:Running as SYSTEM [EnvInject] - Loading node environment variables. Building remotely on MAC-slave in workspace /Users/Admin/workspace/testmacosx [testmacosx] $ /bin/sh -xe /var/folders/rq/4q3q1m2959q6zpgxghhrvdnw0000gn/T/jenkins1551827609931995498.sh + touch 22.txt + echo wwe ++ echo 5 + test=5 + echo 5 5 + ssh jenkins@srv1 'mkdir D:\myfolder$test' /var/folders/rq/4q3q1m2959q6zpgxghhrvdnw0000gn/T/jenkins1551827609931995498.sh: line 7: unexpected EOF while looking for matching `"' Build step 'Execute shell' marked build as failure Finished: FAILURE
How, you have saw, it does not see this variable
$test
in the remote ssh-command. How i can pass this variable ? Can you help me please ? -
Giovanne Afonso over 2 yearsWorked for me today