Skip to content

Commit 7bc0ea6

Browse files
committed
Add notification to pipeline
1 parent be23096 commit 7bc0ea6

File tree

6 files changed

+126
-4
lines changed

6 files changed

+126
-4
lines changed

deploy/pipeline/mw-pipeline-v0.1.yaml

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ spec:
4343
type: string
4444
- name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
4545
type: string
46+
- name: NOTIFICATION_CONTEXT
47+
type: string
48+
default: ""
4649
workspaces:
4750
- name: source
4851
description: Workspace containing the source code
@@ -101,7 +104,7 @@ spec:
101104
resolver: http
102105
params:
103106
- name: url
104-
value: https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/refs/heads/main/deploy/tasks/pre-build.yaml
107+
value: https://raw.githubusercontent.com/rnc/jvm-build-service/refs/heads/BR3/deploy/tasks/pre-build.yaml
105108
workspaces:
106109
- name: source
107110
workspace: source
@@ -161,3 +164,64 @@ spec:
161164
params:
162165
- name: url
163166
value: https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/refs/heads/main/deploy/tasks/maven-deployment.yaml
167+
168+
169+
finally:
170+
- name: notification
171+
displayName: "Notify PNC driver"
172+
params:
173+
- name: ACCESS_TOKEN
174+
value: $(params.ACCESS_TOKEN)
175+
- name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
176+
value: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
177+
- name: NOTIFICATION_CONTEXT
178+
value: $(params.NOTIFICATION_CONTEXT)
179+
- name: STATUS
180+
value: $(tasks.status)
181+
taskSpec:
182+
params:
183+
- name: ACCESS_TOKEN
184+
description: Access token for OAuth.
185+
type: string
186+
default: ""
187+
- name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
188+
description: Name of the processor image. Useful to override for development.
189+
type: string
190+
default: "quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/build-request-processor:latest"
191+
- name: NOTIFICATION_CONTEXT
192+
description: Notification context
193+
type: string
194+
- name: STATUS
195+
description: Aggregate tasks status
196+
type: string
197+
steps:
198+
- name: notification
199+
image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
200+
args:
201+
- notify
202+
- --context=$(params.NOTIFICATION_CONTEXT)
203+
- --status=$(params.STATUS)
204+
- --build-id=$(params.BUILD_ID)
205+
# script: |
206+
# #!/bin/bash
207+
# set -x
208+
# data=""
209+
# if [ $(params.STATUS) == "Failed" ]; then
210+
# echo "Looks like one or more tasks returned failure!"
211+
# data={\"status\":\"$(params.STATUS)\"}
212+
# else
213+
# echo "Notify PNC on pipeline completion"
214+
# data={\"status\":\"$(params.STATUS)\"}
215+
# fi
216+
# echo "Send notification >>\n$data"
217+
# # curl -v -X POST -H "Content-Type: application/json" \
218+
# # -H "Authorization: Bearer $(params.ACCESS_TOKEN)" \
219+
# # --data $data \
220+
# echo "### context: $(params.NOTIFICATION_CONTEXT)"
221+
# /opt/jboss/container/java/run/run-java.sh $@
222+
223+
# taskRef:
224+
# resolver: http
225+
# params:
226+
# - name: url
227+
# value: https://raw.githubusercontent.com/rnc/jvm-build-service/refs/heads/BR3/deploy/tasks/notification.yaml

deploy/tasks/notification.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
apiVersion: tekton.dev/v1
3+
kind: Task
4+
metadata:
5+
name: notification
6+
annotations:
7+
tekton.dev/pipelines.minVersion: 0.12.1
8+
tekton.dev/tags: image-build, konflux
9+
labels:
10+
app.kubernetes.io/version: "0.1"
11+
build.appstudio.redhat.com/build_type: docker
12+
spec:
13+
description: |-
14+
Notify PNC on pipeline completion
15+
params:
16+
- name: STATUS
17+
description: Aggregate tasks status
18+
type: string
19+
- name: NOTIFICATION_CONTEXT
20+
description: Notification context
21+
type: string
22+
- name: ACCESS_TOKEN
23+
description: Access token for OAuth.
24+
type: string
25+
default: ""
26+
- name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
27+
description: Name of the processor image. Useful to override for development.
28+
type: string
29+
default: "quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/build-request-processor:latest"
30+
steps:
31+
- name: notification
32+
image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
33+
#image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:81c4864dae6bb11595f657be887e205262e70086a05ed16ada827fd6391926ac
34+
script: |
35+
#!/bin/bash
36+
set -x
37+
data=""
38+
if [ $(params.STATUS) == "Failed" ]; then
39+
echo "Looks like one or more tasks returned failure!"
40+
data={\"status\":\"$(params.STATUS)\"}
41+
else
42+
echo "Notify PNC on pipeline completion"
43+
data={\"status\":\"$(params.STATUS)\"}
44+
fi
45+
echo "Send notification >>\n$data"
46+
# curl -v -X POST -H "Content-Type: application/json" \
47+
# -H "Authorization: Bearer $(params.ACCESS_TOKEN)" \
48+
# --data $data \
49+
echo "### context: $(params.NOTIFICATION_CONTEXT)"

deploy/tasks/pre-build.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,13 @@ spec:
118118
- name: create-pre-build-image
119119
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:52f1391e6f1c472fd10bb838f64fae2ed3320c636f536014978a5ddbdfc6b3af
120120
script: |
121+
set -x
122+
echo "IMAGE is $(params.IMAGE_URL)"
123+
ls -lR $HOME/.docker || true
124+
cat $HOME/.docker/config.json
121125
echo "Creating pre-build-image archive"
126+
select-oci-auth.sh $(params.IMAGE_URL)
122127
create-archive --store $(params.IMAGE_URL) $(results.PRE_BUILD_IMAGE_DIGEST.path)=$(workspaces.source.path)/source
123128
env:
124129
- name: IMAGE_URL
125130
value: $(params.IMAGE_URL)
126-

java-components/build-request-processor/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
<artifactId>quarkus-maven-resolver</artifactId>
5656
</dependency>
5757

58+
<dependency>
59+
<groupId>org.jboss.pnc</groupId>
60+
<artifactId>konflux-build-driver</artifactId>
61+
</dependency>
62+
5863
<dependency>
5964
<groupId>com.google.cloud.tools</groupId>
6065
<artifactId>jib-core</artifactId>

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/EntryPoint.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.redhat.hacbs.container.deploy.DeployCommand;
1313
import com.redhat.hacbs.container.deploy.DeployPreBuildSourceCommand;
1414
import com.redhat.hacbs.container.verifier.VerifyBuiltArtifactsCommand;
15+
import com.redhat.hacbs.container.notification.NotifyCommand;
1516

1617
import io.quarkus.picocli.runtime.annotations.TopCommand;
1718
import picocli.CommandLine;
@@ -27,6 +28,7 @@
2728
LookupBuildInfoCommand.class,
2829
LookupScmLocationCommand.class,
2930
DeployCommand.class,
31+
NotifyCommand.class,
3032
MavenPrepareCommand.class,
3133
SBTPrepareCommand.class,
3234
VerifyBuiltArtifactsCommand.class

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/AbstractPreprocessor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ private String getContainerFile() {
212212
""";
213213
}
214214

215-
Log.warnf("### containerFile is\n%s", containerFile);
216-
217215
return containerFile;
218216
}
219217

0 commit comments

Comments
 (0)