Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab-CI difference between multiline script and multiple scripts

Fairly new to GitLab-CI, I'm trying to deploy via Helm on a Kubernetes cluster. I have this:

image: docker:stable

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

And it fails with:

Error: unknown command "sh" for "helm"

And the echo is not echoed, however, If I were to remove the echo line, the helm cmd would execute successfully.

I guess I'm asking how to make multiline scripts run? How do the gitlab-runner executes the series of commands provided in the script: array?

like image 780
Moshe Avatar asked Feb 20 '26 19:02

Moshe


1 Answers

Each entry in the script array runs in an sh shell.

sh -x 'echo "Deploying to production"'

The alpine/helm image you are using contains an entrypoint of helm Which means the sh command gitlab is trying to run is being appended to the entrypoint as an argument (e.g. 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"
like image 166
Matt Avatar answered Feb 23 '26 11:02

Matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!