Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile.CI #145

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 90 additions & 9 deletions .tekton/create-ci-image-pipelinerun.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: tekton.dev/v1beta1
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
name: create-push-ci-image
Expand All @@ -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 }}"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -89,7 +99,31 @@ spec:
workspace: source
- name: dockerconfig
workspace: dockerconfig
- name: skopeo-copy
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
when:
- input: "image-registry"
operator: in
values:
- "$(tasks.generate-image-name.results.repository)"
- name: skopeo-copy-pull-request
taskRef:
kind: ClusterTask
name: skopeo-copy
Expand All @@ -102,9 +136,52 @@ spec:
- name: destImageURL
value: docker://$(tasks.generate-image-name.results.image-name-timestamp)
runAfter:
- buildah
- buildah-pull-request
- 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: "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: "<icon> Uploading IS image *<run_status>* <icon> <<logs_url>|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:
Expand All @@ -118,9 +195,13 @@ spec:
- name: MESSAGE
value: "<icon> Uploading CI image *<run_status>* <icon> <<logs_url>|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
Expand All @@ -135,4 +216,4 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storage: 1Gi
2 changes: 1 addition & 1 deletion Dockerfile.CI
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&\
Expand Down