Within a gitlab-ci job, I want to create a directory (on a remote server) with the job id and perform some actions more or less as follows:
- ssh user@server mkdir -p /user/$CI_JOB_ID
- ssh user@server <perform_some_action_that_creates_several_zip_files>
- LAST_MODIFIED_FILE=$(ssh user@server bash -c 'find /user/$CI_JOB_ID -iname "*.zip" | tail -n 1 | xargs readlink -f')
The directory does get created and the action that creates several zips works out.
However, the last command that I use for getting the last modified/created .zip does not work, because $CI_JOB_ID does not seem to get expanded.
Any suggestions?
CI_JOB_IDa environment variable in remote machine?ssh user@server mkdir -p /tmp/$CI_JOB_ID"find /user/$CI_JOB_ID -iname '*.zip' | tail -n 1 | xargs readlink -f". Here, the single quotes may prevent variable expansion for$CI_JOB_IDvariablesfile holding entries such asexport CI_JOB_ID=$CI_JOB_ID, copying it to the remote server and sourcing it ... no luck either ...variablesfile) the variable is not available... these are distinctsshsessions