Reputation: 517
I have this code snippet. It gives me syntax error: unexpected end of file If I copy it in a .sh file and run in terminal it works.
before_script:
- sbt sbtVersion
- for file in ./pending/*.sql; do
file=$(basename "$file")
export str_opt="$(cat ./pending/"$file"|tr '\n' ' ')"
mv ./pending/"$file" ./done/
done
where am I going wrong?
Upvotes: 5
Views: 9941
Reputation: 141010
do;
There is no ;
after do
. Remove it.
The way yaml in gitlab-ci works, it concatenates the lines into one long line, substituting the newline and line leading spaces for a single space:
for file in ./pending/*.sql; do; file=$(basename "$file"); export str_opt="$(cat ./pending/"$file"|tr '\n' ' ')"; mv ./pending/"$file" ./done/; done
which is invalid because of the ;
after do
.
Script like so:
before_script:
- sbt sbtVersion
- for file in ./pending/*.sql; do
file=$(basename "$file");
export str_opt="$(cat ./pending/"$file"|tr '\n' ' ')";
mv ./pending/"$file" ./done/;
done
should work.
Upvotes: 3