3

I have a kustomization.yaml file that uses a private repository as a resource:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - https://gitlab.com/my-user/k8s-base-cfg.git
patchesStrategicMerge:
  - app-patch.yaml

I want to automate this on a Jenkins Pipeline. I don't know how to pass Git credentials to the kustomize build command. Is there any option to do that?

Thank you

Fernando Lozano
  • 352
  • 2
  • 11

2 Answers2

3

You can't, you would set up the credentials in git before starting Kustomize. In this case probably something very simple like git config --global user.password "your password" but look up the credentials.helper setting for more complex options, either from a local file or a tool that reads from some backing store directly.

coderanger
  • 52,400
  • 4
  • 52
  • 75
1

@coderanger's answer is correct, but doesn't work for me. I use this:

git config --global credential.helper store
echo "https://$GITUSER:$PASSWORD@github.com" >> "${HOME}/.git-credentials"

If you're using GitHub, $GITUSER = git (it's ignored) and $PASSWORD = a personal access token.

Chris Jones
  • 4,815
  • 6
  • 34
  • 28