Multiline YAML string for GitLab CI (.gitlab-ci.yml)

samanime picture samanime · Mar 2, 2017 · Viewed 68.3k times · Source

I'm trying to write a gitlab-ci.yml file which uses a multi-line string for the command. However, it seems like it is not being parsed. I've tried both the - | and - > with identical results.

stages:
  - mystage

Build:
  stage: mystage
  script:
    - |
        echo -e "
            echo 'hi';
            echo 'bye';
        "

When it tries to run, it only shows echo -e ' as the script to run, and not the whole multiline string. This causes issues for me.

What would be the correct syntax to write something like this?

Answer

PotatoFarmer picture PotatoFarmer · Mar 9, 2017

I came here preemptively expecting this would be an issue but the following "multi-line" command for readability is working for me:

Gitlab Runner: Shell Runner version 1.11.0 / Gitlab version: 8.17.2

myjob:
stage: deploy
script:
  # Single line command
  - az component update --add sql

  # Multi-line command
  - az sql server create -n ${variable} -g ${variable} -l ${variable}
    --administrator-login ${variable} --administrator-login-password ${variable}