diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index ec86a3c5..b8ef426f 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 @@ -8,6 +8,9 @@ metadata: "Dockerfile.CI".pathChanged() && ( event == "push" || event == "pull_request" ) pipelinesascode.tekton.dev/max-keep-runs: "5" spec: + taskRunSpecs: + - pipelineTaskName: skopeo-copy-push + serviceAccountName: skopeo-copy-quay-creds params: - name: repo_url value: "{{ repo_url }}" @@ -39,6 +42,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 +51,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:latest" + IMAGE_NAME_TIMESTAMP="quay.io/openshift-pipeline/chainstest: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 +80,10 @@ 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 + - name: buildah-push taskRef: kind: ClusterTask name: buildah @@ -89,7 +99,12 @@ spec: workspace: source - name: dockerconfig workspace: dockerconfig - - name: skopeo-copy + when: + - input: "quay.io" + operator: in + values: + - "$(tasks.generate-image-name.results.repository)" + - name: skopeo-copy-push taskRef: kind: ClusterTask name: skopeo-copy @@ -102,9 +117,64 @@ spec: - name: destImageURL value: docker://$(tasks.generate-image-name.results.image-name-timestamp) runAfter: - - buildah + - buildah-push + when: + - input: "quay.io" + operator: in + values: + - "$(tasks.generate-image-name.results.repository)" + - name: buildah-pull-request + 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-pull-request + 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-pull-request 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: @@ -118,9 +188,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 @@ -135,4 +209,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 1Gi \ No newline at end of file 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 &&\