{{- define "common.pipeline" }} {{- $common := dict "Values" .Values.common -}} {{- $noCommon := omit .Values "common" -}} {{- $overrides := dict "Values" $noCommon -}} {{- $noValues := omit . "Values" -}} {{- with merge $noValues $overrides $common -}} {{- $thisapp := include "common.name" . -}} apiVersion: tekton.dev/v1 kind: Pipeline metadata: labels: app: {{ include "common.name" . }} name: {{ include "common.name" . }} namespace: {{ .Release.Namespace }} spec: params: - description: Ref of the application name: ref type: string - description: git unique head commit id name: revision type: string - description: repository name name: repourl type: string - description: repository full name name: repofullname type: string - description: commit author username name: author type: string - description: commit author email name: email type: string - description: commit message name: message type: string - description: pull request index number name: index type: string - description: The URL of the repo containing the helm charts name: git-helm-url type: string - description: the base git server hostname name: githost type: string - description: the base quay server hostname name: quayhost type: string tasks: - name: set-pending-status params: - name: githost value: $(params.githost) - name: statusurl value: https://console-openshift-console.apps.ocp.endofday.com/pipelines/ns/goghvideo-cicd-pipeline/pipeline-runs - name: revision value: $(params.revision) - name: repofullname value: $(params.repofullname) - name: description value: CI Pipeline - name: state value: pending taskRef: kind: Task name: gitea-set-status workspaces: - name: gitauth workspace: gitauth - name: copy-shared-utilities runAfter: - set-pending-status taskRef: kind: Task name: copy-shared-utilities workspaces: - name: utilities - name: prepare params: - name: gitrepositoryurl value: $(params.repourl) - name: gitbranch value: $(params.ref) runAfter: - set-pending-status taskRef: kind: Task name: git-semver workspaces: - name: repo workspace: source - name: gitauth workspace: gitauth - name: standards params: - name: package value: $(params.githost)/goghvideo/{{ include "common.name" . }} - name: context value: ./{{ include "common.name" . }}/src - name: version value: latest runAfter: - prepare taskRef: kind: Task name: golangci-lint workspaces: - name: source workspace: source - name: build params: - name: TLSVERIFY value: "false" - name: BUILDER_IMAGE value: {{ .Values.quayHostname }}/goghvideo/golang-s2i-buildah:v1 - name: PATH_CONTEXT value: {{ include "common.name" . }}/src - name: verbose value: "true" - name: IMAGE value: {{ .Values.quayHostname }}/goghvideo/{{ include "common.name" . }}:$(params.revision) - name: ENV_VARS value: - semver=$(tasks.prepare.results.version) runAfter: - standards taskRef: kind: Task name: s2i-go workspaces: - name: source workspace: source - name: dockerconfig workspace: dockerconfig - name: ephemeral-namespace params: - name: VERSION value: "4.17" - name: SCRIPT value: | echo "${SHELL}" RANDOMID=$(openssl rand -hex 4) oc new-project goghvideo-test-${RANDOMID} >/dev/null oc label namespace goghvideo-test-${RANDOMID} app=goghvideo-test oc create -f - </dev/null) || $x -eq 10 ]]; do echo "Waiting for secret replication" && sleep 10 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi oc -n goghvideo-test-${RANDOMID} secrets link default goghvideo-openshift-builder-pull-secret --for=pull oc apply -f - </dev/null ) || $x -eq 10 ]]; do echo "Waiting for operator to deploy rabbit" && sleep 5 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi oc -n goghvideo-test-${RANDOMID} adm policy add-scc-to-user anyuid -z rabbitmq-server x=0; until [[ $(oc -n goghvideo-test-${RANDOMID} get sts rabbitmq-server -o jsonpath="{.status.readyReplicas}") -gt 0 || $x -eq 20 ]]; do echo "Waiting for Rabbit MQ to startup" && sleep 15 && ((x++)); done if [[ "${x}" -eq 20 ]]; then exit 1; fi oc -n goghvideo-test-${RANDOMID} create route edge --service=rabbitmq --port=15672 oc -n goghvideo-test-${RANDOMID} get pods RABBITHOST=$(oc -n goghvideo-test-${RANDOMID} get secret/rabbitmq-default-user -o template='{{ "{{" }} .data.host | base64decode {{ "}}" }}') RABBITUSER=$(oc -n goghvideo-test-${RANDOMID} get secret/rabbitmq-default-user -o template='{{ "{{" }} .data.username | base64decode {{ "}}" }}') RABBITPASS=$(oc -n goghvideo-test-${RANDOMID} get secret/rabbitmq-default-user -o template='{{ "{{" }} .data.password | base64decode {{ "}}" }}') oc -n goghvideo-test-${RANDOMID} create secret generic amqp --from-literal=url=amqp://${RABBITUSER}:${RABBITPASS}@${RABBITHOST}/ curl --retry 12 --retry-connrefused --retry-delay 10 -O http://${RABBITHOST}:15672/cli/rabbitmqadmin chmod +x rabbitmqadmin x=0; until [[ -n $( ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare exchange name=conversion type=topic 2>/dev/null ) || $x -eq 10 ]]; do echo "waiting for exchange to be created" && sleep 5 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi x=0; until [[ -n $( ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare queue name=transcode durable=true queue_type=quorum ) || $x -eq 10 ]]; do echo "waiting for exchange to be created" && sleep 5 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi x=0; until [[ -n $( ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare queue name=notification durable=true queue_type=quorum ) || $x -eq 10 ]]; do echo "waiting for exchange to be created" && sleep 5 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi x=0; until [[ -n $( ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare queue name=upload-nextcloud durable=true queue_type=quorum ) || $x -eq 10 ]]; do echo "waiting for exchange to be created" && sleep 5 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi x=0; until [[ -n $( ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare queue name=complete durable=true queue_type=quorum ) || $x -eq 10 ]]; do echo "waiting for exchange to be created" && sleep 5 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi x=0; until [[ -n $( ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare binding source="conversion" destination_type="queue" destination="transcode" routing_key="transcode" ) || $x -eq 10 ]]; do echo "waiting for exchange to be created" && sleep 5 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi x=0; until [[ -n $( ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare binding source="conversion" destination_type="queue" destination="notification" routing_key="notification" ) || $x -eq 10 ]]; do echo "waiting for exchange to be created" && sleep 5 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi x=0; until [[ -n $( ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare binding source="conversion" destination_type="queue" destination="upload-nextcloud" routing_key="upload-nextcloud" ) || $x -eq 10 ]]; do echo "waiting for exchange to be created" && sleep 5 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi x=0; until [[ -n $( ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare binding source="conversion" destination_type="queue" destination="complete" routing_key="complete" ) || $x -eq 10 ]]; do echo "waiting for exchange to be created" && sleep 5 && ((x++)); done if [[ "${x}" -eq 10 ]]; then exit 1; fi echo -n "goghvideo-test-${RANDOMID}" > $(results.namespace.path) runAfter: - build taskRef: kind: Task name: openshift-client workspaces: - name: kubeconfig-dir workspace: dockerconfig - name: prepare-helm-charts params: - name: url value: $(params.git-helm-url) runAfter: - ephemeral-namespace taskRef: kind: Task name: git-clone workspaces: - name: output workspace: helm - name: basic-auth workspace: gitauth - name: deploy-notification-app params: - name: charts_dir value: notification - name: release_namespace value: $(tasks.ephemeral-namespace.results.namespace) - name: release_name value: notification {{- if eq $thisapp "notification" }} - name: overwrite_values value: image.tag=$(params.revision) {{- end }} runAfter: - prepare-helm-charts taskRef: kind: Task name: helm-upgrade-from-source workspaces: - name: source workspace: helm - name: deploy-upload-to-nextcloud-app params: - name: charts_dir value: upload-to-nextcloud - name: release_namespace value: $(tasks.ephemeral-namespace.results.namespace) - name: release_name value: upload-to-nextcloud {{- if eq $thisapp "upload-to-nextcloud" }} - name: overwrite_values value: image.tag=$(params.revision) {{- end }} runAfter: - prepare-helm-charts taskRef: kind: Task name: helm-upgrade-from-source workspaces: - name: source workspace: helm - name: deploy-conversion-engine-job params: - name: charts_dir value: conversion-engine - name: release_namespace value: $(tasks.ephemeral-namespace.results.namespace) - name: release_name value: conversion-engine {{- if eq $thisapp "conversion-engine" }} - name: overwrite_values value: image.tag=$(params.revision) {{- end }} runAfter: - prepare-helm-charts taskRef: kind: Task name: helm-upgrade-from-source workspaces: - name: source workspace: helm - name: get-filedrop-name params: - name: VERSION value: "4.11" - name: SCRIPT value: | #!/usr/bin/env bash wget "https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-amd64" -O /usr/local/bin/jq chmod +x /usr/local/bin/jq INPUTSRC=$(oc -n $(tasks.ephemeral-namespace.results.namespace) get scaledjob/conversion-engine -o json | /usr/local/bin/jq -r '.spec.jobTargetRef.template.spec.initContainers[0].env[] | select(.name == "sourcefile").value') if [[ -z "${INPUTSRC}" ]]; then exit 1; fi echo -n "${INPUTSRC}" > $(results.filedrop.path) runAfter: - deploy-conversion-engine-job - deploy-upload-to-nextcloud-app - deploy-notification-app taskRef: kind: Task name: openshift-client workspaces: - name: kubeconfig-dir workspace: dockerconfig - name: perform-e2e-test params: - name: VERSION value: "4.11" - name: SCRIPT value: | #!/usr/bin/env bash oc create -f - <