Hi all,
I’d like to process a file line by line using the code below.
The lines are read correctly. However, the reading does not stop when all lines are done. Instead, the while loop runs endlessly.
Do you have any ideas on that?
Thanks!
- while read line
- do
#- echo $line
- done < InsertData.sql
I would recommend moving the code portions into a dedicated file, e.g. called process-files.sh, make it executable, and call it from the CI/CD config. Within the YAML configuration and inline bash scripts, there is no guarantee for loop exit conditions AFAIK.
One way to hide them from the default repo view is to move them into the .gitlab directory where other specific things are stored, like description templates for MRs and issues, etc.
$ mkdir -p .gitlab/ci/scripts
$ vim .gitlab/ci/scripts/process-files.sh
#!/bin/bash
FILE=InsertData.sql
while read line
do
echo $line
done < $FILE
# do more, calculate the exit state, etc.
STATE=0
exit($STATE)