From 0642dba48e771edcb131740613805e99c77f706b Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Fri, 8 Mar 2024 08:37:43 +0100 Subject: [PATCH 01/14] add parallel task --- .tekton/create-ci-image-pipelinerun.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index ec86a3c5..5c3da285 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -89,6 +89,20 @@ spec: workspace: source - name: dockerconfig workspace: dockerconfig + - name: buildah2 + taskref: + kind: ClusterTask + name: buildah + params: + - name: IMAGE + value: $(tasks.generate-image-name.results.image-name) + - name: DOCKERFILE + value: ./Dockerfile.CI + runAfter: + - generate-image-name + workspaces: + - name: source + workspace: source - name: skopeo-copy taskRef: kind: ClusterTask From 70a19d3c86467eddbd4b1ca5c6a6ab01f46a5092 Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Fri, 8 Mar 2024 10:11:34 +0100 Subject: [PATCH 02/14] when expressions --- .tekton/create-ci-image-pipelinerun.yaml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 5c3da285..69572b7a 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -1,5 +1,5 @@ --- -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: PipelineRun metadata: name: create-push-ci-image @@ -39,6 +39,7 @@ spec: results: - name: image-name - name: image-name-timestamp + - name: repository steps: - name: generate-image-name image: quay.io/openshift-pipeline/ci @@ -47,21 +48,26 @@ spec: BRANCH_NAME={{ target_branch }} IMAGE_NAME="" IMAGE_NAME_TIMESTAMP="" + REPOSITORY="" TIMESTAMP=$(date +"%y%m%d%H%M") if [ "$BRANCH_NAME" == "master" ]; then if [ {{ event_type }} == "pull_request" ]; then IMAGE_NAME="image-registry.openshift-image-registry.svc:5000/pipelines-ci/ci:latest" IMAGE_NAME_TIMESTAMP="image-registry.openshift-image-registry.svc:5000/pipelines-ci/ci:5.0-$TIMESTAMP" + REPOSITORY="image-registry" else - IMAGE_NAME="quay.io/openshift-pipeline/ci:latest" - IMAGE_NAME_TIMESTAMP="quay.io/openshift-pipeline/ci:5.0-$TIMESTAMP" + IMAGE_NAME="quay.io/openshift-pipeline/chainstest/test:latest" + IMAGE_NAME_TIMESTAMP="quay.io/openshift-pipeline/chainstest/test:5.0-$TIMESTAMP" + REPOSITORY="quay.io" fi elif [[ "$BRANCH_NAME" == release-* ]]; then if [ {{ event_type }} == "pull_request" ]; then IMAGE_NAME="image-registry.openshift-image-registry.svc:5000/pipelines-ci/ci:${BRANCH_NAME#release-}" + REPOSITORY="image-registry" else IMAGE_NAME="quay.io/openshift-pipeline/ci:${BRANCH_NAME#release-}" + REPOSITORY="quay.io" fi IMAGE_NAME_TIMESTAMP="$IMAGE_NAME-$TIMESTAMP" else @@ -71,9 +77,11 @@ spec: echo -n "$IMAGE_NAME" | tee $(results.image-name.path) echo -n "$IMAGE_NAME_TIMESTAMP" | tee $(results.image-name-timestamp.path) + echo -n "$REPOSITORY" | tee $(results.repository.path) runAfter: - fetch-repository - name: buildah + onError: continue taskRef: kind: ClusterTask name: buildah @@ -89,8 +97,11 @@ spec: workspace: source - name: dockerconfig workspace: dockerconfig + when: + expression: $(tasks.generate-image-name.results.repository == 'quay.io') - name: buildah2 - taskref: + onError: continue + taskRef: kind: ClusterTask name: buildah params: @@ -103,6 +114,8 @@ spec: workspaces: - name: source workspace: source + when: + expression: $(tasks.generate-image-name.results.repository == 'image-registry') - name: skopeo-copy taskRef: kind: ClusterTask @@ -117,6 +130,7 @@ spec: value: docker://$(tasks.generate-image-name.results.image-name-timestamp) runAfter: - buildah + - buildah2 finally: - name: send-slack-notification taskRef: @@ -149,4 +163,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 1Gi \ No newline at end of file From 31cbf320572709692372d7cf88c6317b2454f691 Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Fri, 8 Mar 2024 10:17:17 +0100 Subject: [PATCH 03/14] refactoring --- .tekton/create-ci-image-pipelinerun.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 69572b7a..679e0594 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -98,7 +98,10 @@ spec: - name: dockerconfig workspace: dockerconfig when: - expression: $(tasks.generate-image-name.results.repository == 'quay.io') + - input: "quay.io" + operator: in + values: + - "$(tasks.generate-image-name.results.repository)" - name: buildah2 onError: continue taskRef: @@ -115,7 +118,10 @@ spec: - name: source workspace: source when: - expression: $(tasks.generate-image-name.results.repository == 'image-registry') + - input: "image-registry" + operator: in + values: + - "$(tasks.generate-image-name.results.repository)" - name: skopeo-copy taskRef: kind: ClusterTask From 338c2f213f2b5f2412dbc73ead2898e9113a1bd9 Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Fri, 8 Mar 2024 11:01:18 +0100 Subject: [PATCH 04/14] refactoring --- .tekton/create-ci-image-pipelinerun.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 679e0594..67bac3ba 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -81,7 +81,6 @@ spec: runAfter: - fetch-repository - name: buildah - onError: continue taskRef: kind: ClusterTask name: buildah @@ -103,7 +102,6 @@ spec: values: - "$(tasks.generate-image-name.results.repository)" - name: buildah2 - onError: continue taskRef: kind: ClusterTask name: buildah From b81f9a37ffff0630a41295dd485dae90317e2f6c Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Fri, 8 Mar 2024 12:44:26 +0100 Subject: [PATCH 05/14] correct image name --- .tekton/create-ci-image-pipelinerun.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 67bac3ba..84319719 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -57,8 +57,8 @@ spec: IMAGE_NAME_TIMESTAMP="image-registry.openshift-image-registry.svc:5000/pipelines-ci/ci:5.0-$TIMESTAMP" REPOSITORY="image-registry" else - IMAGE_NAME="quay.io/openshift-pipeline/chainstest/test:latest" - IMAGE_NAME_TIMESTAMP="quay.io/openshift-pipeline/chainstest/test:5.0-$TIMESTAMP" + IMAGE_NAME="quay.io/openshift-pipeline/chainstest:latest" + IMAGE_NAME_TIMESTAMP="quay.io/openshift-pipeline/chainstest:5.0-$TIMESTAMP" REPOSITORY="quay.io" fi elif [[ "$BRANCH_NAME" == release-* ]]; then From e8e1d5b55fdc6aed492f757a187c6cd08672fb74 Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Fri, 8 Mar 2024 13:08:47 +0100 Subject: [PATCH 06/14] rename tasks --- .tekton/create-ci-image-pipelinerun.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 84319719..febcb807 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -80,7 +80,7 @@ spec: echo -n "$REPOSITORY" | tee $(results.repository.path) runAfter: - fetch-repository - - name: buildah + - name: buildah-push taskRef: kind: ClusterTask name: buildah @@ -101,7 +101,7 @@ spec: operator: in values: - "$(tasks.generate-image-name.results.repository)" - - name: buildah2 + - name: buildah-pull-request taskRef: kind: ClusterTask name: buildah @@ -133,8 +133,8 @@ spec: - name: destImageURL value: docker://$(tasks.generate-image-name.results.image-name-timestamp) runAfter: - - buildah - - buildah2 + - buildah-push + - buildah-pull-request finally: - name: send-slack-notification taskRef: From 39fda8675e4bc2525b40f00eef497d2811ac8394 Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Tue, 12 Mar 2024 09:26:35 +0100 Subject: [PATCH 07/14] add service account --- .tekton/create-ci-image-pipelinerun.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index febcb807..47f8c3a3 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -8,6 +8,7 @@ metadata: "Dockerfile.CI".pathChanged() && ( event == "push" || event == "pull_request" ) pipelinesascode.tekton.dev/max-keep-runs: "5" spec: + serviceAccountName: skopeo-copy-quay-creds params: - name: repo_url value: "{{ repo_url }}" From 7148d4cef93d70494891ff0e7c6f854fb6729f7a Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Tue, 12 Mar 2024 11:22:28 +0100 Subject: [PATCH 08/14] change spec --- .tekton/create-ci-image-pipelinerun.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 47f8c3a3..45010b1e 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -8,7 +8,9 @@ metadata: "Dockerfile.CI".pathChanged() && ( event == "push" || event == "pull_request" ) pipelinesascode.tekton.dev/max-keep-runs: "5" spec: - serviceAccountName: skopeo-copy-quay-creds + taskRunSpecs: + - pipelineTaskName: skopeo-copy + serviceAccountName: skopeo-copy-quay-creds params: - name: repo_url value: "{{ repo_url }}" From 5efe022441870c2947f5db1b18c619790c7480c3 Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Tue, 12 Mar 2024 12:23:42 +0100 Subject: [PATCH 09/14] add skopeo-copy task --- .tekton/create-ci-image-pipelinerun.yaml | 29 +++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 45010b1e..5ba085cb 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -9,7 +9,7 @@ metadata: pipelinesascode.tekton.dev/max-keep-runs: "5" spec: taskRunSpecs: - - pipelineTaskName: skopeo-copy + - pipelineTaskName: skopeo-copy-push serviceAccountName: skopeo-copy-quay-creds params: - name: repo_url @@ -123,7 +123,7 @@ spec: operator: in values: - "$(tasks.generate-image-name.results.repository)" - - name: skopeo-copy + - name: skopeo-copy-pull-request taskRef: kind: ClusterTask name: skopeo-copy @@ -136,8 +136,31 @@ spec: - name: destImageURL value: docker://$(tasks.generate-image-name.results.image-name-timestamp) runAfter: - - buildah-push - buildah-pull-request + when: + - input: "image-registry" + operator: in + values: + - "$(tasks.generate-image-name.results.repository)" + - name: skopeo-copy-push + taskRef: + kind: ClusterTask + name: skopeo-copy + workspaces: + - name: images-url + workspace: images-url + params: + - name: srcImageURL + value: docker://$(tasks.generate-image-name.results.image-name) + - name: destImageURL + value: docker://$(tasks.generate-image-name.results.image-name-timestamp) + runAfter: + - buildah-push + when: + - input: "quay" + operator: in + values: + - "$(tasks.generate-image-name.results.repository)" finally: - name: send-slack-notification taskRef: From 547e7f269ec5e81a3fc5bc04ed0044130e68d4d4 Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Tue, 12 Mar 2024 12:25:13 +0100 Subject: [PATCH 10/14] refactoring --- .tekton/create-ci-image-pipelinerun.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 5ba085cb..8c1ce9e5 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -157,7 +157,7 @@ spec: runAfter: - buildah-push when: - - input: "quay" + - input: "quay.io" operator: in values: - "$(tasks.generate-image-name.results.repository)" From 901cf45a19ef5b2b54a1aeb68dee5fd2872a5b61 Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Tue, 12 Mar 2024 12:25:45 +0100 Subject: [PATCH 11/14] delete when expression --- .tekton/create-ci-image-pipelinerun.yaml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 8c1ce9e5..534ee115 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -137,11 +137,6 @@ spec: value: docker://$(tasks.generate-image-name.results.image-name-timestamp) runAfter: - buildah-pull-request - when: - - input: "image-registry" - operator: in - values: - - "$(tasks.generate-image-name.results.repository)" - name: skopeo-copy-push taskRef: kind: ClusterTask @@ -156,11 +151,6 @@ spec: value: docker://$(tasks.generate-image-name.results.image-name-timestamp) runAfter: - buildah-push - when: - - input: "quay.io" - operator: in - values: - - "$(tasks.generate-image-name.results.repository)" finally: - name: send-slack-notification taskRef: From 5082d1fa4ed099cd5ed554ace49a253b73a44a26 Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Tue, 12 Mar 2024 12:29:49 +0100 Subject: [PATCH 12/14] add finally task --- .tekton/create-ci-image-pipelinerun.yaml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 534ee115..84904083 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -152,7 +152,24 @@ spec: runAfter: - buildah-push finally: - - name: send-slack-notification + - name: send-slack-notification-request + taskRef: + resolver: cluster + params: + - name: kind + value: task + - name: name + value: send-slack-notification + - name: namespace + value: pipelines-ci + params: + - name: MESSAGE + value: " Uploading IS image ** <|logs>" + when: + - input: $(tasks.skopeo-copy-pull-request.status) + operator: in + values: ["Failed", "None"] + - name: send-slack-notification-push taskRef: resolver: cluster params: @@ -166,7 +183,7 @@ spec: - name: MESSAGE value: " Uploading CI image ** <|logs>" when: - - input: $(tasks.skopeo-copy.status) + - input: $(tasks.skopeo-copy-push.status) operator: in values: ["Failed", "None"] From b7cd4a07a439472f3a879521b5e25f3a93098518 Mon Sep 17 00:00:00 2001 From: Anton Misskii Date: Tue, 12 Mar 2024 12:42:05 +0100 Subject: [PATCH 13/14] add when expressions --- .tekton/create-ci-image-pipelinerun.yaml | 32 +++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 8c1ce9e5..256458b2 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -157,12 +157,34 @@ spec: runAfter: - buildah-push when: - - input: "quay.io" + - input: "image-registry" operator: in values: - "$(tasks.generate-image-name.results.repository)" finally: - - name: send-slack-notification + - name: send-slack-notification-request + taskRef: + resolver: cluster + params: + - name: kind + value: task + - name: name + value: send-slack-notification + - name: namespace + value: pipelines-ci + params: + - name: MESSAGE + value: " Uploading IS image ** <|logs>" + when: + - input: $(tasks.skopeo-copy-pull-request.status) + operator: in + values: ["Failed", "None"] + - input: "image-registry" + operator: in + values: + - "$(tasks.generate-image-name.results.repository)" + + - name: send-slack-notification-push taskRef: resolver: cluster params: @@ -176,9 +198,13 @@ spec: - name: MESSAGE value: " Uploading CI image ** <|logs>" when: - - input: $(tasks.skopeo-copy.status) + - input: $(tasks.skopeo-copy-push.status) operator: in values: ["Failed", "None"] + - input: "quay.io" + operator: in + values: + - "$(tasks.generate-image-name.results.repository)" workspaces: - name: dockerconfig From d8203bc2d50a659b100c922f0f72956a451fb701 Mon Sep 17 00:00:00 2001 From: amisskii <124462506+amisskii@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:45:40 +0100 Subject: [PATCH 14/14] Update Dockerfile.CI --- Dockerfile.CI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.CI b/Dockerfile.CI index 97567c0d..99e9ee71 100644 --- a/Dockerfile.CI +++ b/Dockerfile.CI @@ -9,7 +9,7 @@ RUN pip install pyyaml reportportal-client RUN wget https://github.com/mikefarah/yq/releases/download/v4.40.5/yq_linux_amd64 -O /usr/bin/yq &&\ chmod +x /usr/bin/yq -ENV OC_VERSION=4.14 +ENV OC_VERSION=4.13 RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/fast-${OC_VERSION}/openshift-client-linux.tar.gz \ -O /tmp/openshift-client.tar.gz &&\ tar xzf /tmp/openshift-client.tar.gz -C /usr/bin oc &&\