First pass at reporting failed jobs to onedev.
This commit is contained in:
parent
386fcdea47
commit
137a9fcb3a
|
|
@ -0,0 +1,6 @@
|
||||||
|
FROM docker.io/debian:bullseye-slim
|
||||||
|
|
||||||
|
RUN apt update -y && \
|
||||||
|
apt install -y \
|
||||||
|
curl \
|
||||||
|
jq
|
||||||
|
|
@ -7,17 +7,11 @@ spec:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: test-trigger-check
|
- name: test-trigger-check
|
||||||
image: docker.io/debian:bullseye-slim
|
image: 192.168.1.128:8443/curl:latest
|
||||||
env:
|
|
||||||
- name: http_proxy
|
|
||||||
value: http://squid-service:3128
|
|
||||||
command: ["bash"]
|
command: ["bash"]
|
||||||
args:
|
args:
|
||||||
- "-c"
|
- "-c"
|
||||||
- >-
|
- >-
|
||||||
apt update -y &&
|
|
||||||
apt upgrade -y &&
|
|
||||||
apt install -y curl &&
|
|
||||||
curl -X POST http://el-test-pipeline-listener.default.svc.cluster.local:8080 -H 'Content-Type: application/json' -d '{}'
|
curl -X POST http://el-test-pipeline-listener.default.svc.cluster.local:8080 -H 'Content-Type: application/json' -d '{}'
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
backoffLimit: 0
|
backoffLimit: 0
|
||||||
|
|
@ -38,4 +38,19 @@ spec:
|
||||||
script: |
|
script: |
|
||||||
set -x
|
set -x
|
||||||
cat $(workspaces.source.path)/README.md
|
cat $(workspaces.source.path)/README.md
|
||||||
exit 0
|
exit -1
|
||||||
|
finally:
|
||||||
|
- name: notify-onedev
|
||||||
|
params:
|
||||||
|
- name: tekton-login-secret-name
|
||||||
|
value: onedev-api-key
|
||||||
|
- name: feedback-url
|
||||||
|
value: https://git.jpace121.net/
|
||||||
|
- name: project-id
|
||||||
|
value: 9
|
||||||
|
- name: run-name
|
||||||
|
value: $(context.pipelineRun.name)
|
||||||
|
- name: status
|
||||||
|
value: $(tasks.status)
|
||||||
|
taskRef:
|
||||||
|
name: j7s-onedev-file-bug
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
apiVersion: tekton.dev/v1beta1
|
||||||
|
kind: Task
|
||||||
|
metadata:
|
||||||
|
name: j7s-onedev-file-bug
|
||||||
|
spec:
|
||||||
|
params:
|
||||||
|
- name: tekton-login-secret-name
|
||||||
|
- name: feedback-url
|
||||||
|
- name: project-id
|
||||||
|
- name: run-name
|
||||||
|
- name: status
|
||||||
|
steps:
|
||||||
|
- image: 192.168.1.128:8443/curl:latest
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
case "$(params.status)" in
|
||||||
|
"Succeeded" | "Completed")
|
||||||
|
echo "Build was successful!"
|
||||||
|
;;
|
||||||
|
"Failed" | "None")
|
||||||
|
echo "Build failed. :("
|
||||||
|
echo '{"projectId": 0, "title": "", "description": "Build Failed!",
|
||||||
|
"confidential": false, "milestoneIds": [],
|
||||||
|
"fields": {"Type": "Build Failure"} }' > request1.json
|
||||||
|
cat request1.json | jq ".projectId = $(params.project-id)" | jq . > request2.json
|
||||||
|
cat request2.json | jq ".title = \"Failed run: $(params.run-name).\" " | jq . > request3.json
|
||||||
|
curl -u tekton:$TEKTON_API_KEY \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d@request3.json \
|
||||||
|
$(params.feedback-url)/~api/issues
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
env:
|
||||||
|
- name: TEKTON_API_KEY
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: $(params.tekton-login-secret-name)
|
||||||
|
key: accesstoken
|
||||||
Loading…
Reference in New Issue