diff --git a/pipelines/test-report-pipeline.yaml b/pipelines/test-report-pipeline.yaml new file mode 100644 index 0000000..9f94004 --- /dev/null +++ b/pipelines/test-report-pipeline.yaml @@ -0,0 +1,57 @@ +# A pipeline to test the infrasture around calling pipelines. +--- +apiVersion: tekton.dev/v1beta1 +kind: Pipeline +metadata: + name: test-report-pipeline + namespace: j7s-ci +spec: + description: "A test pipeline." + workspaces: + - name: shared-data + description: Shared data. + - name: git-credentials + description: tekton git credentials + tasks: + - name: fetch-repo + workspaces: + - name: output + workspace: shared-data + - name: ssh-directory + workspace: git-credentials + params: + - name: url + value: ssh://git.jpace121.net:2222/tests/job-test + - name: branch + value: master + taskRef: + name: j7s-git-clone + - name: cat-readme + runAfter: ["fetch-repo"] + workspaces: + - name: source + workspace: shared-data + taskSpec: + workspaces: + - name: source + steps: + - image: docker.io/debian:bullseye-slim + script: | + set -x + cat $(workspaces.source.path)/README.md + 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 diff --git a/runs/test-report-pipeline.yaml b/runs/test-report-pipeline.yaml new file mode 100644 index 0000000..9e593aa --- /dev/null +++ b/runs/test-report-pipeline.yaml @@ -0,0 +1,20 @@ +apiVersion: tekton.dev/v1beta1 +kind: PipelineRun +metadata: + generateName: test-report-pipeline- + namespace: j7s-ci +spec: + pipelineRef: + name: test-report-pipeline + workspaces: + - name: shared-data + volumeClaimTemplate: + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + - name: git-credentials + secret: + secretName: git-credentials \ No newline at end of file diff --git a/tasks/j7s-onedev-file-bug.yaml b/tasks/j7s-onedev-file-bug.yaml index 105214b..1c57f41 100644 --- a/tasks/j7s-onedev-file-bug.yaml +++ b/tasks/j7s-onedev-file-bug.yaml @@ -16,20 +16,29 @@ spec: #!/usr/bin/env bash set -e + function make_request { + cat < request.json + { + "projectId": $(params.project-id), + "title": "Failed run: $(params.run-name).", + "description": "Build Failed!", + "confidential": false, + "milestoneIds": [], + "fields": {"Type": "Build Failure"} + } + EOF + } + 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 + make_request curl -u tekton:$TEKTON_API_KEY \ -H "Content-Type: application/json" \ - -d@request3.json \ + -d@request.json \ $(params.feedback-url)/~api/issues ;; esac diff --git a/tasks/j7s-onedev-pr-review.yaml b/tasks/j7s-onedev-pr-review.yaml index d9b0ea7..a218fbe 100644 --- a/tasks/j7s-onedev-pr-review.yaml +++ b/tasks/j7s-onedev-pr-review.yaml @@ -28,15 +28,17 @@ spec: esac # Make a comment on the PR. - echo '{"userId" : 1, "requestId" : 1, "content" : "", - "date" : ""}' > comment.json - cat comment.json | jq ".userId = $TEKTON_USER_ID" | jq . > comment1.json - cat comment1.json | jq ".requestId = $(params.pr-id)" | jq . > comment2.json - cat comment2.json | jq ".date = \"`date +"%Y-%m-%dT%H:%M:%S%:z"`\"" | jq . > comment3.json - cat comment3.json | jq ".content = \"$STATUS Tekton run: $(params.run-name).\"" | jq . > comment4.json + cat < comment.json + { + "userId": $TEKTON_USER_ID, + "requestId": $(params.pr-id), + "date": "`date +"%Y-%m-%dT%H:%M:%S%:z"`", + "content": "$STATUS Tekton run: $(params.run-name)." + } + EOF curl -u tekton:$TEKTON_API_KEY \ -H "Content-Type: application/json" \ - -d@comment4.json \ + -d@comment.json \ $(params.feedback-url)/~api/pull-request-comments env: - name: TEKTON_API_KEY