apiVersion: tekton.dev/v1beta1 kind: Pipeline metadata: name: notification namespace: goghvideo-cicd-pipeline labels: app: notification spec: workspaces: - name: source - name: gitauth - name: dockerconfig - name: helm - name: gitsshauth - name: quayauth - name: utilities params: - name: ref description: Ref of the application - name: revision description: git unique head commit id - name: repourl description: repository name - name: repofullname description: repository full name - name: author description: commit author username - name: email description: commit author email - name: message description: commit message - name: index description: pull request index number - name: git-helm-url description: The URL of the repo containing the helm charts - name: githost description: the base git server hostname - name: quayhost description: the base quay server hostname tasks: - name: set-pending-status taskRef: name: gitea-set-status params: - name: githost value: $(params.githost) - name: quayhost value: $(params.quayhost) - 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" workspaces: - name: gitauth workspace: gitauth - name: copy-shared-utilities runAfter: ["set-pending-status"] taskRef: name: copy-shared-utilities workspaces: - name: utilities - name: prepare runAfter: ["set-pending-status"] taskRef: name: git-semver params: - name: gitrepositoryurl value: $(params.repourl) - name: gitbranch value: $(params.ref) workspaces: - name: repo workspace: source - name: gitauth workspace: gitauth - name: standards runAfter: - prepare taskRef: name: golangci-lint params: - name: package value: $(params.githost)/goghvideo/notification - name: context value: ./notification/src - name: version value: latest workspaces: - name: source workspace: source - name: build runAfter: - standards taskRef: name: s2i-go-debug params: - name: TLSVERIFY value: false - name: BUILDER_IMAGE value: $(params.quayhost)/goghvideo/golang-s2i-buildah:v1 - name: PATH_CONTEXT value: notification/src - name: verbose value: true - name: IMAGE value: $(params.quayhost)/goghvideo/notification:$(params.revision) - name: ENV_VARS value: - semver=$(tasks.prepare.results.version) workspaces: - name: source workspace: source - name: dockerconfig workspace: dockerconfig - name: ephemeral-namespace runAfter: - build taskref: name: openshift-ephemeral-namespace-client kind: Task params: - name: VERSION value: 4.11 - 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 x=0; until [[ -n $(oc -n goghvideo-test-${RANDOMID} get secret/goghvideo-openshift-builder-pull-secret 2>/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 -O http://${RABBITHOST}:15672/cli/rabbitmqadmin chmod +x rabbitmqadmin ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare exchange name=conversion type=topic ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare queue name=transcode durable=true queue_type=quorum ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare queue name=notification durable=true queue_type=quorum ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare queue name=upload-nextcloud durable=true queue_type=quorum ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare queue name=complete durable=true queue_type=quorum ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare binding source="conversion" destination_type="queue" destination="transcode" routing_key="transcode" ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare binding source="conversion" destination_type="queue" destination="notification" routing_key="notification" ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare binding source="conversion" destination_type="queue" destination="upload-nextcloud" routing_key="upload-nextcloud" ./rabbitmqadmin -H ${RABBITHOST} -u ${RABBITUSER} -p ${RABBITPASS} declare binding source="conversion" destination_type="queue" destination="complete" routing_key="complete" echo -n "goghvideo-test-${RANDOMID}" > $(results.namespace.path) workspaces: - name: kubeconfig-dir workspace: dockerconfig - name: prepare-helm-charts runAfter: ["ephemeral-namespace"] taskRef: name: git-clone params: - name: url value: $(params.git-helm-url) workspaces: - name: output workspace: helm - name: basic-auth workspace: gitauth - name: deploy-notification-app runAfter: ["prepare-helm-charts"] taskRef: name: helm-upgrade-from-source params: - name: charts_dir value: notification - name: release_namespace value: $(tasks.ephemeral-namespace.results.namespace) - name: release_name value: notification - name: overwrite_values value: "image.tag=$(params.revision)" workspaces: - name: source workspace: helm - name: deploy-upload-to-nextcloud-app runAfter: ["prepare-helm-charts"] taskRef: name: helm-upgrade-from-source params: - name: charts_dir value: upload-to-nextcloud - name: release_namespace value: $(tasks.ephemeral-namespace.results.namespace) - name: release_name value: upload-to-nextcloud workspaces: - name: source workspace: helm - name: deploy-conversion-engine-job runAfter: ["prepare-helm-charts"] taskRef: name: helm-upgrade-from-source params: - name: charts_dir value: conversion-engine - name: release_namespace value: $(tasks.ephemeral-namespace.results.namespace) - name: release_name value: conversion-engine workspaces: - name: source workspace: helm - name: get-filedrop-name runAfter: ["deploy-conversion-engine-job", "deploy-upload-to-nextcloud-app", "deploy-notification-app"] taskref: name: openshift-ephemeral-namespace-client kind: Task 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) workspaces: - name: kubeconfig-dir workspace: dockerconfig - name: perform-e2e-test runAfter: ["get-filedrop-name"] taskref: name: openshift-ephemeral-namespace-client kind: Task params: - name: VERSION value: 4.11 - name: SCRIPT value: | #!/usr/bin/env bash oc create -f - <