yaml - GitLab CI 的多行 YAML 字符串 (.gitlab-ci.yml)

标签 yaml gitlab-ci gitlab-ci-runner

我正在尝试编写一个 gitlab-ci.yml 文件,该文件使用多行字符串作为命令。然而,它似乎没有被解析。我尝试了 - |-> ,结果相同。

stages:
  - mystage

Build:
  stage: mystage
  script:
    - |
        echo -e "
            echo 'hi';
            echo 'bye';
        "

当它尝试运行时,它仅显示 echo -e ' 作为要运行的脚本,而不是整个多行字符串。这给我带来了问题。

编写这样的内容的正确语法是什么?

最佳答案

我来到这里先发制人地期望这会是一个问题,但以下用于提高可读性的“多行”命令对我有用:

Gitlab Runner: Shell Runner 版本 1.11.0 /Gitlab版本:8.17.2

myjob:
stage: deploy
script:
  # Single line command
  - az component update --add sql

  # Multi-line command
  - az sql server create -n ${variable} -g ${variable} -l ${variable}
    --administrator-login ${variable} --administrator-login-password ${variable}

关于yaml - GitLab CI 的多行 YAML 字符串 (.gitlab-ci.yml),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42560083/

相关文章:

iis - dotnet 使用 gitlab-ci 为傻瓜发布

spring - ConfigurationProperties 从 YML 加载列表

yaml - Gitlab CI : Clone repo only before first build in pipeline

python - Sonarqube 客户端无法解析 pytest 覆盖率结果

运行 helm 命令时出现 Gitlab 问题 - 错误 : unknown command "sh" for "helm"

docker - 如何从 ci-pipeline 执行位于 runner 中的脚本?

batch-file - Windows 上的 GitLab runner 和处理 & %ERRORLEVEL%

gitlab 运行器捕获错误 : no matching files

yaml.load 和 yaml.safe_load 的 Python 区别

yaml - RMarkdown的YAML中的作者和隶属关系