Table of contents
Jenkins
Jenkins is an open-source CI/CD(Continuous Integration and Continuous Delivery/Deployment) tool written in Java programming language that helps automate software development and DevOps processes.
Let's assume a developer has written a code and kept it in Git. The code is taken from Git and built using Docker. The code is then tested and if it passes it means the final code is ready for deployment. This complete process is called Continuous Integration. Finally, the code is deployed to the desired server like EC2. When this whole process is automated, it is called continuous deployment. Whereas, if the user manually clicks on a button to do the deployment, it is called delivery. Deployment is done as soon as any changes to the code are done whereas delivery is done when the user wants it.
Installation of Jenkins
Jenkins requires Java in order to run. There are multiple Java implementations that you can use. OpenJDK is the most popular one.
Update the Debian apt repositories, install OpenJDK 17, and check the installation with the below commands:
sudo apt update
sudo apt install openjdk-17-jre
java -version
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment (build 17.0.7+7-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.7+7-Debian-1deb11u1, mixed mode, sharing)
Use the below command to install Jenkins from debian-stable apt repository:
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.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-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
Here, curl -fsSL is used to hit the given url securely and store in /dev/null path. Jenkins always run on port number 8080. Add inbound rules of 8080 in security groups of your instance. Now, open the ip address and add :8080 to it and you will be able to access Jenkins.
Now, a screen will appear which will ask to install suggested plugins. Click on Install suggested plugins and it will install the plugins.
Once Jenkins is ready and we click on Start using Jenkins, the below screen will appear -
Create a freestyle pipeline to print "Hello World!!
Step 1: Click on New Item present in left hand side of the screen. The below page opens up. Enter your project name, select Freestyle Project and click on OK.
Step 2: Enter a description of the Project.
Step 3: Select Source Code Management as None since we do not have any.
Step 4: After this, if you want to give some triggers then you can choose accordingly as Jenkins provides us with scheduled triggers
Step 5: In the build section we have an option ‘Execute shell’ where can write some commands or code.
Step 6: Now, you can give the command according to your need.
Step 7: Select Execute Windows batch command and enter the command.
Then click apply and save. So, your job is created.
Step 8: Now, once the job is created, the below screen opens up. Click on Build Now on left hand side of the screen.
Once the build is successful, you will be able to see a blue color tick in the Build History column present on the left hand side of the screen. Click on the hyperlink of the build and select console output to check the output status. We can see the successful build in Console Output with "Hello World" printed.
Finally, we have created and successfully executed a freestyle project.
Thanks for reading my blog!
Happy Learning!
~Shilpi