Gitlab CI - helm cli not working in source bash script

25 Views Asked by At

Im trying to build a pipelines that uses helm command in some bash scripts:

before_script:
  - source script.sh

my_stage:
  image: registry.gitlab.com/foo/bar:v1.2
  script:
    - helm version
    - helm_dependency_build_and_update

The script.sh look like:

#!/bin/bash

function helm_dependency_build_and_update {
  helm dependency build
  helm dependency update
}

and it looks sleek the helm is available from the gitlab ci pipeline, yet not in the source script, that's the effect:

Running with gitlab-runner 15.4.0 (43b2dc3d)
...
Using Kubernetes executor with image registry.gitlab.com/foo/bar:v1.2 ...
...
00:02
$ source script.sh
$ helm version
version.BuildInfo{Version:"v3.11.2", GitCommit:"912ebc1cd10d38d340f048efaf0abda047c3468e", GitTreeState:"clean", GoVersion:"go1.18.10"}
$ helm_dependency_build_and_update
script.sh: line 4: helm: command not found
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: command terminated with exit code 1

The custom image is build on python:3.7 base image, helm is added with:

RUN curl --retry 5 -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 && \
    chmod 700 get_helm.sh && \
    ./get_helm.sh -v $HELM_VERSION && \
    helm version --client

Why can I use helm from the level of gitlab yaml file, yet not in source bash script?

0

There are 0 best solutions below