How to update JDK on Jenkins Server cartridge (Ope

2019-07-03 14:45发布

问题:

The Jenkins Server cartridge (OpenShift) uses OpenJDK 7u55.

How to update to OpenJDK 7u60 or 8u05 or Oracle JDK (7u60 or 8u05), please?

回答1:

You can do this using OpenShift's action hooks. Add a script which will check for the existence of the JDK you want to use, and download it if it doesn't exist.

For example, in .openshift/action_hooks/deploy, add this snippet:

#! /bin/bash
JDK_HOME=$OPENSHIFT_DATA_DIR/jdk1.8.0

if [[ ! -L $JDK_HOME && ! -d $JDK_HOME ]] 
  then 
  cd $OPENSHIFT_DATA_DIR
  wget http://www.java.net/download/jdk8u20/archive/b17/binaries/jdk-8u20-ea-bin-b17-linux-x64-04_jun_2014.tar.gz
  tar xvf *.tar.gz 
  rm -f *.tar.gz
  ln -s jdk1.8.0_20 jdk1.8.0
fi

In Jenkins, you can then configure builds to use this JDK by configuring the PATH variable, in an "Execute Shell" action, like so:

export PATH=$OPENSHIFT_DATA_DIR/jdk1.8.0/bin:$PATH

This example retrieves 8u20. Sorry, I'm not sure of the links to use for the exact versions you mention. Also, word of warning, this download is over HTTP, without performing a check against the published MD5 checksums. If you're doing anything serious, you should edit to code snippet to perform that check.