6

In my .gitlab-ci.yml I need to have multiple line python -c 'stuff on multiple lines'

with this:

image: python:latest

before_script:
  - |
    python3 -c 'from datetime import datetime as dt;
    print(dt.now())'

I get this error::

$ python3 -c 'from datetime import datetime as dt;
/bin/bash: eval: line 69: syntax error near unexpected token `('
ERROR: Build failed: exit code 2

On this issue Multiline YAML string for GitLab CI (.gitlab-ci.yml) they talk about an echo 'multiples lines string to echo' and propose to keep it as a one liner or to pre-process the yml with ruamel.yaml.

Community
  • 1
  • 1
user3313834
  • 7,327
  • 12
  • 56
  • 99
  • 1
    Possible duplicate of [Multiline YAML string for GitLab CI (.gitlab-ci.yml)](http://stackoverflow.com/questions/42560083/multiline-yaml-string-for-gitlab-ci-gitlab-ci-yml) – Anthon Mar 19 '17 at 18:32

1 Answers1

5

I think this should do it. The pipe is not supported by docker-ci.

image: python:latest

before_script:
  - >
    python3 -c 'from datetime import datetime as dt;
    print(dt.now())'
vinny
  • 76
  • 4