- Install Docker
- Clone repository from GitHub
- Download and start up Jenkins
- Add new project “PULLCODE” to connect to GitHub repository
- Add new project “BUILD” to build project with Maven
- Run MariaDB and test BUILD
- Part III: Install and create Build Pipeline
- Part III: Install JaCoCo to check for test coverage
- Part III: Install Build Monitor View and schedule run interval
1. Add new project “PULLCODE”
Create new item.
Name your project “PULLCODE” and select Freestyle project. Click OK to create.
Now, we will connect this project to our GitHub repository. But before you can do that you need to install the Git plugin first. Click Back to Dashboard
Click Manage Jenkins
Click Manage Plugins
Go to tab Available and search for GitHub Plugin. Select it and Click Install without restart.
Wait until the all processes are completed.
Restart Jenkins by going to http://localhost:8080/restart and click Yes.
Wait until you get back to the first screen. Go back to project PULLCODE’s config.
In the section Source Code Management, select Git and input your repository URL. In the field Credential, click Add → Jenkins.
Input Username and Password of your GitHub account and name your credential in the Description field as your reminder. Click Add.
Select credential with the one you’ve just added and then click Save.
Test your project by clicking Build Now.
A new item appears in the Build History. Click on small triangle icon to expand the menu.
Select Console Output
You should see the build is finished successfully. Please note the PULLCODE’s workspace location.
2. Add new project “BUILD”
Add another Freestyle project “BUILD”.
In the project config, click Advance… in the Advanced Project Options.
Choose Use custom workspace and input PULLCODE’s workspace location. Click Save.
Go to Manage Jenkins → Configure System.
In JDK section, click Add JDK.
Uncheck Install automatically, name your JDK installation, and input
/usr/lib/jvm/java-8-openjdk-amd64 in JAVA_HOME field. (In case you don’t use Docker, put your local JDK directory here e.g.
Move down to Maven section, click Add Maven…
Select Install automatically and Name your Maven installation. Click Save.
Go back to the project BUILD’s config and go down to the Build section, click Add build step and select Invoke top-level Maven targets.
Select Marven Version with the one you’ve just created and input
clean install in the Goals field. Click Save.
Build the project and wait until it finishes. Your build should end in failure.
If you go up and analyze your build log, you will see the failure because it could not connect to the database MariaDB.
3. Install MariaDB and test BUILD
Note: If you use this alternative repository, you don’t need MariaDB.
In your windows command line, put
docker run -d — name mariadb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -e MYSQL_DATABASE=for_test mariadb:10.1.17and press enter. This will pull MariaDB version 10.1.17 and run it automatically.
docker ps to display all containers. You should see 2 containers are running now including the mariadb.
Check if the database is created properly by using command
docker exec -it mariadb mysql -u root -p”123456" and then followed by
show databases;and you will see something like this:
If you use Docker, you need to perform the following steps to point JDBC connection to the Maria DB container you’ve created.
- Check Maria DB container you’ve just created by using command
docker inspect mariadband note the IP address in the line like:
- Go to your working directory and edit the file application.properties in folder
localhostwith the Maria DB’s IP Adrress from step 1 and Save
- Repeat the same steps with the same file name in folder
- Use these commands to push your changes to your remote Git repository.
git add .
git commit -m "Updated MariaDB host"
- Rebuild the project PULLCODE
Now, you are ready to go. Rebuild the project BUILD and you should get a successful build.
Originally published at pacroy.blogspot.com on December 25, 2016.