Versions and setup
The following JDKs are installed:
Oracle JDK 7, 8 and 9 were removed in Ubuntu Focal. Please switch to OpenJDK versions.
We provide the function
jdk_switcher, available as a setup command, to choose the JDK for your builds. This function can take one of two commands,
usewill select the given JDK by changing the Java executables, and setting JAVA_HOME and JRE_HOME.
homewill print out the value of JAVA_HOME for a given JDK (but make no modifications).
The valid values for
home are openjdk8, openjdk11 and openjdk17. By default, OpenJDK 11 is selected. The following is the resulting Java version, JAVA_HOME, and JRE_HOME for each JDK:
jdk_switcher home openjdk8 # /usr/lib/jvm/java-8-openjdk-amd64 jdk_switcher use openjdk8 echo $JAVA_HOME # /usr/lib/jvm/java-8-openjdk-amd64 echo $JRE_HOME # /usr/lib/jvm/java-8-openjdk-amd64/jre java -version # openjdk version "1.8.0_362" # OpenJDK Runtime Environment (build 1.8.0_362-8u362-ga-0ubuntu1~20.04.1-b09) # OpenJDK 64-Bit Server VM (build 25.362-b09, mixed mode)
OpenJDK 11 (Default)
jdk_switcher home openjdk11 # /usr/lib/jvm/java-11-openjdk-amd64 jdk_switcher use openjdk11 echo $JAVA_HOME # /usr/lib/jvm/java-11-openjdk-amd64 echo $JRE_HOME # /usr/lib/jvm/java-11-openjdk-amd64/jre java -version # openjdk version "11.0.18" 2023-01-17 # OpenJDK Runtime Environment (build 11.0.18+10-post-Ubuntu-0ubuntu120.04.1) # OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Ubuntu-0ubuntu120.04.1, mixed mode, sharing)
jdk_switcher home openjdk17 # /usr/lib/jvm/java-17-openjdk-amd64 jdk_switcher use openjdk17 echo $JAVA_HOME # /usr/lib/jvm/java-17-openjdk-amd64 echo $JRE_HOME # /usr/lib/jvm/java-17-openjdk-amd64/jre java -version # openjdk version "17.0.6" 2023-01-17 # OpenJDK Runtime Environment (build 17.0.6+10-Ubuntu-0ubuntu120.04.1) # OpenJDK 64-Bit Server VM (build 17.0.6+10-Ubuntu-0ubuntu120.04.1, mixed mode, sharing)
Other Versions With SDKMAN
If you need to install a different JDK version, consider using SDKMAN to install it. For example if you want to install OpenJDK 20, you can add the following to your Setup Commands:
source /dev/stdin <<< "$(curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/sdkman.sh)" sdk install java 20-open export PATH=$HOME/.sdkman/candidates/java/current/bin:$PATH export JAVA_HOME=$HOME/.sdkman/candidates/java/current # Add if you want to confirm the installed version java -version
Note the available JDK versions in SDKMAN change as new JDK versions come out so the specific version you are installing may need to be updated occasionally. You can check the available versions by running
sdk list java.
The following tools are preinstalled in our virtual machine. You can add them to your setup or test commands to start your build:
Scala, Clojure, Kotlin, Groovy and other JVM based languages should also run on CodeShip. Let us know if you find something that doesn’t work as expected.
CodeShip automatically caches the
$HOME/.m2/repository directories between builds to optimize build performance. You can read this article to learn more about the dependency cache and how to clear it.
Frameworks And Testing
All build tools and test frameworks, such as JUnit, will work.
If you are running parallel test pipelines, you will want separate your tests into groups and call a group specifically in each pipeline. For instance:
mvn test -Dtest=class_1
mvn test -Dtest=class_2
In addition to parallelizing your tests explicitly via parallel pipelines, some customers have found using the parallel features in JUnit and other testing frameworks to be a good way to speed up your tests.
Note that aggressive parallelization can cause resource and build failure issues, as well.
Notes And Known Issues
Due to Java version issues, you may find it helpful to test your commands with different versions via an SSH debug session if tests are running differently on CodeShip compared to your local machine.
The Java Cryptography Extension (JCE) ships from Oracle by default on Java 8 and Java 9. You can also check if JCE is in limited or unlimited mode by checking the allowed key length. Limited mode will return
128 and unlimited mode will return
jdk_switcher use oraclejdk9 jrunscript -e 'print (javax.crypto.Cipher.getMaxAllowedKeyLength("AES"));'