Search code examples
gitlab-cikubectl

Gitlab CI reference file from another project in a kubectl command


I have a gitlab CI pipeline that is running this command:

kubectl apply -f my-kube.yaml

I would like to move my-kube.yaml to a common place instead of having it in every project. I already include a common pipeline using

include:
  - project: 'somepath/somepath/someProject'
    file: 'someFile.yml'

Can i do this for a file like my-kube.yaml too?


Solution

  • What I ended up doing to resolve the issue was this:

    - 'wget --header="PRIVATE-TOKEN: $MY_TOKEN" -O my-kube.yaml https://my.gitlab.com/api/v4/projects/001/repository/files/my-kube-001.yaml/raw?ref=master'
    - kubectl apply -f my-kube.yaml
    

    Note you could also use curl instead of wget