Out of date
This content is out of date. See the Ubuntu installation section of the handbook on jenkins.io for Debian and Ubuntu installation instructions
On Debian-based distributions, such as Ubuntu, you can install Jenkins through apt-get
.
Recent versions are available in an apt repository. Older but stable LTS versions are in this apt repository.
You need to have a JDK and JRE installed. openjdk-7-jre and openjdk-7-jdk are suggested. As of 2011-08 gcj is known to be problematic - see https://issues.jenkins-ci.org/browse/JENKINS-743.
Please make sure to back up any current Hudson or Jenkins files you may have.
Installation
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add - sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' sudo apt-get update sudo apt-get install jenkins
Upgrade
Once installed like this, you can update to the later version of Jenkins (when it comes out) by running the following commands:
sudo apt-get update sudo apt-get install jenkins
(aptitude or apt-get doesn't make any difference.)
What does this package do?
- Jenkins will be launched as a daemon up on start. See
/etc/init.d/jenkins
for more details. - The '
jenkins
' user is created to run this service. - Log file will be placed in
/var/log/jenkins/jenkins.log
. Check this file if you are troubleshooting Jenkins. /etc/default/jenkins
will capture configuration parameters for the launch like e.g JENKINS_HOME- By default, Jenkins listen on port 8080. Access this port with your browser to start configuration.
If your /etc/init.d/jenkins
file fails to start jenkins, edit the /etc/default/jenkins
to replace the line
HTTP_PORT=8080
by
HTTP_PORT=8081
Here, 8081 was chosen but you can put another port available.
Deploying on Ubuntu in a cloud (EC2, HP Cloud, OpenStack)
The Ubuntu Jenkins maintainer also maintains the Juju charm deployment/management script for deployment in clouds. It's designed to make it easy to deploy a master with multiple slaves:
juju deploy jenkins juju deploy -n 5 jenkins-slave juju add-relation jenkins jenkins-slave
The default password for the 'admin' account will be auto-generated. You can set it using:
juju set jenkins password=mypassword
Always change it this way - this account is used by the charm to manage slave configuration. Then feel free to expose your jenkins master:
juju expose jenkins
Using Linux iptables for port 80 -> 8080
- This enables port forwarding of traffic between ports 80 and 8080. You can keep Jenkins on the default port 8080 and access it with a normal url without installing anything extra.
sudo nano /etc/rc.local
- Then add the following just before the exit 0
#Requests from outside iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080 #Requests from localhost iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080
Now reboot or run sudo /etc/rc.local
to enable port forwarding. Additional info: https://gist.github.com/m5m1th/6870a54717c0387468c3
Setting up an Apache Proxy for port 80 -> 8080
- This configuration will setup Apache2 to proxy port 80 to 8080 so that you can keep Jenkins on 8080.
sudo aptitude install apache2
sudo a2enmod proxy
sudo a2enmod proxy_http
do not do this next command if you already have virtual hosting setup that depends on the default site. See my comment below - danapsimer
sudo a2dissite default
If you get ERROR: Site default does not exist!
then try this instead:
sudo a2dissite 000-default
And if all else fails just have a look if there is a default site set up at all:
ls /etc/apache2/sites-enabled/
- Create a file called
jenkins.conf
in/etc/apache2/sites-available
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName ci.company.com ServerAlias ci ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPreserveHost on ProxyPass / http://localhost:8080/ nocanon AllowEncodedSlashes NoDecode </VirtualHost>
sudo a2ensite jenkins
sudo apache2ctl restart
Setting up an Nginx Proxy for port 80 -> 8080
This configuration will setup Nginx to proxy port 80 to 8080 so that you can keep Jenkins on 8080. Instructions originally found in a GitHub Gist from rdegges: https://gist.github.com/913102
Install Nginx.
sudo aptitude -y install nginx
Remove default configuration.
cd /etc/nginx/sites-available sudo rm default ../sites-enabled/default
Create new configuration for Jenkins. This example uses
cat
, but you can use your favorite text editor. Make sure to replace 'ci.yourcompany.com' with your domain name.
Note: Sometimes your permissions (umask, etc) might be setup such that this won't work. Create the file somewhere else then copy it into place if you run into that problem.sudo cat > jenkins upstream app_server { server 127.0.0.1:8080 fail_timeout=0; } server { listen 80; listen [::]:80 default ipv6only=on; server_name ci.yourcompany.com; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://app_server; break; } } } ^D # Hit CTRL + D to finish writing the file
Link your configuration from
sites-available
tosites-enabled
:sudo ln -s /etc/nginx/sites-available/jenkins /etc/nginx/sites-enabled/
Restart Nginx
sudo service nginx restart
Where to go from here?
- You might want to make Jenkins visible through Apache, to make it available on port 80 (for example, http://myserver/jenkins/ instead of http://myserver:8080/). See this blog for more details
- You might want to see latest releases of Jenkins Debian packages. See http://pkg.jenkins-ci.org/debian-stable/
26 Comments
japher -
The above instructions worked for me on Jaunty (9.04) Server, the daemon dependency was picked up correctly.
There's a bug in the 1.322 and 1.323 releases of Hudson though that stops the hudson service starting up correctly. See https://hudson.dev.java.net/issues/show_bug.cgi?id=4304 (need to edit /etc/init.d/hudson and apply a fix as mentioned in the comments of that bug report).
benjamin dorsett
On Jaunty (9.04) Server, the daemon dependency is picked up correctly.
But Hudson doesn't start. Changing hudson user's shell to /bin/bash instead of /bin/false in /etc/passwd seems to fix it.
Unknown User (joansava@gmail.com)
My case:
I work on a Debian Lenny dist (stable)
I have updated the sources list following the instructions above and have applied the patch attached to the bug
Then, I have had to install the sun-java6-bin package to get working. In my experience the hudson does not start with the debian gnu java. I obtained an exception related to this message:
" Could not instantiate converter : com.thoughtworks.xstream.converters.extended.DurationConverter : null"
Of course, I have changed the symbolic link at /usr/bin/java by one which links directly to the java from sun.
Cheers.
Unknown User (aguynamedben)
This fix worked for me when installing Hudson on Debian Lenny: "After installing the hudson deb on Ubuntu server Jaunty 8.10 [Debian Lenny in my case], when I tried to run the init script /etc/init.d/hudson start, nothing would be printed and the server would not start. No log file was created under /var/log/hudson and no pid file was created under /var/run/hudson. I eventually discovered that if i set the hudson user's shell to /bin/bash instead of /bin/false in /etc/passwd everything works fine. Hope this saves someone else some trouble."
Also, this is a good resource: http://weblogs.java.net/blog/2008/06/11/debian-packages-hudson
Régis Desgroppes
Hi,
Hudson 1.353 was not published in the apt repository. Is there something wrong?
Régis
Unknown User (moragab@gmail.com)
Hi,
The latest version of Hudson as of the time of writing this comment is 1.357 but the latest Debian package published is 1.352 and the latest RPM package published is 1.353
Is this just lag, or is there a change in plans?
Kind Regards
Mohamed Ragab
Willem Verstraeten
Hi,
It seems as if the URL of the apt-get repository changed to
deb http://jenkins-ci.org/debian binary/
I did get an error on my Debian 5.0.4 machine, but on Ubuntu it seems to work. Got to investigate.
The error was
302 Found http://pkg.jenkins-ci.org/debian/binary/Packages
tcharl -
Hi,
Sorry, I can't find where I could post an Issue on Your JIRA.
Can you put the Latest 1.359 rpm's version please, we're stuck with 1.353 and so with the "java.lang.Error: This page expects a form submission" when creating a new Job
Unknown User (sobersabre)
hi there.
I've noticed the debian repository responds with response "302", which is redirect related.
apt does not support redirects as of now. Debian stabe apt does not.
I am currently forced to download the file manually, although it is found in the repository.
Can somebody please change the setup so that not a redirect is returned, but the file?
Thanks.
Stefan Seidel
Here's a workaround for lenny: you need: apache2, mod_proxy.
Then create a file /etc/apache2/sites-available/hudson-deb with this content:
Edit /etc/hosts and add hudson-deb.local as the last term on the line containing 127.0.0.1 (separate it with a space).
Then enable the proxy and the site and restart the apache:
Then you just add the file /etc/apt/sources.list.d/hudson.list with the following content:
And off you go with:
Dana P'Simer
the "
sudo a2dissite default
" step should only be done if you do not want the default site to stay in place. All the steps described should work without this step in a normal virtual hosted environment on a Debian/Ubuntu installation.Steven Bromley
It should probably be more clear that installing Jenkins is going to replace any current installations of Hudson you have on a box.
Barry Warsaw
Ubuntu 11.10 (Oneiric) has Jenkins 1.409.1 afaict. sudo apt-get install jenkins jenkins-cli should get you the basics (do aptitude search jenkins for the full suite of packages). sudo service jenkins start should start the server by default on localhost:8080.
Ed Young
I have jenkins conflicting with tomcat because both run on port 8080.
I've just upgraded to 11.10 and installed tomcat7 (port 8080 default) and then jenkins as a standalone. Both done using synaptic.
jenkins fails with a port already in use exception, so I need to reconfigure it so it's on a different port. What's the best way to do this?
The section above entitled:
Setting up an Apache Proxy for port 80 -> 8080
If I follow that, it appears that jenkins will still be on port 8080, and that will conflict with tomcat.
I'm only starting to be familiar with how Ubuntu installs tomcat and jenkins. What's the best way to change the port of either tomcat or jenkins from 8080 so they don't conflict?
Ed Young
Where can I find the configuration file to change the port where jenkins runs?
the instructions above indicate that
/etc/default/jenkins
will capture configuration parameters for the launch.After installation using synaptic on 11.10, there is no /etc/default/jenkins file.
Benny Chew
Just installed using Aptitude (v1.460) on Ubuntu 11.10, the line in /etc/default/jenkins to change would be the following:
Chin Fang
Why in the current Ubuntu package, 1.484, the group for the 'jenkins' user is set to 'nogroup'? The group in the corresponding RPM is set to 'jenkins' however. Admitted this is not a fatal inconsistency, but an inconsistency nevertheless?
Anton Trapp
On debian squeeze one of the latest updates does something very ugly... - running system - aptitude update - now this:
Dmitry Sheiko
On dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/jenkins_1.539_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
On Ubuntu 12.04.3 LTS on any attempt to install jenkins
sudo apt-get install jenkins
sudo apt-get install -f jenkins
it ends up with the error:
...
dpkg: error processing /var/cache/apt/archives/jenkins_1.539_all.deb (--unpack):
trying to overwrite '/usr/share/jenkins/jenkins.war', which is also in package jenkins-common 1.424.6+dfsg-1ubuntu0.2
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/jenkins_1.539_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
P.S. I tried to install some old version
apt-get install jenkins=1.424.6+dfsg-1ubuntu0.2
and it worked fine
Michael Kryzhanovsky
Installing under apache has some caveats. In my case I wanted Jenkins to respond to a subomain, e.g. ci.myhost.com. In this case the config should be as follows:
Note, that nocanon and NoDecode are important.
A simple tool comes with Jenkins to test your proxy configuration, so you can check if everything works correctly as follows:
curl -iL http://ci.myhost.com/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/test
Allen McIntosh
Above didn't work for me unfortunately. Ubuntu 14.04, followed the instructions down to apt-get install. I changed the port number to 8888. ps shows that jenkins is running:
/usr/bin/java -Djava.awt.headless=true -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8888 --ajp13Port=-1
but there is no response when I try to connect to port 8888. The log looks clean except for the "NO JSP support" message:
Running from: /usr/share/jenkins/jenkins.war
Mar 10, 2015 5:07:55 PM winstone.Logger logInternal
INFO: Beginning extraction from war file
Mar 10, 2015 5:07:55 PM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: jetty-winstone-2.8
Mar 10, 2015 5:07:57 PM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: NO JSP Support for , did not find org.apache.jasper.servlet.JspServlet
Jenkins home directory: /var/lib/jenkins found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
Mar 10, 2015 5:07:58 PM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Started SelectChannelConnector@0.0.0.0:8888
Mar 10, 2015 5:07:58 PM winstone.Logger logInternal
INFO: Winstone Servlet Engine v2.0 running: controlPort=disabled
...
When my browser tries to connect to port 8888, wireshark shows an HTTP GET being sent, and that is all.
Where do I go from here?
Jonathan Dill
With newer Ubuntu 15.04 where 'sh' resolves to 'dash' instead of 'bash' I had to use this command:
Abhimanyu Singh
Hi,
Can anyone tell me what is the minimum java version required for Jenkins 2.x version.
Do we need to update java to 1.8 or 1.7 will be fine. I installed it on debian 7 with java 1.7 and jenkins service is not starting.
Thanks,
Kalyan Sarkar
Hi ,
After this getting below error .
Err:6 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 Release.gpg
The following signatures were invalid: KEYEXPIRED 1507497109
Hit:10 http://gb.archive.ubuntu.com/ubuntu xenial InRelease
Get:11 http://gb.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Ign:12 http://pkg.jenkins.io/debian-stable binary/ InRelease
Hit:13 http://pkg.jenkins.io/debian-stable binary/ Release
Get:14 http://gb.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Ign:16 https://dl.bintray.com/pcp/xenial xenial InRelease
Get:17 https://dl.bintray.com/pcp/xenial xenial Release [1,840 B]
Hit:17 https://dl.bintray.com/pcp/xenial xenial Release
Fetched 311 kB in 2s (141 kB/s)
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 Release: The following signatures were invalid: KEYEXPIRED 1507497109
W: Failed to fetch http://repo.mongodb.org/apt/ubuntu/dists/xenial/mongodb-org/3.2/Release.gpg The following signatures were invalid: KEYEXPIRED 1507497109
W: Some index files failed to download. They have been ignored, or old ones used instead.
Thanks
Kalyan Sarkar
Michael Crusoe
That's an error with your MongoDB apt source, not Jenkins. Looks like https://docs.mongodb.com/v3.2/tutorial/install-mongodb-on-debian/#import-the-public-key-used-by-the-package-management-system may help you.
Ma Gang
Hi,
I met one issue.
Background:
I want to switch jenkins from http to https.
So I updated parameter HTTP_PORT from 8080 to 8443 in file /etc/default/jenkins. and updated related configuration.
then restart jenkins, but finally port 8080 and port 8443 are listening at the same time at the same process!
So strange!
root@gang-virtual-machine:/var/lib/jenkins# netstat -anp |grep 8080
tcp6 0 0 :::8080 :::* LISTEN 25690/java
root@gang-virtual-machine:/var/lib/jenkins# netstat -anp |grep 8443
tcp6 0 0 :::8443 :::* LISTEN 25690/java
I checked the log, it shows:
Jul 30, 2018 2:43:16 PM org.eclipse.jetty.server.handler.ContextHandler doStart
INFO: Started w.@c05fddc{/,file:///var/cache/jenkins/war/,AVAILABLE}{/var/cache/jenkins/war}
Jul 30, 2018 2:43:16 PM org.eclipse.jetty.server.AbstractConnector doStart
INFO: Started ServerConnector@5c86a017{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
Jul 30, 2018 2:43:16 PM org.eclipse.jetty.util.ssl.SslContextFactory load
INFO: x509=X509@1b919693(hudson,h=[],w=[]) for SslContextFactory@7fb4f2a9[provider=null,keyStore=null,trustStore=null]
Jul 30, 2018 2:43:16 PM org.eclipse.jetty.server.AbstractConnector doStart
INFO: Started ServerConnector@5167f57d{SSL,[ssl, http/1.1]}{0.0.0.0:8443}
is that correct?
can anybody help with this?Thanks!
Br.
Michael