Gitlab-CI 多行脚本和多脚本的区别

Gitlab-CI difference between multiline script and multiple scripts

对 GitLab 相当陌生-CI,我正在尝试通过 Helm 在 Kubernetes 集群上进行部署。 我有这个:

image: docker:stable

deploy:
  stage: deploy
  image:
    name: alpine/helm:3.4.1
  script:
    - echo "Deploying to production"
    - helm list --all-namespaces

它失败了:

Error: unknown command "sh" for "helm"

并且 echo 没有回显,但是,如果我删除 echo 行,helm cmd 将成功执行。

我想我是在问如何制作多行脚本 运行? gitlab-运行ner如何执行script:数组中提供的一系列命令?

script 数组 运行 中的每个条目 sh shell。

sh -x 'echo "Deploying to production"'

您正在使用的 alpine/helm 图像包含 helm 的入口点 这意味着 sh 命令 gitlab 正在尝试 运行 作为参数附加到入口点(例如 helm sh -x 'echo "Deploying to production"'

Override the entrypoint

deploy:
  stage: deploy
  image:
    name: alpine/helm:3.4.1
  entrypoint: [""]
  script:
    - echo "Deploying to production"