Getting started with Jenkins
- No Comments
I use Jenkins quite a lot, for almost everything in my daily work. Not to mention the CI/CD part. I achieve regular deployment with Jenkins. Daily backup and weekly cleanup from Jenkins. Vulnerability scanning from Jenkins. Workflow enforcement with Jenkins. And the list goes on and on.
But just several years ago, Jenkins (as Hudson, its old name) wasn’t that well-known. And now? It is almost everywhere. Jenkins is just so important! So answer me: Why is that?
There are five reason for that:
Lowers the Effort of Converting CLI to GUI
The Pipeline Integrates Individual Jobs for a Bigger Purpose
Keeps People in Sync, Especially in Slack
Project Management Now Has More Accurate Data Support
Quick History In mid-2006 or 2007, Kohsuke Kawaguchi founded the project called Hudson. At that time he was working to Sun Microsystems. In a very brief manner, after Sun has been bought by Oracle a little turbulence happened in the community. The end of this history was a fork of the project to GitHub. Previously it was hosted at java.net. This process motivated a project naming change from Hudson to Jenkins, due to Hudson’s naming rights. So if you are searching for Jenkins don’t get surprised if you meet Hudson information.
Nowadays, the Hudson project still exists but in a corporate way and not so active. On the other hand, Jenkins is on fire with a high community acceptance and many great features always coming.
One of the key committers of the project is CloudBees. They provide an enterprise version of Jenkins with commercial support. And as Chief Technology Officer (CTO) they have Kohsuke, wise choice.
What is jenkins?
Jenkins is an extensible, open source continuous integration server. It builds and tests your software continuously and monitors the execution and status of remote jobs, making it easier for team members and users to regularly obtain the latest stable code.
What is Continuous Integration(CI) ?
Continuous Integration(CI) is a continuous process of of merging new code into the centralized repository. You can easily find the issues if there are any. The static code checking is perform in this process to catch the bugs earlier. The unit test plays the important role in this process to validate the code merge into the centralized repository. It is best practice to have a build server designed specifically for performing these tests so your development team can continue merging requests even while tests are being performed.
“Continuous Integration(CI) doesn’t get rid of bugs, but it does make them dramatically easier to find and remove” — Martin Fowler, Chief Scientist, ThoughtWorks.
What is continuous deployment?
Continuous deployment is a strategy for software releases wherein any code commit that passes the automated testing phase is automatically released into the production environment, making changes that are visible to the software’s users.
To install Jenkins on your CentOS system, follow the steps below: 1. Jenkins is a Java application, so the first step is to install Java. Run the following command to install the OpenJDK 8 package:
sudo yum install java-1.8.0-openjdk-devel
2. The next step is to enable the Jenkins repository. To do that, import the GPG key using the following curl command:
curl –silent –location http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo | sudo tee /etc/yum.repos.d/jenkins.repo
3. And add the repository to your system with:
sudo rpm –import https://jenkins-ci.org/redhat/jenkins-ci.org.key
4. Once the repository is enabled, install the latest stable version of Jenkins by typing:
sudo yum install jenkins
5. After the installation process is completed, start the Jenkins service with:
sudo systemctl start jenkins
6. To check whether it started successfully run:
systemctl status jenkins
Finally enable the Jenkins service to start on system boot. sudo systemctl enable jenkins
Adjust the Firewall
If you are installing Jenkins on a remote CentOS server that is protected by a firewall you need to port 8080
Use the following commands to open the necessary port:
sudo firewall-cmd –permanent –zone=public –add-port=8080/tcp sudo firewall-cmd –reload
Setting Up Jenkins
To set up your new Jenkins installation, open your browser and type your domain or IP address followed by port 8080
A screen similar to the following will appear, prompting you to enter the Administrator password that is created during the installation:
Use the following command to print the password on your terminal:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
You should see a 32-character long alphanumeric password as shown below:
Copy the password from your terminal, paste it into the Administrator password field and click Continue.
On the next screen, you will be asked whether you want to install the suggested plugins or to select specific plugins. Click on the Install suggested plugins box, and the installation process will start immediately.
Once the installation is complete, you will be prompted to set up the first administrative user. Fill out all required information and click Save and Continue.
On the next page, you will be asked to set the URL for the Jenkins instance. The URL field will be populated with an automatically generated URL.
To complete the setup confirm the URL by clicking on the Save and Finish button.
Finally, click on the Start using Jenkins button and you will be redirected to the Jenkins dashboard logged in as the admin user you have created in one of the previous steps.