Using custom tags

Konflux build pipelines allow you to apply multiple custom tags to your container images. This tagging is handled by separate apply-tags task. The custom tags can be configured in three ways:

These can be combined and used together.

Additional Considerations
  • Tag Uniqueness: Ensure your tagging strategy generates unique and meaningful tags. Using timestamps or commit SHAs as part of the tag helps with uniqueness.

  • latest Tag: Be cautious when applying the latest tag. It’s typically reserved for the most recent stable build from the main development branch. You might want to add a condition in your apply-tags task or PipelineRun to only apply latest for main branch pushes. This will help to reduce the occurrence of race conditions which would apply the tag to a non-latest build.

Using konflux.additional-tags image label in your Containerfile

You can specify the additional custom tags directly in your Containerfile by using the konflux.additional-tags label, e.g.:

LABEL konflux.additional-tags="tag1"

If you want to specify multiple tags, they have to be separated by space or a comma, e.g.:

LABEL konflux.additional-tags="tag1 tag2"
LABEL konflux.additional-tags="tag1, tag2"

Using ADDITIONAL_TAGS parameter for apply-tags task

You can also specify additional custom tags by using ADDITIONAL_TAGS array parameter for apply-tags task in your PipelineRun definition, e.g:

...
- name: apply-tags
  params:
  - name: IMAGE
    value: $(tasks.build-container.results.IMAGE_URL)
  - name: ADDITIONAL_TAGS
    value: ["tag1", "tag2"]
  runAfter:
  - build-container
  taskRef:
    params:
    - name: name
      value: apply-tags
    - name: bundle
      value: quay.io/konflux-ci/tekton-catalog/task-apply-tags:0.1
    - name: kind
      value: task
    resolver: bundles
...

The array parameter ADDITIONAL_TAGS can also be specified differently:

...
  - name: ADDITIONAL_TAGS
    value:
      - tag1
      - tag2
...

Using dynamic metadata in new tags

By using the apply-tags task with dynamically constructed tag names, you can achieve a flexible and informative tagging strategy for your container images built with Konflux. Dynamic tags can be created from metadata generated both from other tasks and Pipelines as Code. For example,

...
  - name: ADDITIONAL_TAGS
    value: ["pull-request-{{pull_request_number}}", "from-branch-{{source_branch}}", "{{target_branch}}-$(tasks.clone-repository.results.commit-timestamp)"]
...

To see all available dynamic variables, please see the dynamic variables section in the Pipeline as Code documentation