Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab issue while running helm command as - Error: unknown command "sh" for "helm"

I have a packge script which needs to run on alpina:helm image . I have used this before but for some reason this is always giving me error as - Error: unknown command "sh" for "helm"

package:
  <<: *artifacts
  stage: package
  image: alpine/helm
  variables:
    GIT_STRATEGY: none
  script:
    - echo $VERSION
    - helm package ./keycloak --app-version=$VERSION
  artifacts:
    paths: 
    - "*.tgz"

Can anybody tell me what is the issue here I am not very sure . Helm command should be running as per my assumption but not sure why isnt it .

like image 588
Joy Avatar asked Dec 29 '25 00:12

Joy


1 Answers

As explained in the docs, the runner in gitlab is started this way

  • the runner starts the docker container specified in image and uses the entrypoint of this container
  • the runner attaches itself to the container
  • the runner combines before_script, script and after_script into a single script
  • the runner sends the combined script to the container's shell

If you take a look at the entrypoint of the alpine/helm image, you see that the entrypoint is helm and when the container starts it runs helm. The gitlab runner expects no entrypoint or that the entrypoint is set to start a shell so you get the Error: unknown command "sh" for "helm" as there is no running shell.

With overriding the entrypoint we make sure the runner finds a shell in the container which can execute the script.

package:
  stage: package
  image: 
    name: alpine/helm
    entrypoint: [""] 
  variables:
    GIT_STRATEGY: none
  script:
    - echo $VERSION
    - helm package ./keycloak --app-version=$VERSION
  artifacts:
    paths: 
    - "*.tgz"

EDIT: By reading the docs again I changed the entrypoint to an empty entrypoint for docker 17.06 and later (entrypoint: [""]) as this is more concise.

like image 82
danielnelz Avatar answered Dec 30 '25 22:12

danielnelz



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!