I have the following GitLab CI project variable configured in the UI at the project level.
FILE_SHARE_LOCATION
s:/\ \\1.2.3.4\S:\
I'm running GitLab Auto DevOps and the test job runs this:
/bin/herokuish buildpack test
It fails reading the environment variables.
/tmp/bashenv.333648300: line 786: syntax error near unexpected token `)'
/tmp/bashenv.333648300: line 786: ` \'*|\"*)'
I think it's because of the backslashes in the variable.
How should I properly manage a variable like this?
Make sure you have not used YAML escape sequences (or other conflicting syntax) in your YAML. Because your value includes a
:
(although I think this is a mistake, which I'll explain later), you should enclose your value in quotes to avoid your value being confused as a mapping. Additionally, because your value includes literal\
, you should use single quotes instead of double quotes so that escaping is not needed.For example:
Alternatively, UNC paths can (in most cases) be defined with forward slashes as well, which can avoid the issue of backslashes altogether. This is also the standard for Unix (Linux) systems:
If you use the project settings to set the variable, double check the value is correct in the UI.
Lastly, also note that UNC paths should NOT include the drive letter, which appears to be what you've done here with
\\1.2.3.4\S:\
. Network share paths use the pattern\\<HOSTNAME>\<SHARENAME>\<FILE_PATH>
and never include drive letters.You must create a share first and give it a name. You can map this share to the
S:
drive root, if you want, but is usually a best practice to set a directory as the share target.