Can't find included file in GitLab

I have a .gitlab-ci.yml in my project which includes a template:

include:
  - project: foo/pipeline-templates
    ref: main
    file: deploy-foo.gitlab-ci.yml

deploy-foo.gitlab-ci.yml in the other project foo/pipeline-templates includes another template:

include:
  - local: stages.yml
  - template: Kaniko.gitlab-ci.yml

Now I want to inspect Kaniko.gitlab-ci.yml, and maybe change its content, but I can’t find it. The file is not in the project foo/pipeline-templates.
It seems to be a custom template specific our organization, and not one provided by GitLab. I can’t ask anyone, inside the organization.

I used the search feature to search “in all GitLab”, with no results. There are dozens of GitLab projects, it would be hard to check every single one manually.

Any ideas on how I can find this Kaniko.gitlab-ci.yml template file?

The docs here for templates Development guide for GitLab CI/CD templates | GitLab suggests lib/gitlab/ci/templates - check your project foo/pipeline-templates for that lib directory?

CI/CD templates originate from different paths

  1. GitLab provided template. These are located in the lib/gitlab/ci/templates directory of the GitLab installation. The path depends on the installation method.
  2. Instance template repository, which can be configured by admins. Instance template repository | GitLab

The latest online version for the Kaniko CI/CD template is at lib/gitlab/ci/templates/Kaniko.gitlab-ci.yml · master · GitLab.org / GitLab · GitLab

If you want to change the Kaniko template, there are multiple strategies:

  1. Override job specific attributes, i.e. the stage, variables or rules. The trick here is to use the same job name.
include:
  - template: Kaniko.gitlab-ci.yml

stages:
  - test
  - build
  - container-build 

kaniko-build:
  stage: container-build
  1. Or, copy the template content into a custom template, and modify and maintain it yourself.

To make better suggestions, which changes are you planning to make to the Kaniko jobs?

2 Likes

Thanks a lot.
The change I had in mind, was to provide a variable for a custom Dockerfile filename. As I see in the original template, it’s hardcoded to be “Dockerfile”, which we can only target with its parent folder (build context).

If I understand the Kaniko template correctly, the env variable DOCKERFILE_PATH can be modified and gets interpreted correctly (both in rules in line 55 and the script in line 49).

Could not resists trying it - the following snippet works for me on GitLab.com SaaS:

include:
  - template: Kaniko.gitlab-ci.yml

kaniko-build:
  variables:
    DOCKERFILE_PATH: 'build/Dockerfile'

Modify the build/ prefix to your current setup.

Example build, diff in Build with Kaniko from custom Dockerfile path (f648d34c) · Commits · Michael Friedrich / ci-cd-playground · GitLab

build/Dockerfile

FROM python:3.12

resulting in kaniko-build (#5354279232) · Jobs · Michael Friedrich / ci-cd-playground · GitLab - it uses the Python image as can be seen in the output.

Additional proof: Fetching the latest container image and running python -V. Note that this container command might not work in the future because I use this project for testing many different things. Ignore the two errors with -- - sometimes, Docker CLI requires passing commands this way. Seems Rancher Desktop does not.

docker run -ti registry.gitlab.com/dnsmichi/ci-cd-playground:latest python -V

1 Like