How to Install Jenkins on your Ubuntu server
Leave a comment on How to Install Jenkins on your Ubuntu server
What is CI/CD?
CI/CD stands for Continuous Integration and Continuous Deployment/Delivery. It’s a set of DevOps and software development concepts and procedures meant to automate and optimize the process of creating, testing, and launching apps. CI/CD is essential for modern software development practices because it improves speed, quality, reliability, and collaboration, enabling organizations to deliver software faster, more frequently, and with higher confidence in its stability and performance.
Benefits
- Automation and Efficiency: Code modifications to deployment are all automated with CI/CD pipelines. By decreasing the amount of manual labor required for developing, testing, and deploying software, this automation boosts productivity and quickens the release cycle.
- Faster Time to Market: CI/CD pipelines speed up the delivery of features and problem fixes to customers by automating builds, tests, and deployments. In competitive markets where time-to-market can play a big role, this rapid deployment capacity is essential.
- Early Detection of Issues: By ensuring that code updates are merged on a regular basis, continuous integration sets off automated tests that find flaws and integration issues early in the development cycle. Because of this, developers may address problems earlier and reduce cost and time by fixing errors earlier in the process.
- Scalability and Flexibility: CI/CD pipelines are scalable and flexible, and can be applied to a range of development and deployment scenarios. From modest projects to large-scale, sophisticated systems, they can handle a variety of applications and environments, allowing agile development methods and continuous improvement.
- Scalability and Flexibility: CI/CD pipelines are scalable and flexible, and can be applied to a range of development and deployment scenarios. From modest projects to large-scale, sophisticated systems, they can handle a variety of applications and environments, allowing agile development methods and continuous improvement.
- Consistency and Reliability: Every code update is made sure to be properly tested in a consistent environment by automated testing and deployment processes. This improves software release reliability and lowers the possibility of human error.
Popular CI/CD tools
- Jenkins
- GitLab CI/CD
- CircleCI
- Travis CI
- GitHub Actions
- TeamCity
- Azure DevOps (formerly VSTS)
- Bamboo
- Buddy
- Google Cloud Platform
- AWS CodePipeline
What is Jenkins?
Jenkins is a popular open-source automation server used to build pipelines for continuous delivery (CD) and continuous integration (CI). It’s one of the most widely used tools in the DevOps ecosystem for automating various stages of the software development lifecycle, from building and testing to deploying applications.
Benefits of Jenkins
The benefits of Jenkins can be summarized across several key areas in software development and DevOps practices:
- Automation: Jenkins reduces manual labor and speeds up the delivery of updates and new features by automating the software application development, testing, and deployment processes.
- Continuous Integration (CI): Jenkins facilitates CI by automatically starting builds and tests each time a modification to the code is pushed to version control. This guarantees early detection of integration problems, which improves code quality and speeds up feedback loops.
- Continuous Delivery (CD): Jenkins makes continuous delivery easier by automating the deployment of apps to different environments, such as production and staging. This guarantees that end users receive software changes in a timely and dependable manner.
- Pipeline as Code: With Jenkins Pipeline, teams may use a Groovy-based DSL (Domain-Specific Language) to design their CI/CD pipelines as code. By encouraging code review, versioning, and automated testing of pipeline configurations, this method improves the transparency, repeatability, and manageability of pipelines.
- Extensibility: A large ecosystem of plugins is available for Jenkins, expanding its basic features. To provide flexibility and customization choices, these plugins integrate Jenkins with a variety of tools and technologies, including cloud platforms, testing frameworks, build tools, and version control systems.
- Scalability: Jenkins can grow horizontally by dividing workloads among several nodes or agents and supports distributed builds. Jenkins’s scalability guarantees that it can effectively manage large-scale projects and concurrent executions, catering to the requirements of expanding teams and intricate applications.
- Adaptability: Jenkins is quite flexible and can work with a wide range of technology stacks and development environments. Jenkins may be customized to meet a variety of use cases and objectives, regardless of whether you’re creating microservices, mobile apps, or online applications.
- Cost-Effectiveness: Jenkins is less expensive than commercial CI/CD systems because it is free to use and open-source. Additionally, it allows for both on-premises and cloud deployment, giving it flexibility to accommodate various infrastructure configurations and financial limitations.
Now let’s see how to install Jenkins on your Ubuntu server
Step 1
Update the system package repository using the commands:
sudo apt update -y
sudo apt upgrade -y
Step 2
Install Java if it is not installed on your server.
For that, check the Java version using the command java –version . If Java is already installed, this command will show the current installed Java version. If not, the output will be like:
So we need to install Java first. For that, use the following command to install Java: sudo apt install openjdk-11-jdk -y
Now check the Java version
Step 3
Now let’s add the Jenkins repository using;
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
Add the authentication key and the Jenkins repository to the source list by:
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]
https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
Step 4
We can now install, start, and enable Jenkins.
Update the package lists again:
sudo apt update
And install Jenkins using:
sudo apt install jenkins -y
We have just installed Jenkins. Then need to start and enable it using:
sudo systemctl start jenkins && sudo systemctl enable jenkins
To check the whether the Jenkins started properly and enabled use the command; sudo systemctl status jenkins
Step 5
Modify the firewall:
Since Jenkins uses port 8080, Open up the firewall for that port using: sudo ufw allow 8080
Check the status of the firewall using
sudo ufw status
If the status is showing as inactive, enable it using the command:
Step 6
Jenkins setup
Access the Jenkins set-up page by using:
http://server_IP_or_domain:8080
If you are locally running Jenkins use
http://localhost:8080
Then this page will appear
The password can be obtained from /var/lib/jenkins/secrets/initialAdminPassword View the password using:
cat /var/lib/jenkins/secrets/initialAdminPassword
This will direct you to a customization page. From there, you can either choose to install the suggested plugins or select plugins to install. Here we are choosing Install suggested plugins, which will start the installation process.
Now create the first admin user
Once this is complete, you will receive the instance configuration page. You will have to enter the preferred Jenkins URL. Then press Save and Finish.
So the configuration is now complete, and you will see a page saying Jenkins is ready!. Press start using Jenkins.
When you select “Start using Jenkins,” the administrator dashboard will open.
Conclusion
To sum up, setting up Jenkins on your Ubuntu server is a simple procedure that gives teams and developers access to strong automation features. You can easily set up Jenkins to manage your pipelines for continuous integration and delivery by following the instructions in this guide. Jenkins offers a strong framework for improving software development processes, regardless of experience level with automation, making it ideal for both novice and seasoned DevOps engineers. Utilize Jenkins’ broad ecosystem of plugins and configurable processes to expedite project delivery, enhance code quality, and simplify your development lifecycle. Accept Jenkins’ ability to revolutionize the way you develop, test, and release software, ultimately leading to a more effective and fruitful development environment.