Im Durchschnitt wird dieses Tutorial Install Jenkins on Debian 9 mit 5 bewertet, wobei 1.0 die schlechteste und 5.0 die beste Bewertung ist. Es haben insgesamt 326 Besucher eine Bewertung abgegeben.
326 0

Install Jenkins on Debian 9

from gridscale Team Debian Jenkins
tutorial - how to install Jenkins on Debian

How to install Jenkins the fast and easy way

Jenkins is an open-source automation server for the automatic repetition of technical tasks involved in the continuous integration and delivery of software. In this article I will show you how to install Jenkins on the new Debian 9 and how to encrypt the connection to Jenkins using Let’s Encrypt.

Preparing the server

Jenkins offers its own web server. However, this is not encrypted. Therefore, it is a good idea to switch a reverse proxy to the Jenkins web server using Apache2.

Install an Apache2 web server before you go ahead with the encryption using Let’s Encrypt. In this article (German only), I’ll show you how to do that. Set up your web server so that requests are automatically redirected via HTTP to HTTPS.

In order to use Apache as a proxy, the corresponding extensions must still be activated. Use the following commands:

a2enmod proxy
a2enmod proxy_http
a2enmod headers

Then edit the two Apache Config files /etc/apache2/sites-available/000-default.conf und /etc/apache2/sites-available/000-default-le-ssl.conf.

The content for 000-default.conf:

<VirtualHost yourDomain.tld:80>
        ServerName yourDomain.tld
        ServerAdmin yourE-Mail-Adress
 
        ErrorLog ${APACHE_LOG_DIR}/jenkins-error.log
        CustomLog ${APACHE_LOG_DIR}/jenkins-access.log combined
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =yourDomain.tld
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>

The result should look like this:

Jenkins - prepare server - step 1

The content for 000-default-le-ssl.conf:

deineDomain.tld:443>
        ServerName yourDomain.tld
        ServerAdmin yourE-Mail-Adress
 
        ErrorLog ${APACHE_LOG_DIR}/jenkins-ssl-error.log
        CustomLog ${APACHE_LOG_DIR}/jenkins-ssl-access.log combined
 
        SSLCertificateFile /etc/letsencrypt/live/deineDomain.tld/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/deineDomain.tld/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
 
        ProxyPass         /  http://localhost:8080/ nocanon
        ProxyPassReverse  /  http://localhost:8080/
        ProxyPassReverse  /  http://yourDomain.tld
        ProxyPreserveHost On
        ProxyRequests     Off
        AllowEncodedSlashes NoDecode
 
        <Proxy http://localhost:8080/*>
          Order deny,allow
          Allow from all
        </Proxy>
 
 
</VirtualHost>
</IfModule>

The result should look like this:

Jenkins - prepare server - part 2

Then restart Apache2:

service apache2 restart

Now you can install Jenkins.

Installing Jenkins

Jenkins is not yet included in the default Debian 9 repository. Therefore, the developer repository must be activated. Execute the following commands in this order:

wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | apt-key add -
echo deb http://pkg.jenkins.io/debian-stable binary/ | tee /etc/apt/sources.list.d/jenkins.list
apt-get update

Then you can install Jenkins over apt.

apt -y install jenkins

To make Jenkins not accessible from outside via the port 8080, but only via the encrypted Apache proxy, the config of Jenkins still needs to be adjusted.

Adjusting the config

Edit the file with Nano /etc/default/jenkins

nano /etc/default/jenkins

Then add the following line to the last line:

--httpListenAddress=127.0.0.1

In the end, the result should look like this:

Jenkins - Change configuration part 1

After that restart Jenkins.

service jenkins restart

Testing the installation

Click the following link in a browser of your choice:

http://DomainOrIP:8080/

Because you have blocked access to the port from outside, this should not work.

http://DomainOderIP/

Now you should be redirected to the next page and then see Jenkins.

https://DomainOderIP/

Setting up Jenkins

If you called up Jenkins for the first time, you will be asked for a key. You can find this by using the following command in the terminal:

cat /var/lib/jenkins/secrets/initialAdminPassword

unlock jenkins

Now select the recommended packages. These should now be installed automatically:

Choose plugins

Paket installieren

Then you are asked to create a user. Make sure you use a password that is as secure as possible.

Create user

Afterwards Jenkins is finished:

Jenkins installation complete

Summary

With a little effort, Jenkins can be set up on your Debian 9 server. By using Apache2 as a reverse proxy and the free certificate from Let’s Encrypt, the connection to Jenkins is also secure and encrypted from outside.

How to install Jenkins the fast and easy way Jenkins is an open-source automation server for the automatic repetition of technical tasks involved in the continuous integration and delivery of software. In this article I will show you how to install Jenkins on the new Debian 9 and how to encrypt the connection to Jenkins using […]

Schade, dass dir der Artikel nicht gefallen hat.
Was sollten wir deiner Meinung nach besser machen?

Thank you for your feedback!
We will get back to you as soon as the article is finished.

Übrigens: kennst du schon unser Tutorial zum Thema Set up your Debian router / gateway in 10 minutes?

×

Developer?

Get the latest gridscale developer tutorials here.
And don’t worry - we won’t spam you