Test Drive Jenkins using Docker — Part I
Jenkins is now popular these days as a continuous integration and continuous delivery tool to automate software development process to achieve DevOps objectives. I have a chance to see a demo during the Test-Driven Development training last week at IMC Institue by K.Somkiat Puisungnoen (www.somkiat.cc)
Here I have listed instructions I tried on Windows 10 that you can follow if you are new to Jenkins and want to see what it can do. Thank you very much to Nont who spent an hour to help me setting Jenkins up.
PS: I’m not the expert but just tried this out for the first time so your comments and suggestions will be very appreciated.
- 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. Install Docker
- To avoid touching your Windows system, we will use Docker as a container for this demo.
- To learn about what Docker is. Click here.
- To download Docker for Windows. Click here.
- To learn how to install Docker on Windows. Click here.
- To learn how to get started with Docker. Click here.
After you have installed Docker, you may test it by typing this into Windows command line: docker version and you should see something like this:
2. Clone repository from GitHub
Download Git Client from here and install it.
Extract ZIP file to a folder and command prompt there (here is your working directory). Use command
git init to create a new Git repository.
git add . to add files to Git staging area.
git commit -m "Initial Commit" to commit files to your Git repository.
Log in to your GitHub account (Sign up if you don’t have an account) and create a new repository.
Give a name to your new repository and click Create.
Now you’ve got a blank repository. Please note your repository URL.
Go back to your command prompt and use command
git remote add origin <your Git repository URL>
Then use command
git push --set-upstream origin master to push files to your Git repository on GitHub.
Now, if you go back to your GitHub you should see files in your own repository like this:
3. Download and Start up Jenkins
Use command docker pull jenkins:1.651.3 to download Jenkins Docker image version 1.651.3 (You may use the newer or latest version but I’ll use this version which I’m familiar with).
If you want to install locally without using Docker, you can download the war file here. You can find the older version by the link below.
Once your pull is done, use command docker images then you should see the image is now available on your local.
Start up a new Jenkins container by using command docker run -d — name jenkinsdemo -p 8080:8080 jenkins:1.651.3
If you install Jenkins locally you can start it up by using command java -jar “jenkins v1.651.3.war”
Check your container’s log by command docker logs jenkinsdemo and look for the line:
This tells your Jenkins is ready to use.
Open Jenkins with web browser at http://localhost:8080/ and you should see the dashboard like this.
Originally published at pacroy.blogspot.com on December 24, 2016.