From d75aa341f0abb981326161669fc72aa6ce7ddbc4 Mon Sep 17 00:00:00 2001 From: Misha Sugakov Date: Thu, 12 Dec 2024 13:28:05 +0100 Subject: [PATCH] Switch `determine-image-tag` to trusted task See https://github.com/stackrox/konflux-tasks/pull/3 --- .tekton/collector-component-pipeline.yaml | 10 ++++- .tekton/determine-image-tag-task.yaml | 55 ----------------------- 2 files changed, 9 insertions(+), 56 deletions(-) delete mode 100644 .tekton/determine-image-tag-task.yaml diff --git a/.tekton/collector-component-pipeline.yaml b/.tekton/collector-component-pipeline.yaml index 0002e4363f..6d15676e3f 100644 --- a/.tekton/collector-component-pipeline.yaml +++ b/.tekton/collector-component-pipeline.yaml @@ -187,7 +187,15 @@ spec: - name: SOURCE_ARTIFACT value: $(tasks.clone-repository.results.SOURCE_ARTIFACT) taskRef: - name: determine-image-tag + params: + - name: name + value: determine-image-tag + - name: bundle + # TODO(ROX-27350): switch to latest tag after tasks PR is pushed. + value: quay.io/rhacs-eng/konflux-tasks:pr-3@sha256:50d7e4bca7e81fbf09faa749dfad62167b2099884363efb4d9fd0d05a6bc843d + - name: kind + value: task + resolver: bundles - name: prefetch-dependencies params: diff --git a/.tekton/determine-image-tag-task.yaml b/.tekton/determine-image-tag-task.yaml deleted file mode 100644 index 29e5847888..0000000000 --- a/.tekton/determine-image-tag-task.yaml +++ /dev/null @@ -1,55 +0,0 @@ -apiVersion: tekton.dev/v1 -kind: Task -metadata: - name: determine-image-tag - namespace: rh-acs-tenant -# TODO(ROX-23812): Refactor to a task bundle -spec: - description: Determines the tag for the output image using the StackRox convention from 'make tag' output. - params: - - name: TAG_SUFFIX - description: Suffix to append to generated image tag. - type: string - - name: SOURCE_ARTIFACT - description: The Trusted Artifact URI pointing to the artifact with - the application source code. This should be the result of the git-clone task, - results from other tasks might fail as dirty. - type: string - results: - - name: IMAGE_TAG - description: Image Tag determined by custom logic. - volumes: - - name: workdir - emptyDir: { } - stepTemplate: - volumeMounts: - - mountPath: /var/workdir - name: workdir - steps: - - name: use-trusted-artifact - image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:52f1391e6f1c472fd10bb838f64fae2ed3320c636f536014978a5ddbdfc6b3af - args: - - use - - $(params.SOURCE_ARTIFACT)=/var/workdir/source - - name: determine-image-tag - image: registry.access.redhat.com/ubi8:latest - workingDir: /var/workdir/source - script: | - #!/usr/bin/env bash - set -euo pipefail - dnf -y upgrade --nobest - dnf -y install git make - - .konflux/scripts/fail-build-if-git-is-dirty.sh - - # First, try take git tag if it's a tagged commit. - tag="$(git tag --points-at)" - if [[ -z "$tag" ]]; then - # If not, use make target's output. - tag="$(make --quiet --no-print-directory tag)" - elif [[ "$(wc -l <<< "$tag")" -gt 1 ]]; then - >&2 echo -e "Error: the HEAD commit has multiple tags, don't know which one to choose:\n$tag" - exit 5 - fi - - echo -n "${tag}$(params.TAG_SUFFIX)" | tee "$(results.IMAGE_TAG.path)"