Install Jenkins on Debian

How to install Jenkins on Debian?

This is the Debian package repository of Jenkins to automate installation and upgrade. To use this repository, first add the key to your system:

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -

Then add the following entry in your /etc/apt/sources.list:

deb http://pkg.jenkins-ci.org/debian binary/

Update your local package index, then finally install Jenkins: 

sudo apt-get update
sudo apt-get install jenkins

Add the following config to your Nginx config, name it e.g: jenkins.yourdomain.com.conf

It will contain content like this:

upstream app_server {
    server localhost:8080 fail_timeout=0;
}
 
server {
    listen 80;
    listen [::]:80 default ipv6only=on;
    server_name jenkins.yourdomain.com;
    rewrite ^ https://$server_name$request_uri? permanent;
}
 
server {
    listen 443 default ssl;
    server_name jenkins.yourdomain.com;
 
    access_log  /var/www/logs/jenkins.yourdomain.com.access.nginx.log;
    error_log  /var/www/logs/jenkins.yourdomain.com.error.nginx.log error;
 
    ssl on;
    ssl_certificate     /etc/nginx/ssl/server.crt;
    ssl_certificate_key /etc/nginx/ssl/server.key;
 
    ssl_session_timeout 5m;
    ssl_protocols SSLv3 TLSv1;
    ssl_ciphers HIGH:!ADH:!MD5;
    ssl_prefer_server_ciphers on;
 
    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_redirect http:// https://;
 
        add_header Pragma "no-cache";
        proxy_pass http://app_server;

    }
}


Note that you also have to create a ssl key and certificate.

Now, you probably want to secure up your Jenkins.

Do this by going to: Configure Global Security.
Select enable security and choose: Jenkins’ own user database.

Important: select Allow users to sign up. This is needed to create your first user.
After you created that user, and logged in, you can update the security and deselect "Allow users to sign up".

 

Of course you will lock yourself out

Here you can undo this:

$ cd /var/lib/jenkins/
$ nano config.xml
$ set userSecurity to false: <userSecurity>false</userSecurity>Rep
$ sudo service jenkins restart