Say, you wrote a project you are pretty proud of and want to show your friends. While building and installing it on your friends computer you realize that it is only runnable on your developing machine. Here continuous integration comes into play.
Before we start make sure that Java 8 and Git are installed and you have at least one project on GitLab.
First we need a build server like a Raspberry Pi 3 where we install Jenkins (Version up to writing: 2.7.1). This can be done following the official Jenkins manual for ubuntu as Raspbian is also based on Debian.
As my personal projects are hosted on GitLab, the easiest way to integrate Jenkins with GitLab is to use the official plugin. Navigate through Manage Jenkins -> Manage Plugins -> Available -> Install Git and GitLab plugins (If you use a jenkins 1.x version you might need to install the gradle plugin for your gradle projects).
Next we need to go to Manage Jenkins -> Configure System and fill out the text areas in the GitLab section.
Now go to the main page and click on New Item to create a build job. I Use a ‘Freestyle project’, choose my GitLab-Configuration, specify the git connection and invoke gradle script with following options:
If you want to trigger Jenkins on every commit or merge requests, you have to specify a WebHook in your GitLab Account. As I don’t have a static ip for my raspberry pi, I just trigger the build manually and make sure that the master branch is always stable - not just for me.
PS: I experienced errorless builds more often when using the gradle wrapper.