sous-chefs / jenkins

Development repository for the jenkins cookbook
https://supermarket.chef.io/cookbooks/jenkins
Apache License 2.0
424 stars 635 forks source link

jenkins.java attribute ignored by init.d in current packages #688

Closed stefanor closed 4 years ago

stefanor commented 6 years ago

Cookbook version

5.0.4 (but looks present in 6.0.0 too)

Chef-client version

12.22.1

Platform Details

Ubuntu 18.04

Scenario:

Jenkins doesn't support Java 11 yet, which is the default on Ubuntu 18.04.

The jenkins cookbook appears to provide a mechanism to deal with this, the jenkins.java attribute. However, the init script for the jenkins package reads:

...
NAME=jenkins
SCRIPTNAME=/etc/init.d/$NAME

[ -r /etc/default/$NAME ] && . /etc/default/$NAME

#DAEMON=$JENKINS_SH
DAEMON=/usr/bin/daemon
DAEMON_ARGS="--name=$NAME --inherit --env=JENKINS_HOME=$JENKINS_HOME --output=$JENKINS_LOG --pidfile=$PIDFILE"
JAVA=`type -p java`
...

So, the init script is ignoring the $JAVA variable that the cookbook set in /etc/default/jenkins and instead using the first java on $PATH.

Steps to Reproduce:

Install both a default JRE and a non-default JRE. Set the attribute force_default['jenkins']['java'] to the non-default JRE.

e.g. on Ubuntu 18.04:

apt install default-jre openjdk-8-jre

and

force_default['jenkins']['java'] = '/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java'

Install Jenkins using the package method.

Expected Result:

That Jenkins starts using the specified Java version. On Ubuntu 18.04, this would result in a successful start.

Actual Result:

Jenkins attempts to start, using the default JRE, and on Ubuntu 18.04, it fails.

astj commented 5 years ago

As I described in #707 , to change java we have to set PATH=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin or something in /etc/default/jenkins, and currently this cookbook does not support setting PATH in /etc/default/jenkins. Though default['jenkins']['java']=XXX writes JAVA=XXX to /etc/default/jenkins, /etc/init.d/jenkins never look JAVA environmental variable in the default file.

github-actions[bot] commented 4 years ago

Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.

github-actions[bot] commented 4 years ago

Closing due to inactivity. If this is still an issue please reopen or open another issue. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.