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

ci: Add scheduled eventlistener #379

Merged
merged 1 commit into from
Apr 17, 2024
Merged
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
108 changes: 108 additions & 0 deletions .tekton/scheduled-eventlistener.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: ruby-tracer-scheduled-ci-pipeline-template
spec:
params:
- description: The ISO-8601 date and time converted to RFC 1123 subdomain names
name: date-time-normalized
- description: The full sha of the git commit
name: git-commit-sha
- description: The short 7 digit sha of the git commit
name: git-commit-short-sha
resourcetemplates:
- apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
# After variable resolution, this has to be maximum 63 character long,
# lower case, RFC 1123 subdomain name. The regex used for validation is
# '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'
name: ruby-tracer-scheduled-ci-pipeline-$(tt.params.date-time-normalized)-$(tt.params.git-commit-short-sha)
spec:
params:
- name: revision
value: master
- name: git-commit-sha
value: $(tt.params.git-commit-sha)
pipelineRef:
name: github-pr-ruby-tracer-ci-pipeline
workspaces:
- name: ruby-tracer-ci-pipeline-pvc
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
---
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerBinding
metadata:
name: ruby-tracer-scheduled-binding
spec:
params:
- name: date-time-normalized
value: $(extensions.normalized_date_time)
- name: git-commit-sha
value: $(body.git_master_head_commit_sha)
- name: git-commit-short-sha
value: $(extensions.truncated_sha)
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: ruby-tracer-scheduled-ci-cronjob
spec:
schedule: "5 1 * * Mon-Fri"
jobTemplate:
spec:
template:
spec:
containers:
- name: git
# alpine/git:2.43.0
image: alpine/git@sha256:6ff4de047dcc8f0c7d75d2efff63fbc189e87d2f458305f2cc8f165ff83309cf
command:
- sh
- -c
- |
wget -O- \
--header 'Content-Type: application/json' \
--post-data '{
"git_master_head_commit_sha":"'"$(git ls-remote https://github.com/instana/ruby-sensor master | cut -f1)"'",
"date_time":"'"$(date -u -Iminutes )"'"
}' \
'http://el-ruby-tracer-scheduled-pipeline-listener.default.svc.cluster.local:8080'
restartPolicy: OnFailure
---
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: ruby-tracer-scheduled-pipeline-listener
spec:
serviceAccountName: tekton-triggers-eventlistener-serviceaccount
triggers:
- name: ruby-tracer-scheduled-pipeline-triggger
interceptors:
- name: add-truncated-sha
ref:
name: "cel"
params:
- name: "overlays"
value:
- key: truncated_sha
expression: "body.git_master_head_commit_sha.truncate(7)"
- name: add-normalized-date-time
ref:
name: "cel"
params:
- name: "overlays"
value:
- key: normalized_date_time
# The date-time converted to RFC 1123 subdomain names
expression: 'body.date_time.split("+")[0].lowerAscii().translate(":", "-")'
bindings:
- ref: ruby-tracer-scheduled-binding
template:
ref: ruby-tracer-scheduled-ci-pipeline-template
Loading