Jenkins is the most popular CI/CD server. There you create jobs that are triggered by some events (changed in a code repository, manually, etc). Those events invokes the steps like compiling to see if you can generate the executable. Then you run tests (unit tests) to confirm the desired behaviour at low-level. After the integration stage passes, you can build the executable to deliver them to a working environment.
Step 1: Install & start Docker container. If the image is not already available it will be downloaded from “Docker Hub”, i.e. https://hub.docker.com/ where you can search for the image “jenkins”.
1 2 3 4 |
[arulkumarankumaraswamipillai@MacBook-Pro-2:~]$ docker run --name my_jenkins -d \ -p 8080:8080 -p 50000:50000 \ -v /Users/arulkumarankumaraswamipillai/Desktop/jenkins_home:/var/jenkins_home \ jenkins/jenkins:lts |
Step 2: Get into the container and check for “/var/jenkins_home/secrets/initialAdminPassword”
1 2 3 4 5 6 7 8 9 10 |
[arulkumarankumaraswamipillai@MacBook-Pro-2:~]$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c8a23dd1e443 jenkins/jenkins "/sbin/tini -- /usr/…" 4 minutes ago Up 4 minutes 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp my_jenkins [arulkumarankumaraswamipillai@MacBook-Pro-2:~]$ docker exec -it c8a23dd1e443 /bin/bash jenkins@c8a23dd1e443:/$ |
Show the password:
1 |
jenkins@c8a23dd1e443:/$ cat /var/jenkins_home/secrets/initialAdminPassword |
Copy and paste the password on the Web UI in the next step.
Step 3: Open the Jenkins Web UI and paste password from last step.
1 |
http://localhost:8080/ |
Step 4: Install the suggested packages.
Step 5: Create an admin user with a password in the ensuing screens, and then you are ready to use Jenkins as shown below.
Step 6: Click on “New Item” menu within Jenkins, and type “test” and select “Freestyle project“.
Step 7: Go to the “Build” tab and in “Add build step” list select “Execute shell“.
Step 8: Enter some shell commands & click “save“.
Step 9: Click on the “Build Now” to build the project.
Step 10: Click on the build number as in “#4”, and the select “Console Output“.
Step 11: Get yourself familiarised by clicking on the “Configure” and playing around with various things.
What is next?
02: Getting started with Jenkins Multibranch pipeline on Docker tutorial. Most industrial applications will be using this as there will be many branches.