Ubuntu – How to configure Jenkins deployment path on Ubuntu

debianJenkinsUbuntu

With default Ubuntu/Debian installation of Jenkins, is there an easy way to change the deployment path? I'd like Jenkins to be available somewhere like http://localhost:8090/foobar

I'm looking for a way to configure it in /etc/default/jenkins, similarly to setting the HTTP port:

# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8090

/etc/default/jenkins contains this bit which seems related, but I'm not sure how to use it:

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

Best Answer

Ah, looking at /etc/default/jenkins a bit more, this turned out very easy.

The end of /etc/default/jenkins looks like this by default:

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

# arguments to pass to jenkins.
# --javahome=$JAVA_HOME
# --httpPort=$HTTP_PORT (default 8080; disable with -1)
# --httpsPort=$HTTP_PORT
# --ajp13Port=$AJP_PORT
# --argumentsRealm.passwd.$ADMIN_USER=[password]
# --argumentsRealm.roles.$ADMIN_USER=admin
# --webroot=~/.jenkins/war
# --prefix=$PREFIX

JENKINS_ARGS="--webroot=/var/cache/jenkins/war --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT"

So, you only need to set PREFIX to your liking, and edit JENKINS_ARGS to contain --prefix=$PREFIX. So JENKINS_ARGS would be something like:

 JENKINS_ARGS="--webroot=/var/cache/jenkins/war --prefix=$PREFIX --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT"