-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Tekton config to support for BitBucket Cloud (#311)
Create Triggers, TriggerTemplates, and Bindings Signed-off-by: Sergiy Kulanov <[email protected]>
- Loading branch information
Showing
16 changed files
with
447 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
charts/pipelines-library/templates/triggers/bitbucket/trigger-build.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
30 changes: 30 additions & 0 deletions
30
charts/pipelines-library/templates/triggers/bitbucket/trigger-review.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
40 changes: 40 additions & 0 deletions
40
charts/pipelines-library/templates/triggers/bitbucket/triggerbinding-build.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
33 changes: 33 additions & 0 deletions
33
charts/pipelines-library/templates/triggers/bitbucket/triggerbinding-review.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
82 changes: 82 additions & 0 deletions
82
charts/pipelines-library/templates/triggers/bitbucket/tt-build.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
78 changes: 78 additions & 0 deletions
78
charts/pipelines-library/templates/triggers/bitbucket/tt-review.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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!" |
Oops, something went wrong.