Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update jdk and scala quickstarters / agents #1050

Merged
merged 14 commits into from
Sep 3, 2024
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Unreleased

- Update Rust Axum Quickstarter to Rust 1.79.0 ([#1024](https://github.com/opendevstack/ods-quickstarters/pull/1024))
- Update jdk quickstarters and agent ([#1032](https://github.com/opendevstack/ods-quickstarters/issues/1032))
- Update jdk and scala quickstarters and agents ([#1032](https://github.com/opendevstack/ods-quickstarters/issues/1032))
- Gitleaks docs fix and update ([#1028](https://github.com/opendevstack/ods-quickstarters/issues/1028))
- Enable OpenSSL vendored compilation for Rust Jenkins Agent ([#1026](https://github.com/opendevstack/ods-quickstarters/pull/1026))
- Update Golang agent ([#1031](https://github.com/opendevstack/ods-quickstarters/issues/1031))
Expand Down
2 changes: 1 addition & 1 deletion be-scala-play/files/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/openjdk-11-runtime:1.15
FROM registry.access.redhat.com/ubi9/openjdk-11-runtime:latest

BraisVQ marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /app
COPY lib/* /app/lib/
Expand Down
28 changes: 11 additions & 17 deletions common/jenkins-agents/scala/docker/Dockerfile.ubi8
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ ARG nexusUrl
ARG nexusUsername
ARG nexusPassword

# Install Java
RUN yum install -y java-11-openjdk-devel && \
yum clean all -y && \
# Container support is now integrated in Java 11, the +UseCGroupMemoryLimitForHeap option has been pruned
ENV JAVA_TOOL_OPTIONS="-XX:+UnlockExperimentalVMOptions -Dsun.zip.disableMemoryMapping=true"

# Install sbt and java 11 (for retrocompatibility)
ENV SBT_VERSION=1.8.2
ENV SBT_CREDENTIALS="$HOME/.sbt/.credentials"
RUN rm -f /etc/yum.repos.d/bintray-rpm.repo && \
curl -L https://www.scala-sbt.org/sbt-rpm.repo > sbt-rpm.repo && \
mv sbt-rpm.repo /etc/yum.repos.d/ && \
yum -y install sbt-$SBT_VERSION java-11-openjdk-devel && \
yum clean all && \
rm -rf /var/cache/yum

# Copy use java scripts.
Expand All @@ -22,20 +30,6 @@ RUN chmod +x /usr/local/bin/use-j*.sh && \
use-j17.sh && \
echo "--- ENDS JDK 11/17 TESTS ---"

# Container support is now integrated in Java 11, the +UseCGroupMemoryLimitForHeap option has been pruned
ENV JAVA_TOOL_OPTIONS="-XX:+UnlockExperimentalVMOptions -Dsun.zip.disableMemoryMapping=true"


# Install sbt
ENV SBT_VERSION=1.8.2
ENV SBT_CREDENTIALS="$HOME/.sbt/.credentials"
RUN rm -f /etc/yum.repos.d/bintray-rpm.repo && \
curl -L https://www.scala-sbt.org/sbt-rpm.repo > sbt-rpm.repo && \
mv sbt-rpm.repo /etc/yum.repos.d/ && \
yum -y install sbt-$SBT_VERSION && \
yum clean all && \
rm -rf /var/cache/yum

COPY sbtconfig/repositories $HOME/.sbt/repositories
COPY sbtconfig/credentials.sbt $HOME/.sbt/1.0/plugins/credentials.sbt
COPY sbtconfig/credentials $HOME/.sbt/.credentials
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/jenkins-agents/pages/jdk.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ To switch the environment to `java 17` the script `use-j17.sh` is provided at th
To switch the environment to `java 21` the script `use-j21.sh` is provided at the jenkins home folder.
Following command shows how the jenkins build script from the springboot quickstarter switches the java version before calling the gradle wrapper:
```
def status = sh(script: "$HOME/use-j21.sh && ./gradlew clean build --stacktrace --no-daemon && $HOME/use-j11.sh", returnStatus: true)
def status = sh(script: "$HOME/use-j21.sh && ./gradlew clean build --stacktrace --no-daemon && $HOME/use-j17.sh", returnStatus: true)
```
NOTE: like this example, you will need to switch back to `java 11` after running the gradlew build. This is required because the jdk agent environment still does not support the latest java version. E.g. the `sonar scanner` is not compatible with the latest java version.
NOTE: like this example, you will need to switch back to `java 17` after running the gradlew build. This is required because the jdk agent environment still does not support the latest java version. E.g. the `sonar scanner` is not compatible with the latest java version.

== Installed packages

Expand Down
18 changes: 18 additions & 0 deletions docs/modules/jenkins-agents/pages/scala.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,23 @@ It can be referenced in a `Jenkinsfile` with `ods/jenkins-agent-scala`.
. HTTP proxy aware
. Nexus aware

== Supported Java Versions
This agent provides 1 JDKs: `java 11` and `java 17` (default).

For backwards compatibility `java 11` is till included. Java projects migrating from previous ODS version will require the use of the bash script `use-j11.sh` to use java 11. A migration to `java 17` can be done afterwards.

To switch the environment to `java 11` the script `use-j11.sh` is provided at the jenkins home folder.
To switch the environment to `java 17` the script `use-j17.sh` is provided at the jenkins home folder.
Following command shows how the jenkins build script from the scala quickstarter switches the java version before calling the SBT:
```
def status = sh(script: "$HOME/use-j11.sh && sbt -v clean scalafmtSbtCheck scalafmtCheckAll coverage test coverageReport coverageOff compile:clean copyDockerFiles && $HOME/use-j17.sh", returnStatus: true)
```
NOTE: like this example, you will need to switch back to `java 17` after running the SBT build. This is required because the scala agent environment still does not support the latest java version. E.g. the `sonar scanner` is not compatible with the java 11.

== Installed packages

Dockerfile.ubi8 installs:
- java-11-openjdk-devel

== Known limitations
In case HTTP Proxy config is injected through environment variables (including `NO_PROXY`), Nexus configuration is disabled because of an SBT bug.
12 changes: 6 additions & 6 deletions docs/modules/quickstarters/pages/be-java-springboot.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ The quickstarter uses the spring boot project generator service hosted by Spring

This is implemented in the quickstarter jenkins build script called `Jenkinsfile` (open it to understand the internal of the code generation of this quickstarter).

When provisioning this quickstarter in the provisioning app a spring boot project based on version `3.2.0` will be generated and pushed to your git repository.
When provisioning this quickstarter in the provisioning app a spring boot project based on version `3.3.3` will be generated and pushed to your git repository.

The generated project requires `java 21` and includes the required gradle build and wrapper artifact based on gradle version `8.5`.
The generated project requires `java 21` and includes the required gradle build and wrapper artifact based on gradle version `8.10`.

== Project Structure

Expand Down Expand Up @@ -111,7 +111,7 @@ version: 1.0.1
type: ods
role: backend
runtime: spring-boot
runtimeVersion: 3.2.0
runtimeVersion: 3.3.3
```

== How this quickstarter is built thru jenkins
Expand Down Expand Up @@ -144,14 +144,14 @@ https://github.com/opendevstack/ods-quickstarters/tree/master/common/jenkins-age
== Migration to Java 21

The https://github.com/opendevstack/ods-quickstarters/tree/master/common/jenkins-agents/jdk[jdk builder agent] Jenkins builder agent has installed 3 JDK: `java 11`, `java 17` and `java 21`.
The default version is `java 11`. This makes the agent backwards compatible.
The default version is `java 17`. This makes the agent backwards compatible.

If you are migrating an ODS-based spring boot project to `java 21` following instructions provide a some guidance about the typical steps to achieve this:

- change the agent version as indicated in https://github.com/opendevstack/ods-quickstarters/tree/master/common/jenkins-agents/jdk[jdk builder agent]
- upgrade the gradle wrapper to version `8.5` running this gradle command at the root folder of your spring project:
- upgrade the gradle wrapper to version `8.10` running this gradle command at the root folder of your spring project:
```
gradle wrapper --gradle-version 8.5 --distribution-type bin
gradle wrapper --gradle-version 8.10 --distribution-type bin
```
NOTE: this command use just `gradle` instead of the wrapper.

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/quickstarters/pages/be-scala-play.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ An example Play Web Application is generated with a Controller and some tests.
This project is generated by https://www.scala-sbt.org/[SBT] using SBTs template generation via the `new` command.
The template used is an adapted version of the official https://github.com/playframework/play-scala-seed.g8[Play Scala Seed Template].

It will generate a Play Scala project using version 2.8.0 of Play with Scala version 2.13.1.
It will generate a Play Scala project using version 2.8.2 of Play with Scala version 2.13.10.
It uses the https://github.com/logstash/logstash-logback-encoder[logstash-logback-encoder] to output logmessages in logstash format.
It uses https://scalameta.org/scalafmt[Scalafmt] to check/format the source files consistently.

Expand Down
Loading