简体   繁体   English

gitlab-ci.yml python -c'多行cmd'失败

[英]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' 在我的.gitlab-ci.yml我需要在多行上有多行python -c'的东西'

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 . 在这个问题上,GitLab CI的多行YAML字符串(.gitlab-ci.yml)他们讨论了一个echo 'multiples lines string to echo'并建议将其保持为单行或使用ruamel.yaml预处理yml。

I think this should do it. 我认为应该这样做。 The pipe is not supported by docker-ci. docker-ci不支持管道。

image: python:latest

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Gitlab中配置.gitlab-ci.yml文件以测试python代码 - Configuring .gitlab-ci.yml file in Gitlab to test python Codes Gitlab Flask Page: Problems with installing python GDAL package for Frozen Flask Application with.gitlab-ci.yml file - Gitlab Flask Page: Problems with installing python GDAL package for Frozen Flask Application with .gitlab-ci.yml file 在.gitlab-ci.yml中使用apt-get install python包 - use apt-get install python packages in .gitlab-ci.yml 每个python脚本是否可以在.gitlab-ci.yml文件中填充变量? - Is it possible to fill a variable in the .gitlab-ci.yml file per python script? 使用 gitlab-ci.yml 管道测试 python 程序时出现问题 - Problem using MPI in a python program when testing it with a gitlab-ci.yml pipeline 如何在 gitlab-ci.yml 中将 postgis 扩展添加到 postgresql 数据库 - How to add postgis extension to postgresql database in gitlab-ci.yml gitlab-ci.yml:“脚本:-pytest”命令无法识别 - gitlab-ci.yml: 'script: -pytest' command is not recognized 我的 first.gitlab-ci.yml 文件:如何在 CI/CD 中运行现有文件 - My first .gitlab-ci.yml file: How to run existing files in CI/CD 如何在 Gitlab 中为简单的 hello world 程序配置 gitlab-ci.yml - How do I configure gitlab-ci.yml for a simple hello world program in Gitlab 如何从 .gitlab-ci.yml 文件中提取单个管道名称? - How to extract individual Pipeline names from .gitlab-ci.yml file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM