Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 482
user3313834 Avatar asked Mar 19 '17 17:03

user3313834


1 Answers

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())'
like image 148
vinny Avatar answered Oct 20 '22 14:10

vinny