You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 5, 2024. It is now read-only.
= Configuring dependencies rebuild for Java applications
2
2
3
-
For Java applications in {ProductName}, you can configure the Java Virtual Machine (JVM) build service either with the dependencies rebuild feature enabled or with that feature disabled. This document outlines, for each scenario, why and how you would configure the JVM build service.
3
+
For Java applications in {ProductName}, you can configure the Java Virtual Machine (JVM) build service either with the dependencies rebuild feature enabled or with that feature disabled.
4
4
5
-
== Configuring Java builds with enabled dependencies rebuild
5
+
== JVM Build Service overview
6
6
7
-
Java applications download all their dependencies as pre-compiled binaries from repositories, such as Maven Central. While these pre-compiled binaries are convenient, they do not assure the origin of the dependency, and you cannot ensure that the binary artifact matches the open source code. Therefore, Java is different from languages like golang which use source code-based dependencies.
7
+
The Java Virtual Machine Build Service (JBS or JVM Build Service) is a controller that rebuilds Java and other JVM Language based dependencies from source.
8
8
9
-
The JVM build service addressed this concern by allowing you to rebuild your application dependencies from the source automatically. By rebuilding, you can be sure that your dependencies match the source code and were compiled in a clean and trusted environment.
9
+
The Java ecosystem uses a binary distribution model, where binary jar files are downloaded from central repositories, such as Maven Central. This distribution model means that the only way to ensure an application is completely built from source is to rebuild all its component libraries from source in a trusted environment. Due to the Java ecosystem, you would need to manually rebuild the component libraries.
10
10
11
-
.*Workflow*
11
+
Although the Java binary distribution model is very convenient, it does mean that you will inevitably use untrusted dependencies with unknown provenance maintained by external communities. In general, you don't know who has uploaded these artifacts, the environment that was used to build them, or how that build environment might be compromised. Building from source in a secure environment means that you can be be completely sure as to where the code you are running has come from.
12
12
13
-
* The system builds your application by using community dependencies.
13
+
JBS automates this process as much as possible, making it much less time-consuming to create builds that are build from source in a controlled environment.
14
14
15
-
* The JVM Build Service analyzes your application and determines the dependencies that the system needs to be rebuilt.
15
+
=== Workflow Description
16
16
17
-
* The JVM Build Service generates `ArtifactBuild` objects to represent each artifact in your application before determining to which repository the artifacts belong. The JVM Build Service tags from which systems the artifacts derive.
17
+
When using the JVM Build Service the end user workflow is as follows:
18
18
19
-
* The system analyzes the repository and uses the results to find a build strategy. For example, if the system cannot find the JDK version to use, the system uses all versions to determine the most effective version to use.
19
+
- The system builds your application by using community dependencies.
20
20
21
-
* The system attempts to build all the dependencies and stores them in container images in an image registry, and `quay.io` is the default.
21
+
- The JVM Build Service analyzes your application and determines the dependencies that the system needs to rebuild.
22
22
23
-
* When the system has completed all its builds, you can rebuild your application.
23
+
- The JVM Build Service generates `ArtifactBuild` objects to represent each artifact in your application before determining to which repository the artifacts belong. The JVM Build Service tags from which systems the artifacts derive.
24
24
25
-
* If all the builds are successful, your application's SBOM displays that none of the dependencies came from third-party repositories. However, you may need to troubleshoot when some dependencies fail to build.
25
+
- The system analyzes the repository and uses the results to find a build strategy. For example, if the system cannot find the JDK version to use, the system uses all versions to determine the most effective version to use.
26
26
27
-
.*Procedure*
27
+
- The system attempts to build all the dependencies and stores them in container images in an image registry, and `quay.io` is the default.
28
+
29
+
- When the system has completed all its builds, you can rebuild your application.
30
+
31
+
- If all the builds are successful, your application's SBOM displays that none of the dependencies came from third-party repositories. However, you may need to troubleshoot when some dependencies fail to build.
32
+
33
+
== Setup
34
+
35
+
=== Logging into the Server
36
+
37
+
All interactions with the JVM Build Service require you to be logged into the OpenShift namespace used for your builds.
38
+
39
+
.Procedure
40
+
41
+
Copy the login command from: https://registration-service-toolchain-host-operator.apps.stone-prd-host1.wdlc.p1.openshiftapps.com/
42
+
43
+
=== Setting up the CLI
44
+
45
+
Many of the commands below can be setup using the JVM Build Service CLI.
46
+
47
+
The CLI is currently distributed as a docker image. To use the docker image, create the following alias:
48
+
49
+
```
50
+
alias jbs='docker run --mount type=bind,source=$HOME/.kube/config,target=/kube --mount type=bind,source=$HOME/.github,target=/root/.github --env KUBECONFIG=/kube -it --rm quay.io/redhat-appstudio/hacbs-jvm-cli:latest'
51
+
```
52
+
53
+
To update the latest version, create an update alias. You can run this alias to pull the latest version of the docker image:
54
+
55
+
```
56
+
alias update-jbs='docker pull quay.io/redhat-appstudio/hacbs-jvm-cli:latest'
57
+
```
58
+
59
+
The CLI supports tab completion and all the commands have a --help option to show usage.
60
+
61
+
Note that this CLI also requires you to be logged in as described above.
62
+
63
+
To use commands that modify build recipes (i.e. commands that are used to fix failing builds) you will need to create a `$HOME/.github` file as specified at https://github-api.kohsuke.org/[].
64
+
65
+
== Configuring The JVM Rebuild Service
66
+
67
+
There are three ways to setup the JVM Build Service, they are listed below.
68
+
69
+
=== Setting up using the CLI
70
+
71
+
If you do not require explicit quay.io configuration, and you have setup the CLI this is the simplest way to setup the JVM Build Service. To do this run the `setup rebuilds` command in the CLI:
72
+
73
+
[source]
74
+
----
75
+
jbs> setup rebuilds
76
+
Working...
77
+
found .dockerconfigjson secret with appropriate token keys in namespace sdouglas1-tenant, rebuilds are possible
78
+
Rebuilds setup successfully
79
+
----
80
+
81
+
This will automatically perform the steps detailed below and setup rebuilds for you. The JVM Build Service will automatically create a quary repository to store your rebuilt artifacts.
82
+
83
+
=== Manual Setup Without Quay.io Configuration*
84
+
85
+
If you do not want to use the CLI this method creates the Kubernetes objects to setup the JVM Build Service directory using `kubectl`.
86
+
87
+
. Create a file, for example, `config.yaml`.
88
+
89
+
. In the `config.yaml` file, create a `JBSConfig` resource with the following data:
90
+
91
+
+
92
+
[source,yaml]
93
+
----
94
+
apiVersion: jvmbuildservice.io/v1alpha1
95
+
kind: JBSConfig
96
+
metadata:
97
+
name: jvm-build-config
98
+
spec:
99
+
enableRebuilds: "true"
100
+
----
101
+
102
+
. Run `kubectl apply -f config.yaml`
103
+
104
+
105
+
=== Manual Procedure With Explicit Quay.io Config
106
+
107
+
This is required if you want to specify where the rebuilt artifacts are stored. It is more complex you must also provision a secret to allow the JVM Build Service to push to the repository.
Once these steps are completed the secret should disappear, and the system is ready to use.
134
214
135
-
=== Examining the System State
215
+
== Examining the System State
136
216
137
217
After you have run your first java build with rebuilds enabled you can use `kubectl` to view the state of the rebuilds.
138
218
@@ -165,7 +245,7 @@ NAME URL
165
245
166
246
The names of the `PipelineRun` objects begin with the build name. This enables you to view logs for each `PipelineRun`.
167
247
168
-
==== Re-Running Builds [[rebuilding_artifacts]]
248
+
=== Re-Running Builds [[rebuilding_artifacts]]
169
249
170
250
To rebuild an artifact, you need to annotate the `ArtifactBuild` object with `jvmbuildservice.io/rebuild=true`. For example, to rebuild the `zookeeper.3.6.3-8fc126b0` `ArtifactBuild`, you would run:
Generally, when you are trying to fix a failure, you must manually run the builds yourself.
185
265
186
-
=== Dealing With Failed Builds
266
+
== Dealing With failed Builds
187
267
188
268
In order to see why the build failed, look at the results from the JVM Build Service.
189
269
@@ -223,7 +303,7 @@ status:
223
303
224
304
You need to deal with the failure states: `ArtifactBuildMissing` and `ArtifactBuildFailed`.
225
305
226
-
==== Dealing With Missing Artifacts (`ArtifactBuildMissing`) [[missing_artifacts]]
306
+
=== Dealing with missing artifacts (`ArtifactBuildMissing`) [[missing_artifacts]]
227
307
228
308
If your build has ended up in the state,`ArtifactBuildMissing`, you must add some SCM information into your build data repository.
229
309
@@ -290,7 +370,7 @@ legacyRepos: <6>
290
370
After adding this information, re-running the build should resolve this information, moving it to the state `ArtifactBuildBuilding`, and eventually to `ArtifactBuildComplete`.
291
371
292
372
293
-
==== Identifying why a build failed [[failed_builds]]
373
+
=== Identifying why a build failed [[failed_builds]]
294
374
295
375
To fix failed builds, first look at the build logs and figure out why it failed.
The builds are performed from lowest JDK to highest JDK. Although some JDKs may be skipped if the analyser can determine they
314
394
are not relevant. If a build has failed because of a JDK version issue, you might need to look at a later build.
315
395
316
-
==== Unknown Build Systems
396
+
=== Unknown build systems
317
397
318
398
If there are no builds at all, then the analyser could not find a build file to use.
319
399
@@ -329,7 +409,7 @@ To see an example, go to https://github.com/jvm-build-service-code/cs-au-dk-dk.b
329
409
330
410
Because the 1.11-8 release had no build file, we forked the project and added a file. We then added this file to link:https://github.com/redhat-appstudio/jvm-build-data/blob/30a00905314ca5bf20d653af1a59c39c93b9aadb/scm-info/dk/brics/_artifact/automaton/scm.yaml#L6[the SCM information].
331
411
332
-
==== Tweaking Build Parameters
412
+
=== Tweaking build parameters
333
413
334
414
Tweak build parameters to get them to pass. Tweak build paramaters by adding a `build.yaml` file to the build
335
415
data repository. For our databind example, the file would go in one of the following locations:
0 commit comments