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.

1

1 Answer 1

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())'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.