user3313834 user3313834 -4 years ago 249
YAML Question

gitlab-ci.yml python -c 'multiple line cmd' failed

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
.

Answer Source

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())'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download