Reputation: 2316
There are two variables in my .gitlab-ci.yml
file, both of them are used in the same script line:
variables:
TEST_SERVER: 10.11.12.13
BUILD_DIR: "/var/www/distrib"
[...]
script:
- ssh skipper@$TEST_SERVER 'ls -la $BUILD_DIR'
The server IP gets picked up correctly, but the directory gets never reached (and it exists, of course). The directory contents listed below are obviously user's home dir contents:
$ ssh skipper@$TEST_SERVER 'ls -la $BUILD_DIR'
Warning: Permanently added '10.11.12.13' (ECDSA) to the list of known hosts.
total 48
drwxr-xr-x 5 skipper skipper 4096 Mar 12 12:03 .
drwxr-xr-x 16 root root 4096 Mar 11 09:29 ..
-rw------- 1 skipper skipper 2056 Mar 18 09:43 .bash_history
-rw-r--r-- 1 skipper skipper 220 Mar 11 09:29 .bash_logout
-rw-r--r-- 1 skipper skipper 3771 Mar 11 09:29 .bashrc
drwx------ 2 skipper skipper 4096 Mar 11 11:38 .cache
drwx------ 3 skipper skipper 4096 Mar 11 11:38 .gnupg
-rw-r--r-- 1 skipper skipper 807 Mar 11 09:29 .profile
drwx------ 2 skipper root 4096 Mar 11 11:30 .ssh
-rw------- 1 skipper skipper 9800 Mar 12 12:03 .viminfo
I tried defining the directory variable with or without quotation marks, then calling it with double dollar sign ($$BUILD_DIR
), but none of these attempts worked.
Any ideas what is wrong here?
Upvotes: 0
Views: 34
Reputation: 7384
I think the single quotes might be messing with the script section somewhat, as everything inside the single quotes is preserved literally.
Using double quotes round the ls
should resolve the issue.
ssh skipper@$TEST_SERVER "ls -la $BUILD_DIR"
Upvotes: 1