Skip to content

Commit 9bf2b93

Browse files
committed
Split prebuild for jbs. Simplify for PNC.
1 parent a212daa commit 9bf2b93

File tree

7 files changed

+149
-17
lines changed

7 files changed

+149
-17
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ spec:
6868
type: string
6969
- name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
7070
type: string
71+
default: "quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/konflux-tooling:latest"
7172
- name: NOTIFICATION_CONTEXT
7273
type: string
7374
default: ""

deploy/tasks/maven-deployment.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ spec:
4242
- name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
4343
description: Name of the processor image. Useful to override for development.
4444
type: string
45-
default: "quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/build-request-processor:latest"
4645
- name: caTrustConfigMapKey
4746
description: The name of the key in the ConfigMap that contains the
4847
CA bundle data.

deploy/tasks/pre-build-jbs.yaml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
apiVersion: tekton.dev/v1
3+
kind: Task
4+
metadata:
5+
name: pre-build
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+
Sets up pre-build running the preprocessor, pushing the source and creating the OCI image.
15+
params:
16+
- name: IMAGE_URL
17+
description: URL of the OCI image to use.
18+
type: string
19+
- name: NAME
20+
description: Name of the pipeline run (i.e. unique dependency build name)
21+
type: string
22+
- name: GIT_IDENTITY
23+
description: Git username. If empty, deploy-pre-build-source step will be skipped.
24+
type: string
25+
default: ""
26+
- name: GIT_URL
27+
description: String to determine whether we're using gitlab or github
28+
type: string
29+
default: "github"
30+
- name: GIT_SSL_VERIFICATION
31+
description: Whether to disable ssl verification
32+
type: string
33+
default: "false"
34+
- name: GIT_REUSE_REPOSITORY
35+
description: Whether to reuse existing git repository or create new one
36+
type: string
37+
default: "false"
38+
- name: SCM_URL
39+
description: Reference to the git repository
40+
type: string
41+
- name: SCM_HASH
42+
description: Git hash
43+
type: string
44+
- name: RECIPE_IMAGE
45+
description: The image from the build recipe to use
46+
- name: BUILD_TOOL
47+
description: The build tool to use (ant, gradle, maven, sbt).
48+
- name: BUILD_TOOL_VERSION
49+
description: The build tool version to use (e.g. 3.9.5)
50+
- name: JAVA_VERSION
51+
description: Java version to use (7, 8, 9, 11, 17, 21, 22, 23)
52+
- name: BUILD_PLUGINS
53+
description: Optional comma separated list of build plugins that should be disabled.
54+
default: ""
55+
- name: BUILD_SCRIPT
56+
description: The build script to embed with the Containerfile
57+
- name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
58+
description: Name of the processor image. Useful to override for development.
59+
type: string
60+
default: "quay.io/ncross/hacbs-jvm-build-request-processor:latest"
61+
# default: "quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/build-request-processor:latest"
62+
results:
63+
- name: PRE_BUILD_IMAGE_DIGEST
64+
description: Digest of the image just built
65+
- name: GIT_ARCHIVE
66+
description: Git archive information
67+
workspaces:
68+
- description: The git repo will be cloned onto the volume backing this Workspace.
69+
name: source
70+
mountPath: /var/workdir
71+
steps:
72+
- name: preprocessor
73+
image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
74+
securityContext:
75+
runAsUser: 0
76+
computeResources:
77+
limits:
78+
cpu: 300m
79+
memory: 512Mi
80+
requests:
81+
cpu: 10m
82+
memory: 512Mi
83+
script: |
84+
# Complete temporary hack for backwards compatibility with JBS until tasks are ported to build-definitions
85+
if [[ $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) == *"konflux-tooling"* ]]; then
86+
/opt/jboss/container/java/run/run-java.sh prepare --type=$(params.BUILD_TOOL) --java-version=$(params.JAVA_VERSION) --build-tool-version=$(params.BUILD_TOOL_VERSION) --recipe-image=$(params.RECIPE_IMAGE) --request-processor-image=$(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) $(workspaces.source.path)/source
87+
else
88+
/opt/jboss/container/java/run/run-java.sh $(params.BUILD_TOOL)-prepare --java-version=$(params.JAVA_VERSION) --build-tool-version=$(params.BUILD_TOOL_VERSION) --recipe-image=$(params.RECIPE_IMAGE) --request-processor-image=$(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) --disabled-plugins=$(params.BUILD_PLUGINS) $(workspaces.source.path)/source
89+
fi
90+
env:
91+
- name: BUILD_SCRIPT
92+
value: $(params.BUILD_SCRIPT)
93+
# TODO: Look at making this optional until we know whether we need to store source
94+
- name: create-pre-build-source
95+
image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
96+
securityContext:
97+
runAsUser: 0
98+
computeResources:
99+
limits:
100+
cpu: 300m
101+
memory: 512Mi
102+
requests:
103+
cpu: 10m
104+
memory: 512Mi
105+
env:
106+
- name: GIT_DEPLOY_TOKEN
107+
valueFrom:
108+
secretKeyRef:
109+
optional: true
110+
name: jvm-build-git-repo-secrets
111+
key: gitdeploytoken
112+
args:
113+
- deploy-pre-build-source
114+
- --source-path=$(workspaces.source.path)/source
115+
- --task-run-name=$(context.taskRun.name)
116+
- --scm-uri=$(params.SCM_URL)
117+
- --scm-commit=$(params.SCM_HASH)
118+
- --image-id=$(params.NAME)
119+
- --git-identity=$(params.GIT_IDENTITY)
120+
- --git-url=$(params.GIT_URL)
121+
- --git-disable-ssl-verification=$(params.GIT_SSL_VERIFICATION)
122+
- --git-reuse-repository=$(params.GIT_REUSE_REPOSITORY)
123+
- name: create-pre-build-image
124+
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:52f1391e6f1c472fd10bb838f64fae2ed3320c636f536014978a5ddbdfc6b3af
125+
script: |
126+
set -x
127+
echo "IMAGE is $(params.IMAGE_URL)"
128+
cat $HOME/.docker/config.json || true
129+
echo "Creating pre-build-image archive"
130+
create-archive --store $(params.IMAGE_URL) $(results.PRE_BUILD_IMAGE_DIGEST.path)=$(workspaces.source.path)/source
131+
env:
132+
- name: IMAGE_URL
133+
value: $(params.IMAGE_URL)

deploy/tasks/pre-build.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ spec:
3232
- name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
3333
description: Name of the processor image. Useful to override for development.
3434
type: string
35-
default: "quay.io/ncross/hacbs-jvm-build-request-processor:latest"
36-
# default: "quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/build-request-processor:latest"
3735
results:
3836
- name: PRE_BUILD_IMAGE_DIGEST
3937
description: Digest of the image just built
@@ -53,17 +51,20 @@ spec:
5351
requests:
5452
cpu: 10m
5553
memory: 512Mi
56-
script: |
57-
/opt/jboss/container/java/run/run-java.sh prepare --type=$(params.BUILD_TOOL) --java-version=$(params.JAVA_VERSION) --build-tool-version=$(params.BUILD_TOOL_VERSION) --recipe-image=$(params.RECIPE_IMAGE) --request-processor-image=$(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) $(workspaces.source.path)/source
54+
args:
55+
- prepare
56+
- --build-tool-version=$(params.BUILD_TOOL_VERSION)
57+
- --java-version=$(params.JAVA_VERSION)
58+
- --recipe-image=$(params.RECIPE_IMAGE)
59+
- --request-processor-image=$(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
60+
- --type=$(params.BUILD_TOOL)
61+
- $(workspaces.source.path)/source
5862
env:
5963
- name: BUILD_SCRIPT
6064
value: $(params.BUILD_SCRIPT)
6165
- name: create-pre-build-image
6266
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:52f1391e6f1c472fd10bb838f64fae2ed3320c636f536014978a5ddbdfc6b3af
6367
script: |
64-
set -x
65-
echo "IMAGE is $(params.IMAGE_URL)"
66-
cat $HOME/.docker/config.json || true
6768
echo "Creating pre-build-image archive"
6869
create-archive --store $(params.IMAGE_URL) $(results.PRE_BUILD_IMAGE_DIGEST.path)=$(workspaces.source.path)/source
6970
env:

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ public abstract class AbstractPreprocessor implements Runnable {
2929
protected List<String> disabledPlugins;
3030

3131
@CommandLine.Option(names = "--recipe-image", required = true)
32-
String recipeImage;
32+
protected String recipeImage;
3333

3434
@CommandLine.Option(names = "--request-processor-image", required = true)
35-
String buildRequestProcessorImage;
35+
protected String buildRequestProcessorImage;
3636

3737
@CommandLine.Option(names = "--java-version", required = true)
38-
String javaVersion;
38+
protected String javaVersion;
3939

4040
@CommandLine.Option(names = "--build-tool-version", required = true)
41-
String buildToolVersion;
41+
protected String buildToolVersion;
42+
43+
protected ToolType type;
4244

4345
protected enum ToolType {
4446
ANT,
@@ -52,8 +54,6 @@ public String toString() {
5254
}
5355
}
5456

55-
protected ToolType type;
56-
5757
/**
5858
* This section creates two files within a <code>.jbs</code> subdirectory. The Containerfile is used
5959
* by Konflux to initiate a build and the <code>run-build.sh</code> contains generic setup

java-components/build-request-processor/src/test/java/com/redhat/hacbs/container/notification/NotificationTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ public void testNotify() throws IOException, URISyntaxException {
5656
.uri(new URI(wireMockServer.baseUrl() + "/internal/completed"))
5757
.build();
5858

59-
System.err.println("### wiremock uri: " + wireMockServer.baseUrl());
60-
// {"method":"PUT","uri":"http://localhost:8081/internal/completed","headers":[{"name":"Content-Type","value":"application/json"}],"attachment":null}
61-
6259
NotifyCommand notifyCommand = new NotifyCommand();
6360
notifyCommand.status = "Succeeded";
6461
notifyCommand.buildId = "1234";

pkg/apis/jvmbuildservice/v1alpha1/systemconfig_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type SystemConfigList struct {
4848
const (
4949
KonfluxGitDefinition = "https://raw.githubusercontent.com/konflux-ci/build-definitions/refs/heads/main/task/git-clone/0.1/git-clone.yaml"
5050
KonfluxPreBuildDefinitions = "https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/main/deploy/tasks/pre-build.yaml"
51+
KonfluxPreBuildGitDefinitions = "https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/main/deploy/tasks/pre-build-jbs.yaml"
5152
KonfluxBuildDefinitions = "https://raw.githubusercontent.com/tecarter94/jvm-build-service/rename-domain-proxy-whitelist/deploy/tasks/buildah-oci-ta.yaml"
5253
KonfluxMavenDeployDefinitions = "https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/main/deploy/tasks/maven-deployment.yaml"
5354
)

0 commit comments

Comments
 (0)