Log in
← Docs

Connect GitLab CI

Point a kaniko build on GitLab CI at this backend.

Three steps. Nothing is stored in your repository: the job mints a short-lived token per build.

1. Sign in

Sign in with GitLab. A group, or your personal namespace, shows up after its first build sends telemetry. Everyone with Reporter or higher in it sees the same builds.

A build belongs to the project's immediate parent. A project in a subgroup lands in the subgroup's tenant, not the parent group's.

2. Add the build job

Put this in .gitlab/kaniko.yml, include: it, and extends: .kaniko-build from any job that builds an image. Already have a kaniko job? The + lines are all it needs.

# The account these builds belong to comes from the token below, not from
# anything set here.
.kaniko-build:
  image:
    name: ghcr.io/osscontainertools/kaniko:v1.28.5-debug
    entrypoint: [""]
  id_tokens:
    KANIKO_TELEMETRY_ID_TOKEN:
      aud: kaniko-telemetry
  variables:
    KANIKO_TELEMETRY_ENDPOINT: "https://ingest.firnlayers.com/oidc/v1/traces"
    KANIKO_TELEMETRY_TOKEN_EXCHANGE_ENDPOINT: "https://ingest.firnlayers.com/ingest/token"
    DOCKERFILE: Dockerfile
    CONTEXT_PATH: .
    IMAGE_URL: $CI_REGISTRY_IMAGE
    IMAGE_NAME: ""
    IMAGE_TAG: latest
    BASE_ARGS: >-
      --dockerfile $DOCKERFILE
      --context $CONTEXT_PATH
      --destination=${IMAGE_URL}/${IMAGE_NAME}:${IMAGE_TAG}${EXT}
    BUILD_ARGS: ""
    CACHE: "true"
    CACHE_REPO: "${CI_REGISTRY_IMAGE}/cache"
    CACHE_ARGS: >-
      --cache=$CACHE
      --cache-copy-layers
      --cache-repo $CACHE_REPO
    EXTRA_ARGS: ""
  script:
    - set -x
    - /kaniko/executor
      $BASE_ARGS
      $BUILD_ARGS
      $CACHE_ARGS
      $EXTRA_ARGS
    - echo IMAGE_ID=${IMAGE_URL}/${IMAGE_NAME}:${IMAGE_TAG}${EXT} > image.env
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      variables:
        EXT: ""
    - if: $CI_MERGE_REQUEST_ID
      variables:
        EXT: -MR${CI_MERGE_REQUEST_IID}
    - variables:
        EXT: -${CI_COMMIT_REF_SLUG}
  artifacts:
    reports:
      dotenv: image.env

3. Run a pipeline

The build appears under Builds a few seconds after the job finishes.

A refused exchange logs ingest token exchange refused and the build carries on without telemetry.

What the snippet does

GitLab hands the job an identity token, kaniko trades it for an ingest token and sends that with its spans. The token lasts minutes and never leaves the job that asked for it.

Which account the build belongs to comes from that identity, not from anything the pipeline sets.

If nothing arrives

Check the job log for exchange refused, and check the picker above matches the kaniko you run. The endpoint differs between versions and the wrong one fails silently.