Home > database >  Jenkins changes in /etc/default/jenkins not working
Jenkins changes in /etc/default/jenkins not working

Time:03-19

I'm running Jenkins on Ubuntu 20.04 LTS and I want to change the port or the user Jenkins runs as but changes to the /etc/default/jenkins file do not change the port after restarting the service.

The service still starts as:

/usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080

While the /etc/default/jenkins file reads:

[...]
# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8081


# servlet context, important if you want to use apache proxying
PREFIX=/$NAME

# arguments to pass to jenkins.
# full list available from java -jar jenkins.war --help
# --javaHome=$JAVA_HOME
# --httpListenAddress=$HTTP_HOST (default 0.0.0.0)
# --httpPort=$HTTP_PORT (default 8080; disable with -1)
# --httpsPort=$HTTP_PORT
# --argumentsRealm.passwd.$ADMIN_USER=[password]
# --argumentsRealm.roles.$ADMIN_USER=admin
# --webroot=~/.jenkins/war
# --prefix=$PREFIX

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"

I've checked two different Ubuntu 20.04 LTS machines and both have the same problem. Anyone have an idea what I'm doing wrong?

CodePudding user response:

Same problem here. Today I've just upgraded jenkins to v2.332.1 (on Ubuntu 20.04.1 LTS), I've slightly modified /etc/default/jenkins - updated java memory and java args:

...
# arguments to pass to java
JAVA_MEMORY="-Xmx2048m"

# Allow graphs etc. to work even when an X server is present
JAVA_ARGS="${JAVA_MEMORY} -Djava.awt.headless=true -Dhudson.model.DirectoryBrowserSupport.CSP=\"sandbox allow-scripts allow-same-origin; default-src 'none'; img-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; font-src 'self'; media-src 'self'\""
...

But after restarting the service using "systemctl restart jenkins", it does not use the new args. It seems that the /etc/default/jenkins is just ignored

jenkins  1774584       1 42 19:07 ?        00:07:14 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080

CodePudding user response:

after jenkins 2.332.1.. the /etc/default/jenkins is no longer used. jenkins is configured with systemd. you can check systemctl cat jenkins to see the options and systemctl edit jenkins to modify it..

you can change the port.

[Service] Environment="JENKINS_PORT=8081"

updated java memory and java args Environment="JENKINS_OPTS="

Environment="JENKINS_OPTS=-Xmx2048m"

  • Related