|
|
|
# Jenkins
|
|
|
|
You can find Jenkins at [jenkins.mphslaats.com](https://jenkins.mphslaats.com).
|
|
|
|
|
|
|
|
# Table of contents
|
|
|
|
- [Jenkins](#jenkins)
|
|
|
|
- [Table of contents](#table-of-contents)
|
|
|
|
- [Resources](#resources)
|
|
|
|
- [Ports](#ports)
|
|
|
|
- [Installation](#installation)
|
|
|
|
- [Configuration](#configuration)
|
|
|
|
- [Email bot](#email-bot)
|
|
|
|
- [Maven projects](#maven-projects)
|
|
|
|
- [Run job after commit in Gitlab](#run-job-after-commit-in-gitlab)
|
|
|
|
- [Installed plugins](#installed-plugins)
|
|
|
|
|
|
|
|
## Resources
|
|
|
|
It is [documented](https://jenkins.io/doc/book/hardware-recommendations/) that the amount of RAM and CPU cores varies depending on how intensive you are using Jenkins. Therefore I chose to go with 4 GB RAM and 2 CPU cores.
|
|
|
|
|
|
|
|
## Ports
|
|
|
|
By default Jenkins runs on port 8080, however Jenkins is a website therefore you only need to add a new server section to the Proxy server, which handles the rest.
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
* Jenkins requires Java therefore run the following `apt-get install openjdk-8-jre`;
|
|
|
|
* To [install](https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+on+Ubuntu) Jenkins we need a key, therefore we download that first by doing `wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | apt-key add -`;
|
|
|
|
* Now we need to tell the aptitude where to find the jenkins files, do this by doing `echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list`;
|
|
|
|
* Now update the system so it know about the newly added URL and install Jenkins by doing `apt-get update && apt-get install jenkins`;
|
|
|
|
* Now go to the jenkins website at your IP-address and port 8080;
|
|
|
|
* It tells you to paste the password which is in `/var/lib/jenkins/secrets/initialAdminPassword`;
|
|
|
|
* Jenkins now let's you choose which packages you want, I added Github and Gitlab;
|
|
|
|
* After installing you need to create an admin user.
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
* If you go to [jenkins.mphslaats.com/configureSecurity](https://jenkins.mphslaats.com/configureSecurity/) you can set that other users are not allowed to be an administrator by using "Project-based Matrix Authorization Strategy";
|
|
|
|
* You have to go to [jenkins.mphslaats.com/updateCenter](https://jenkins.mphslaats.com/updateCenter) to view installations of Jenkins and restart Jenkins (after installing).
|
|
|
|
|
|
|
|
### Email bot
|
|
|
|
* After you created the admin user, you could go to [jenkins.mphslaats.com/configure](https://jenkins.mphslaats.com/configure) and add an email bot:
|
|
|
|
* SMTP server: smtp.gmail.com;
|
|
|
|
* Default user e-mail suffix: @gmail;
|
|
|
|
* Use SMTP Authentication: True;
|
|
|
|
* User Name: ****@gmail.com;
|
|
|
|
* Password: ****;
|
|
|
|
* Use SSL: True;
|
|
|
|
* SMTP Port: 465;
|
|
|
|
* If Jenkins tells you that your reverse proxy setup is broken, than you have to add `proxy_set_header X-Forwarded-Proto $scheme;` to the proxy server;
|
|
|
|
|
|
|
|
### Maven projects
|
|
|
|
* Now let's add both Git and Maven to Jenkins:
|
|
|
|
* First start by manually installing them by using `apt-get install git maven openjdk-8-jdk`;
|
|
|
|
* Now use `which git` to find out where git is installed (`/usr/bin/git`);
|
|
|
|
* Use `whereis maven` to find where maven's home directory is (`/usr/share/maven`);
|
|
|
|
* Go to [jenkins.mphslaats.com/configureTools](https://jenkins.mphslaats.com/configureTools) and add the git, maven and jdk (`/usr/lib/jvm/default-java`) directories;
|
|
|
|
* To make full use of Maven go to [jenkins.mphslaats.com/pluginManager/available](https://jenkins.mphslaats.com/pluginManager/available) and add Maven Intergration;
|
|
|
|
|
|
|
|
### Run job after commit in Gitlab
|
|
|
|
* Go to [jenkins.mphslaats.com/pluginManager/available](https://jenkins.mphslaats.com/pluginManager/available) and add the GitLab Plugin;
|
|
|
|
* Now go to a Jenkins item and configure the build trigger as follows:
|
|
|
|
* Check `Build when a change is pushed to GitLab. GitLab CI Service URL: <URL>`;
|
|
|
|
* Select the proper triggers;
|
|
|
|
* Click Advanced and Generate a Secret token;
|
|
|
|
* Make sure that the administrator has enabled `requests to the local network from hooks and services` in the Administrator settings;
|
|
|
|
* Go to Settings - Integrations on Gitlab (you must be master for the project):
|
|
|
|
* Use https://jenkins.mphslaats.com/project/ <Jenkins item> as URL;
|
|
|
|
* Use the generated token from Jenkins as Secret token and add the Webhook;
|
|
|
|
* If you now push something (depending on your trigger). Jenkins will automagically run.
|
|
|
|
|
|
|
|
## Installed plugins
|
|
|
|
You can search for new plugins [here](https://plugins.jenkins.io/).
|
|
|
|
* [Maven Integration](https://plugins.jenkins.io/maven-plugin): Needed to be able to create Maven items in Jenkins;
|
|
|
|
* [Build Pipeline Plugin](https://plugins.jenkins.io/build-pipeline-plugin): Gives you the ability to make a pipeline view;
|
|
|
|
* [Green Balls](https://plugins.jenkins.io/greenballs): Makes the success balls green;
|
|
|
|
* [GitLab Plugin](https://plugins.jenkins.io/gitlab-plugin): Plugin to be able to trigger Jenkins after Gitlab push;
|
|
|
|
* [Blue Ocean Plugin](https://wiki.jenkins.io/display/JENKINS/Blue+Ocean+Plugin): For a more elegant GUI;
|
|
|
|
* [JaCoCo Plugin](https://wiki.jenkins.io/display/JENKINS/JaCoCo+Plugin): To show the test coverage. |
|
|
|
\ No newline at end of file |