From c57ba3baf79c372972d2ad8997e9ec89dfe37eab Mon Sep 17 00:00:00 2001 From: Sergiy Kulanov Date: Wed, 2 Oct 2024 12:41:06 +0300 Subject: [PATCH] feat: Add Tekton config to support for BitBucket Cloud (#311) Create Triggers, TriggerTemplates, and Bindings Signed-off-by: Sergiy Kulanov --- charts/pipelines-library/README.md | 2 +- .../resources/gitservers/quicklink.yaml | 2 + .../triggers/bitbucket/trigger-build.yaml | 28 +++++++ .../triggers/bitbucket/trigger-review.yaml | 30 +++++++ .../bitbucket/triggerbinding-build.yaml | 40 +++++++++ .../bitbucket/triggerbinding-review.yaml | 33 ++++++++ .../triggers/bitbucket/tt-build.yaml | 82 +++++++++++++++++++ .../triggers/bitbucket/tt-review.yaml | 78 ++++++++++++++++++ charts/pipelines-library/values.yaml | 3 +- tests/e2e/bitbucket/00-assert.yaml | 44 ++++++++++ tests/e2e/bitbucket/01-assert.yaml | 23 ++++++ tests/e2e/bitbucket/01-install.yaml | 18 ++++ tests/e2e/bitbucket/02-assert.yaml | 15 ++++ tests/e2e/bitbucket/02-install.yaml | 15 ++++ tests/e2e/bitbucket/99-cleanup.yaml | 5 ++ tests/e2e/values.yaml | 31 +++++++ 16 files changed, 447 insertions(+), 2 deletions(-) create mode 100644 charts/pipelines-library/templates/triggers/bitbucket/trigger-build.yaml create mode 100644 charts/pipelines-library/templates/triggers/bitbucket/trigger-review.yaml create mode 100644 charts/pipelines-library/templates/triggers/bitbucket/triggerbinding-build.yaml create mode 100644 charts/pipelines-library/templates/triggers/bitbucket/triggerbinding-review.yaml create mode 100644 charts/pipelines-library/templates/triggers/bitbucket/tt-build.yaml create mode 100644 charts/pipelines-library/templates/triggers/bitbucket/tt-review.yaml create mode 100644 tests/e2e/bitbucket/00-assert.yaml create mode 100644 tests/e2e/bitbucket/01-assert.yaml create mode 100644 tests/e2e/bitbucket/01-install.yaml create mode 100644 tests/e2e/bitbucket/02-assert.yaml create mode 100644 tests/e2e/bitbucket/02-install.yaml create mode 100644 tests/e2e/bitbucket/99-cleanup.yaml diff --git a/charts/pipelines-library/README.md b/charts/pipelines-library/README.md index 2a94f909..16525f49 100644 --- a/charts/pipelines-library/README.md +++ b/charts/pipelines-library/README.md @@ -102,7 +102,7 @@ Follows [Tekton Interceptor](https://tekton.dev/vault/triggers-main/clusterinter | global.dockerRegistry.type | string | `"ecr"` | Define Image Registry that will to be used in Pipelines. Can be ecr (default), harbor, dockerhub | | global.dockerRegistry.url | string | `".dkr.ecr..amazonaws.com/"` | Docker Registry endpoint. In dockerhub case the URL must be specified in accordance with the Kaniko name convention (docker.io/) | | global.gerritHost | string | `"gerrit"` | Gerrit Host URL, must be specified if gerrit is enabled | -| global.gitProviders | list | `["github","gitlab","gerrit"]` | Deploy Kubernetes Resources for the specific Git Provider. Can be gerrit, gitlab, github (default) | +| global.gitProviders | list | `["bitbucket","gerrit","github","gitlab"]` | Deploy Kubernetes Resources for the specific Git Provider. Can be gerrit, gitlab, github (default) | | global.platform | string | `"kubernetes"` | platform type that can be "kubernetes" or "openshift" | | grafana.dashboards.labelKey | string | `"grafana_dashboard"` | | | grafana.dashboards.labelValue | string | `"1"` | | diff --git a/charts/pipelines-library/templates/resources/gitservers/quicklink.yaml b/charts/pipelines-library/templates/resources/gitservers/quicklink.yaml index b1463abe..9b69119a 100644 --- a/charts/pipelines-library/templates/resources/gitservers/quicklink.yaml +++ b/charts/pipelines-library/templates/resources/gitservers/quicklink.yaml @@ -14,6 +14,8 @@ spec: icon: "PHN2ZyB3aWR0aD0iOTgiIGhlaWdodD0iOTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00OC44NTQgMEMyMS44MzkgMCAwIDIyIDAgNDkuMjE3YzAgMjEuNzU2IDEzLjk5MyA0MC4xNzIgMzMuNDA1IDQ2LjY5IDIuNDI3LjQ5IDMuMzE2LTEuMDU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NSwzMjMuNTlMMzA0LjM3NSwzMjMuNTl6IiBzdHlsZT0iZmlsbDojMjY4NEZGOyIvPjwvZz48L2c+PGcgaWQ9IkxheWVyXzEiLz48L3N2Zz4=" {{- else if eq $server.gitProvider "gerrit" }} icon: "PHN2ZyB3aWR0aD0iNTIiIGhlaWdodD0iNTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+DQo8cmVjdCByeT0iNCIgcng9IjQiIGhlaWdodD0iNDAiIHdpZHRoPSI0MCIgeT0iMCIgeD0iMCIgZmlsbD0iI2ZmYWFhYSIvPg0KPHJlY3Qgcnk9IjQiIHJ4PSI0IiBoZWlnaHQ9IjQwIiB3aWR0aD0iNDAiIHk9IjEyIiB4PSIxMiIgZmlsbD0iI2FhZmZhYSIvPg0KPHBhdGggZD0ibTE4LDIybDEyLDBsMCw0bC0xMiwwbDAsLTR6IiBmaWxsPSIjZmYwMDAwIi8+DQo8cGF0aCBkPSJtMzQsMjJsMTIsMGwwLDRsLTEyLDBsMCwtNHoiIGZpbGw9IiNmZjAwMDAiLz4NCjxwYXRoIGQ9Im0xOCwzNmw0LDBsMCwtNGw0LDBsMCw0bDQsMGwwLDRsLTQsMGwwLDRsLTQsMGwwLC00bC00LDBsMCwtNHoiIGZpbGw9IiMwMDgwMDAiLz4NCjxwYXRoIGQ9Im0zNCwzNmw0LDBsMCwtNGw0LDBsMCw0bDQsMGwwLDRsLTQsMGwwLDRsLTQsMGwwLC00bC00LDBsMCwtNHoiIGZpbGw9IiMwMDgwMDAiLz4NCjwvc3ZnPg==" {{- end }} diff --git a/charts/pipelines-library/templates/triggers/bitbucket/trigger-build.yaml b/charts/pipelines-library/templates/triggers/bitbucket/trigger-build.yaml new file mode 100644 index 00000000..d778d088 --- /dev/null +++ b/charts/pipelines-library/templates/triggers/bitbucket/trigger-build.yaml @@ -0,0 +1,28 @@ +{{ if has "bitbucket" .Values.global.gitProviders }} +apiVersion: triggers.tekton.dev/v1beta1 +kind: Trigger +metadata: + name: bitbucket-build + labels: + {{- include "edp-tekton.labels" . | nindent 4 }} +spec: + interceptors: + - ref: + kind: ClusterInterceptor + name: "bitbucket" + params: + - name: "secretRef" + value: + secretName: ci-bitbucket + secretKey: secretString + - name: "eventTypes" + value: + - pullrequest:fulfilled + - ref: + name: "edp" + kind: NamespacedInterceptor + bindings: + - ref: bitbucket-binding-build + template: + ref: bitbucket-build-template +{{ end }} diff --git a/charts/pipelines-library/templates/triggers/bitbucket/trigger-review.yaml b/charts/pipelines-library/templates/triggers/bitbucket/trigger-review.yaml new file mode 100644 index 00000000..f052db48 --- /dev/null +++ b/charts/pipelines-library/templates/triggers/bitbucket/trigger-review.yaml @@ -0,0 +1,30 @@ +{{ if has "bitbucket" .Values.global.gitProviders }} +apiVersion: triggers.tekton.dev/v1beta1 +kind: Trigger +metadata: + name: bitbucket-review + labels: + {{- include "edp-tekton.labels" . | nindent 4 }} +spec: + interceptors: + - ref: + kind: ClusterInterceptor + name: "bitbucket" + params: + - name: "secretRef" + value: + secretName: ci-bitbucket + secretKey: secretString + - name: "eventTypes" + value: + - pullrequest:created + - pullrequest:comment_created + - pullrequest:updated + - ref: + kind: NamespacedInterceptor + name: "edp" + bindings: + - ref: bitbucket-binding-review + template: + ref: bitbucket-review-template +{{ end }} diff --git a/charts/pipelines-library/templates/triggers/bitbucket/triggerbinding-build.yaml b/charts/pipelines-library/templates/triggers/bitbucket/triggerbinding-build.yaml new file mode 100644 index 00000000..b870836a --- /dev/null +++ b/charts/pipelines-library/templates/triggers/bitbucket/triggerbinding-build.yaml @@ -0,0 +1,40 @@ +{{ if has "bitbucket" .Values.global.gitProviders }} +apiVersion: triggers.tekton.dev/v1beta1 +kind: TriggerBinding +metadata: + name: bitbucket-binding-build + labels: + {{- include "edp-tekton.labels" . | nindent 4 }} +spec: + params: + - name: gitrevision + value: $(body.object_attributes.target_branch) + - name: gitrepositoryurl + value: $(body.project.git_ssh_url) + - name: gitrepositoryname + value: $(body.project.name) + - name: codebase + value: "$(extensions.codebase)" + - name: codebasebranch + value: "$(extensions.codebasebranch)" + - name: changeNumber + value: "$(extensions.pullRequest.changeNumber)" + # commitMessage is used for 'push-to-jira' Task + - name: commitMessage + value: "$(body.object_attributes.title)" + # commitMessagePattern is used for 'commit-validate' Tasks + - name: commitMessagePattern + value: "$(extensions.spec.commitMessagePattern)" + # jiraIssueMetadataPayload is used for 'push-to-jira' Task + - name: jiraIssueMetadataPayload + value: "$(extensions.spec.jiraIssueMetadataPayload)" + # ticketNamePattern is used for 'push-to-jira' Task + - name: ticketNamePattern + value: "$(extensions.spec.ticketNamePattern)" + # jiraServer is used for 'push-to-jira' Task + - name: jiraServer + value: "$(extensions.spec.jiraServer)" + # get the pipeline name from the codebasebranch spec + - name: pipelineName + value: $(extensions.pipelines.build) +{{ end }} diff --git a/charts/pipelines-library/templates/triggers/bitbucket/triggerbinding-review.yaml b/charts/pipelines-library/templates/triggers/bitbucket/triggerbinding-review.yaml new file mode 100644 index 00000000..5c5e1009 --- /dev/null +++ b/charts/pipelines-library/templates/triggers/bitbucket/triggerbinding-review.yaml @@ -0,0 +1,33 @@ +{{ if has "bitbucket" .Values.global.gitProviders }} +apiVersion: triggers.tekton.dev/v1beta1 +kind: TriggerBinding +metadata: + name: bitbucket-binding-review + labels: + {{- include "edp-tekton.labels" . | nindent 4 }} +spec: + params: + - name: gitrevision + value: "$(extensions.pullRequest.headSha)" + - name: gitrepositoryurl + value: "$(body.repository.links.html.href)" + - name: gitrepositoryname + value: "$(body.repository.name)" + - name: gitfullrepositoryname + value: "$(body.repository.full_name)" + - name: targetBranch + value: "$(extensions.targetBranch)" + - name: changeNumber + value: "$(extensions.pullRequest.changeNumber)" + - name: commitMessagePattern + value: "$(extensions.spec.commitMessagePattern)" + - name: commitMessage + value: "$(extensions.pullRequest.lastCommitMessage)" + - name: codebase + value: "$(extensions.codebase)" + - name: codebasebranch + value: "$(extensions.codebasebranch)" + # get the pipeline name from the codebasebranch spec + - name: pipelineName + value: $(extensions.pipelines.review) +{{ end }} diff --git a/charts/pipelines-library/templates/triggers/bitbucket/tt-build.yaml b/charts/pipelines-library/templates/triggers/bitbucket/tt-build.yaml new file mode 100644 index 00000000..2572f986 --- /dev/null +++ b/charts/pipelines-library/templates/triggers/bitbucket/tt-build.yaml @@ -0,0 +1,82 @@ +{{ if has "bitbucket" .Values.global.gitProviders }} +apiVersion: triggers.tekton.dev/v1beta1 +kind: TriggerTemplate +metadata: + name: bitbucket-build-template + labels: + {{- include "edp-tekton.labels" . | nindent 4 }} +spec: + params: + - name: gitrevision + - name: gitrepositoryurl + - name: gitrepositoryname + - name: codebase + description: Codebase name used in pipeline + - name: codebasebranch + description: Codebasebranch name used in pipeline + - name: ticketNamePattern + description: Ticket name pattern + - name: commitMessagePattern + description: Commit message pattern to run commit-validate task + - name: commitMessage + description: Commit message + - name: changeNumber + description: Change number from Merge Request + - name: jiraIssueMetadataPayload + description: Jira issue payload + - name: jiraServer + description: Jira server name + - name: pipelineName + description: Pipeline to trigger. Populated by edp interceptor from codebasebranch spec + resourcetemplates: + - apiVersion: tekton.dev/v1 + kind: PipelineRun + metadata: + generateName: $(tt.params.codebasebranch)-build- + labels: + # used by UI to sort pipelines for codebasebranches + app.edp.epam.com/codebasebranch: $(tt.params.codebasebranch) + app.edp.epam.com/codebase: $(tt.params.codebase) + app.edp.epam.com/pipelinetype: build + annotations: + argocd.argoproj.io/compare-options: IgnoreExtraneous + spec: + taskRunTemplate: + serviceAccountName: tekton + pipelineRef: + name: $(tt.params.pipelineName) + params: + - name: git-source-url + value: $(tt.params.gitrepositoryurl) + - name: git-source-revision + value: $(tt.params.gitrevision) + - name: CODEBASE_NAME + value: $(tt.params.codebase) + - name: CODEBASEBRANCH_NAME + value: $(tt.params.codebasebranch) + - name: changeNumber + value: $(tt.params.changeNumber) + - name: TICKET_NAME_PATTERN + value: $(tt.params.ticketNamePattern) + - name: COMMIT_MESSAGE_PATTERN + value: $(tt.params.commitMessagePattern) + - name: COMMIT_MESSAGE + value: $(tt.params.commitMessage) + - name: JIRA_ISSUE_METADATA_PAYLOAD + value: $(tt.params.jiraIssueMetadataPayload) + - name: JIRA_SERVER + value: $(tt.params.jiraServer) + workspaces: + - name: shared-workspace + volumeClaimTemplate: + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.tekton.workspaceSize }} + subPath: codebase + - name: ssh-creds + secret: + secretName: ci-bitbucket +{{ end }} diff --git a/charts/pipelines-library/templates/triggers/bitbucket/tt-review.yaml b/charts/pipelines-library/templates/triggers/bitbucket/tt-review.yaml new file mode 100644 index 00000000..b450374d --- /dev/null +++ b/charts/pipelines-library/templates/triggers/bitbucket/tt-review.yaml @@ -0,0 +1,78 @@ +{{ if has "bitbucket" .Values.global.gitProviders }} +apiVersion: triggers.tekton.dev/v1beta1 +kind: TriggerTemplate +metadata: + name: bitbucket-review-template + labels: + {{- include "edp-tekton.labels" . | nindent 4 }} +spec: + params: + - name: gitrevision + - name: gitrepositoryurl + - name: gitrepositoryname + - name: gitfullrepositoryname + description: Full Repo name. Used in "bitbucket-set-status" step as REPO_PATH_ONLY + - name: targetBranch + description: Target branch of Merge Request + - name: changeNumber + description: Change number from Merge Request + - name: codebase + description: Codebase name used in pipeline + - name: codebasebranch + description: Codebasebranch name used in pipeline + - name: commitMessagePattern + description: Commit message pattern to run commit-validate task + - name: commitMessage + description: Commit message + - name: pipelineName + description: Pipeline to trigger. Populated by edp interceptor from codebasebranch spec + resourcetemplates: + - apiVersion: tekton.dev/v1 + kind: PipelineRun + metadata: + generateName: $(tt.params.codebasebranch)-review- + labels: + # used by UI to sort pipelines for codebasebranches + app.edp.epam.com/codebasebranch: $(tt.params.codebasebranch) + app.edp.epam.com/codebase: $(tt.params.codebase) + app.edp.epam.com/pipelinetype: review + annotations: + argocd.argoproj.io/compare-options: IgnoreExtraneous + spec: + taskRunTemplate: + serviceAccountName: tekton + pipelineRef: + name: $(tt.params.pipelineName) + params: + - name: git-source-url + value: $(tt.params.gitrepositoryurl) + - name: git-source-revision + value: $(tt.params.gitrevision) + - name: CODEBASE_NAME + value: $(tt.params.codebase) + - name: CODEBASEBRANCH_NAME + value: $(tt.params.codebasebranch) + - name: targetBranch + value: $(tt.params.targetBranch) + - name: changeNumber + value: $(tt.params.changeNumber) + - name: gitfullrepositoryname + value: $(tt.params.gitfullrepositoryname) + - name: COMMIT_MESSAGE_PATTERN + value: $(tt.params.commitMessagePattern) + - name: COMMIT_MESSAGE + value: $(tt.params.commitMessage) + workspaces: + - name: shared-workspace + volumeClaimTemplate: + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.tekton.workspaceSize }} + subPath: codebase + - name: ssh-creds + secret: + secretName: ci-bitbucket +{{ end }} diff --git a/charts/pipelines-library/values.yaml b/charts/pipelines-library/values.yaml index b8d8bf3a..3e6ff6b2 100644 --- a/charts/pipelines-library/values.yaml +++ b/charts/pipelines-library/values.yaml @@ -10,9 +10,10 @@ global: # Pipelines, EventListener, Tasks, etc. # -- Deploy Kubernetes Resources for the specific Git Provider. Can be gerrit, gitlab, github (default) gitProviders: + - bitbucket + - gerrit - github - gitlab - - gerrit # -- Gerrit SSH node port, must be specified if gerrit is enabled # gerritSSHPort: "30003" diff --git a/tests/e2e/bitbucket/00-assert.yaml b/tests/e2e/bitbucket/00-assert.yaml new file mode 100644 index 00000000..696c964b --- /dev/null +++ b/tests/e2e/bitbucket/00-assert.yaml @@ -0,0 +1,44 @@ +# We need to ensure that the following deployments are ready before we start testing +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cert-manager + namespace: cert-manager +status: + readyReplicas: 1 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tekton-pipelines-controller + namespace: tekton-pipelines +status: + readyReplicas: 1 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tekton-pipelines-webhook + namespace: tekton-pipelines +status: + readyReplicas: 1 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tekton-triggers-controller + namespace: tekton-pipelines +status: + readyReplicas: 1 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tekton-triggers-webhook + namespace: tekton-pipelines +status: + readyReplicas: 1 diff --git a/tests/e2e/bitbucket/01-assert.yaml b/tests/e2e/bitbucket/01-assert.yaml new file mode 100644 index 00000000..34ef2512 --- /dev/null +++ b/tests/e2e/bitbucket/01-assert.yaml @@ -0,0 +1,23 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + name: check-readiness +status: + conditions: + - reason: Succeeded + status: 'True' + type: Succeeded + pipelineSpec: + tasks: + - name: check + taskSpec: + metadata: + labels: + app: example + steps: + - computeResources: {} + image: alpine:3.18.6 + name: echo + script: | + #!/usr/bin/env sh + echo "I'm ok!" diff --git a/tests/e2e/bitbucket/01-install.yaml b/tests/e2e/bitbucket/01-install.yaml new file mode 100644 index 00000000..f27e8cc4 --- /dev/null +++ b/tests/e2e/bitbucket/01-install.yaml @@ -0,0 +1,18 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + name: check-readiness +spec: + pipelineSpec: + tasks: + - name: check + taskSpec: + metadata: + labels: + app: "example" + steps: + - name: echo + image: alpine:3.18.6 + script: | + #!/usr/bin/env sh + echo "I'm ok!" diff --git a/tests/e2e/bitbucket/02-assert.yaml b/tests/e2e/bitbucket/02-assert.yaml new file mode 100644 index 00000000..df79e63a --- /dev/null +++ b/tests/e2e/bitbucket/02-assert.yaml @@ -0,0 +1,15 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tekton-interceptor +status: + readyReplicas: 1 + +# EventListener +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: el-edp-my-bitbucket +status: + readyReplicas: 1 diff --git a/tests/e2e/bitbucket/02-install.yaml b/tests/e2e/bitbucket/02-install.yaml new file mode 100644 index 00000000..2f1ac4ba --- /dev/null +++ b/tests/e2e/bitbucket/02-install.yaml @@ -0,0 +1,15 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: | + helm install tekton-e2e ../../../charts/pipelines-library + --values ../values.yaml + --set interceptor.image.repository=${CONTAINER_REGISTRY_URL}/${CONTAINER_REGISTRY_SPACE}/${E2E_IMAGE_REPOSITORY} + --set interceptor.image.tag=${E2E_IMAGE_TAG} + --set global.dnsWildCard=example.com + --set global.gitProviders[0]=bitbucket + --set global.dockerRegistry.type=harbor + --set global.dockerRegistry.url=harbor.example.com + --set tekton-cache.enabled=false + --replace --wait + namespaced: true diff --git a/tests/e2e/bitbucket/99-cleanup.yaml b/tests/e2e/bitbucket/99-cleanup.yaml new file mode 100644 index 00000000..5be87054 --- /dev/null +++ b/tests/e2e/bitbucket/99-cleanup.yaml @@ -0,0 +1,5 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: helm uninstall tekton-e2e + namespaced: true diff --git a/tests/e2e/values.yaml b/tests/e2e/values.yaml index b28d186d..90907ec6 100644 --- a/tests/e2e/values.yaml +++ b/tests/e2e/values.yaml @@ -61,6 +61,37 @@ gitServers: # -- Ingress TLS configuration tls: [] + my-bitbucket: + gitProvider: bitbucket + host: bitbucket.example.com + webhook: + skipWebhookSSLVerification: false + eventListener: + # -- Enable EventListener + enabled: true + # -- EventListener resources + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "500m" + # -- Node labels for EventListener pod assignment + nodeSelector: {} + # -- Tolerations for EventListener pod assignment + tolerations: [] + # -- Affinity for EventListener pod assignment + affinity: {} + + ingress: + # -- Enable ingress controller resource + enabled: true + # -- Ingress annotations + annotations: {} + # -- Ingress TLS configuration + tls: [] + my-gerrit: gitProvider: gerrit host: gerrit.example.com