I am trying to implement the following step in my gitlab CI pipeline and running into syntax errors: unexpected end of file
- export PATH=$PATH:.cargo/bin
if [ "$CI_COMMIT_REF_NAME" == "/^staging\/.*/"]; then
echo "Skipping version check for staging branch"
RUST_LOG=info [run some shell command]
I don’t think using rules would work for me since I want to run different scripts based on the branch rather than decide when to run the step or not. Are there suggestions on how to fix/ other ways to do this? Thanks!
Using “- >” removes the newline characters in your script, so your 5 lines if-fi block is passed to the shell on a single line. To force a newline when using “- >” you need to insert a blank line. Passing conditional statements and loops on a single line to the shell is fine too, but it requieres some extra semicolons etc.
“- |” on the other hand works as you would expect it.
I find “- >” handy when having to deal with very long, multi-line commands, so you don’t have to worry about the line continuation character “\”.