What is Jenkins? π€
Jenkins is like a magical wand πͺ for developers! It's an open-source tool written in Java β that dances to the rhythm of Continuous Integration and Continuous Delivery π. Think of it as a DevOps genie π§ that automates tasks. Jenkins helps make building, testing, and deploying software a breeze π¬οΈ for all the devs out there. It's like having a helpful robot buddy in your coding adventure.
Jenkins is your trusty sidekick that speaks Java π. With its superpowers, it weaves CI/CD workflows called pipelines π οΈ. These pipelines are like well-choreographed dance routines for your code. π©° Just like adding toppings to a pizza π, Jenkins uses plugins to mix and match DevOps tools. Need to work with Git, Maven, Amazon EC2, or other cool stuff? π οΈπ Plugins got you covered!
Imagine being a bit lazy π΄ and letting technology do the heavy lifting. Jenkins is your tech butler π€. No more babysitting jobs! It takes care of completing one job and gracefully moving on to the next, all on its own. Isn't that awesome?
Curious about how to get started with this tech wizardry? Here's a spell for creating a Jenkins freestyle project: πͺ
Enter Jenkins and find the main dashboard π₯οΈ.
Spot the "New Item" button in the sidebar and give it a tap π.
Whisper a name for your project, pick "Freestyle project" as the job style, and hit "OK" π.
On the project setup page, choose source code management, set up triggers, create a comfy build environment, and define build steps. It's like decorating your project headquarters! π°
In the build step, you can tell Jenkins the cool tasks you want it to do. Think of it like giving your robot buddy a to-do list ποΈ.
Once everything's set, chant "Save" and your project will come to life! π
Ready to see the magic happen? Click "Build Now" and watch Jenkins do its thing β¨.
Now you've got the power of Jenkins in your hands! π Let it automate, simplify, and sparkle up your coding journey. ππ
2. Create a freestyle pipeline to print "Hello World!!
Steps:
Install Jenkins on AWS EC2 Ubuntu instance.
For Jenkins used port 8080, browse instance-public-IP/8080 it will open the Jenkins dashboard.
Click on the "New Item" button on the left sidebar.
Note: By now Jenkins should be installed on your machine(as it was a part of previous tasks, if not follow Installation Guide)
Step 1: Log into the EC2 instance. After logging in to the EC2 instance update the server as. First, we will update the system
Step 2: Install Java
sudo apt install openjdk-11-jre
step 3: Copy the curl command to install Jenkins
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ https://pkg.jenkins.io/debian binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null
And then we will update the server using the get update command
step 4: Install Jenkins using the command
step 5: Let's start Jenkins, before that open port 8080 on AWS in security groups as Jenkins listen to port 8080
First, we will enable Jenkins, then we will start Jenkins and then we will see the status of Jenkins
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
After this copy-paste the public address URL you will see Jenkins home screen as
- Now to login into Jenkins we need an admin password to get that copy paste the path and execute in your server as
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Once you login inyo jenkins click on Install suggested Plugins as will install the plugins
- After installation, it will ask you to add an admin user as add your details and continue
After setting up we will be redirected to Jenkins's home screen
Now let us create the pipeline for Hello World in Jenkins
Click on the "New Item" button on the sidebar
- Give your project a name, select "Freestyle project" as the job type, and click on the "OK" button
- In the build section, we have an option βExecute Shellβ by which we can write some commands or code:
6. In the command field, enter the command to print "Hello World", such as echo "Hello World!!".
7. Click on the "Save" button at the bottom of the page to create the project.
8. Once the project is created, click on the "Build Now" link to run the project.
You can now see changes in the Console output