Skip to content

Commit 3c696ce

Browse files
authored
Merge pull request #2328 from rnc/BR1
Remove git from prebuild and use PNC Konflux tooling
2 parents 5a95d39 + 6688bc2 commit 3c696ce

File tree

10 files changed

+211
-122
lines changed

10 files changed

+211
-122
lines changed

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

Lines changed: 2 additions & 1 deletion
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: ""
@@ -129,7 +130,7 @@ spec:
129130
resolver: http
130131
params:
131132
- name: url
132-
value: https://raw.githubusercontent.com/rnc/jvm-build-service/refs/heads/BR3/deploy/tasks/pre-build.yaml
133+
value: https://raw.githubusercontent.com/rnc/jvm-build-service/refs/heads/BR1/deploy/tasks/pre-build.yaml
133134
workspaces:
134135
- name: source
135136
workspace: source

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-git.yaml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
apiVersion: tekton.dev/v1
3+
kind: Task
4+
metadata:
5+
name: pre-build-git
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 for pushing the source.
15+
params:
16+
- name: PRE_BUILD_IMAGE_DIGEST
17+
description: Digest 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: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
45+
description: Name of the processor image. Useful to override for development.
46+
type: string
47+
results:
48+
- name: GIT_ARCHIVE
49+
description: Git archive information
50+
volumes:
51+
- name: workdir
52+
emptyDir: {}
53+
stepTemplate:
54+
volumeMounts:
55+
- mountPath: /var/workdir
56+
name: workdir
57+
steps:
58+
- name: restore-trusted-artifact
59+
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:52f1391e6f1c472fd10bb838f64fae2ed3320c636f536014978a5ddbdfc6b3af
60+
script: |
61+
echo "Restoring source to workspace"
62+
use-archive $PRE_BUILD_IMAGE_DIGEST=/var/workdir/
63+
env:
64+
- name: PRE_BUILD_IMAGE_DIGEST
65+
value: $(params.PRE_BUILD_IMAGE_DIGEST)
66+
- name: create-pre-build-source
67+
image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
68+
securityContext:
69+
runAsUser: 0
70+
computeResources:
71+
limits:
72+
cpu: 300m
73+
memory: 512Mi
74+
requests:
75+
cpu: 10m
76+
memory: 512Mi
77+
env:
78+
- name: GIT_DEPLOY_TOKEN
79+
valueFrom:
80+
secretKeyRef:
81+
optional: true
82+
name: jvm-build-git-repo-secrets
83+
key: gitdeploytoken
84+
args:
85+
- deploy-pre-build-source
86+
- --source-path=/var/workdir
87+
- --task-run-name=$(context.taskRun.name)
88+
- --scm-uri=$(params.SCM_URL)
89+
- --scm-commit=$(params.SCM_HASH)
90+
- --image-id=$(params.NAME)
91+
- --git-identity=$(params.GIT_IDENTITY)
92+
- --git-url=$(params.GIT_URL)
93+
- --git-disable-ssl-verification=$(params.GIT_SSL_VERIFICATION)
94+
- --git-reuse-repository=$(params.GIT_REUSE_REPOSITORY)

deploy/tasks/pre-build.yaml

Lines changed: 16 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -11,59 +11,27 @@ metadata:
1111
build.appstudio.redhat.com/build_type: docker
1212
spec:
1313
description: |-
14-
Sets up pre-build running the preprocessor, pushing the source and creating the OCI image.
14+
Sets up pre-build running the preprocessor creating the OCI image.
1515
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
4616
- name: BUILD_TOOL
4717
description: The build tool to use (ant, gradle, maven, sbt).
4818
- name: BUILD_TOOL_VERSION
4919
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: ""
5520
- name: BUILD_SCRIPT
5621
description: The build script to embed with the Containerfile
22+
- name: JAVA_VERSION
23+
description: Java version to use (7, 8, 9, 11, 17, 21, 22, 23)
24+
- name: IMAGE_URL
25+
description: URL of the OCI image to use.
26+
type: string
5727
- name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
5828
description: Name of the processor image. Useful to override for development.
5929
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"
30+
- name: RECIPE_IMAGE
31+
description: The image from the build recipe to use
6232
results:
6333
- name: PRE_BUILD_IMAGE_DIGEST
6434
description: Digest of the image just built
65-
- name: GIT_ARCHIVE
66-
description: Git archive information
6735
workspaces:
6836
- description: The git repo will be cloned onto the volume backing this Workspace.
6937
name: source
@@ -80,47 +48,20 @@ spec:
8048
requests:
8149
cpu: 10m
8250
memory: 512Mi
83-
script: |
84-
/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
51+
args:
52+
- prepare
53+
- --build-tool-version=$(params.BUILD_TOOL_VERSION)
54+
- --java-version=$(params.JAVA_VERSION)
55+
- --recipe-image=$(params.RECIPE_IMAGE)
56+
- --request-processor-image=$(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
57+
- --type=$(params.BUILD_TOOL)
58+
- $(workspaces.source.path)/source
8559
env:
8660
- name: BUILD_SCRIPT
8761
value: $(params.BUILD_SCRIPT)
88-
# TODO: Look at making this optional until we know whether we need to store source
89-
- name: create-pre-build-source
90-
image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
91-
securityContext:
92-
runAsUser: 0
93-
computeResources:
94-
limits:
95-
cpu: 300m
96-
memory: 512Mi
97-
requests:
98-
cpu: 10m
99-
memory: 512Mi
100-
env:
101-
- name: GIT_DEPLOY_TOKEN
102-
valueFrom:
103-
secretKeyRef:
104-
optional: true
105-
name: jvm-build-git-repo-secrets
106-
key: gitdeploytoken
107-
args:
108-
- deploy-pre-build-source
109-
- --source-path=$(workspaces.source.path)/source
110-
- --task-run-name=$(context.taskRun.name)
111-
- --scm-uri=$(params.SCM_URL)
112-
- --scm-commit=$(params.SCM_HASH)
113-
- --image-id=$(params.NAME)
114-
- --git-identity=$(params.GIT_IDENTITY)
115-
- --git-url=$(params.GIT_URL)
116-
- --git-disable-ssl-verification=$(params.GIT_SSL_VERIFICATION)
117-
- --git-reuse-repository=$(params.GIT_REUSE_REPOSITORY)
11862
- name: create-pre-build-image
11963
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:52f1391e6f1c472fd10bb838f64fae2ed3320c636f536014978a5ddbdfc6b3af
12064
script: |
121-
set -x
122-
echo "IMAGE is $(params.IMAGE_URL)"
123-
cat $HOME/.docker/config.json || true
12465
echo "Creating pre-build-image archive"
12566
create-archive --store $(params.IMAGE_URL) $(results.PRE_BUILD_IMAGE_DIGEST.path)=$(workspaces.source.path)/source
12667
env:

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
* We keep all the options the same between maven, gradle, sbt and ant for now to keep the pipeline setup simpler.
1717
* Some of these may be ignored by different processors
1818
*/
19-
public abstract class AbstractPreprocessor implements Runnable {
19+
@CommandLine.Command(name = "prepare")
20+
public class AbstractPreprocessor implements Runnable {
2021

2122
/**
2223
* Equivalent to <code>$(workspaces.source.path)/source</code>
@@ -29,16 +30,19 @@ public abstract class AbstractPreprocessor implements Runnable {
2930
protected List<String> disabledPlugins;
3031

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

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

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

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

4347
protected enum ToolType {
4448
ANT,
@@ -52,8 +56,6 @@ public String toString() {
5256
}
5357
}
5458

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

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/git/Git.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ protected GitStatus pushRepository(Path path, String httpTransportUrl, String co
146146
}
147147
var branchName = tagName + "-jbs-branch";
148148
var createBranch = jGit.branchList().call().stream().map(Ref::getName).noneMatch(("refs/heads/" + branchName)::equals);
149+
Log.infof("Will create branch %s for tag %s and branch name %s", createBranch, tagName, branchName);
149150
var ref = jGit.checkout().setStartPoint(tagName).setName(branchName).setCreateBranch(createBranch).call();
150151
StoredConfig jConfig = jRepo.getConfig();
151152
Log.infof("Updating current origin of %s to %s", jConfig.getString("remote", "origin", "url"),

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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ type SystemConfigList struct {
4747

4848
const (
4949
KonfluxGitDefinition = "https://raw.githubusercontent.com/konflux-ci/build-definitions/refs/heads/main/task/git-clone/0.1/git-clone.yaml"
50-
KonfluxPreBuildDefinitions = "https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/main/deploy/tasks/pre-build.yaml"
51-
KonfluxBuildDefinitions = "https://raw.githubusercontent.com/tecarter94/jvm-build-service/rename-domain-proxy-whitelist/deploy/tasks/buildah-oci-ta.yaml"
52-
KonfluxMavenDeployDefinitions = "https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/main/deploy/tasks/maven-deployment.yaml"
50+
KonfluxPreBuildDefinitions = "https://raw.githubusercontent.com/rnc/jvm-build-service/BR1/deploy/tasks/pre-build.yaml"
51+
KonfluxPreBuildGitDefinitions = "https://raw.githubusercontent.com/rnc/jvm-build-service/BR1/deploy/tasks/pre-build-git.yaml"
52+
KonfluxBuildDefinitions = "https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/main/deploy/tasks/buildah-oci-ta.yaml"
53+
KonfluxMavenDeployDefinitions = "https://raw.githubusercontent.com/rnc/jvm-build-service/BR1/deploy/tasks/maven-deployment.yaml"
5354
)

0 commit comments

Comments
 (0)