Folded multiline with `&&` throws " line 180: syntax error near unexpected token `&&'"

can some1 explain to me why this is OK and works

    - >
      [ -n "$MDM_BUILD_TAG" ] && git push origin -d $MDM_BUILD_TAG

and this doesnt:

    - >
      [ -n "$MDM_BUILD_TAG" ] 
        && git push origin -d $MDM_BUILD_TAG

the trace log shows this

++ echo '$ [ -n "$MDM_BUILD_TAG" ] # collapsed multi-line command'
++ '[' -n deploys/dev_d408196-1.0.13-20201009_124907 ']'
/bin/bash: eval: line 180: syntax error near unexpected token `&&'

as far as i understand yaml and the CI spec the failing form should be converted by the yaml parser into the working form, or not ? hence, shoudnt the runner should always see the whole thing as 1 line ?

As you posted it, the indentation seems to be different for the first and second line of the command. Yaml can be quite sensitive about that. It is at least worth a shot.
Still strange that it does report a multiline command in that case. In “normal” bash I’d probably start to fiddle with backslashes, but the documentation does not seem to indicate you need that.

seems u are right. in that info page it doest say that but for gitlab block scalars (ie with - |, or - >) indentation must be the same for all (tested and works now) where as for the flow scalars this isnt required (judging from the examples on the info page but havent tested that).

Ok, if that was the solution, please mark my comment as such, for future reference :slight_smile: