6

The following command in a job script:

STATUS_ID=$(grep -Eo "Status Code [0-9]+: Done" somefile | grep -Eo "[0-9]+")

Seems to be causing the following ci lint error:

script config should be a string or an array of strings

The command works fine on my bash however when trying to grep the status code via a file containing the line:

Status Code 8484: Done

What is causing the error on gitlab?

pkaramol
  • 16,451
  • 43
  • 149
  • 324

1 Answers1

5

The colon (:) makes the line be interpeted as yaml map.

The solution (to escape the special meaning of the colon) is to enclose the entire line in single quotes:

'STATUS_ID=$(grep -Eo "Status Code [0-9]+: Done" somefile | grep -Eo "[0-9]+")'
pkaramol
  • 16,451
  • 43
  • 149
  • 324
  • what about using single quotes for the `grep`? `STATUS_ID=$(grep -Eo 'Status Code [0-9]+: Done' somefile | grep -Eo "[0-9]+")` – fedorqui Nov 15 '17 at 10:52