what is Jenkins?
Jenkins is an open-source automation server that is widely used for building, deploying and automating software development and IT operation tasks. It is written in Java so it works or runs on Java.
Jenkins is an open-source continuous integration, continuous delivery and deployment (CI/CD) automation software DevOps tool. It is used to implement CI/CD workflows, called pipelines. It manages and controls several stages of the software delivery process, including build, documentation, automated testing, packaging, and static code analysis. Jenkins is a highly popular DevOps tool used by thousands of development teams.
Jenkins achieves Continuous Integration with the help of plugins. Plugins allow the integration of Various DevOps stages. If you want to integrate a particular tool, you need to install the plugins for that tool. For example Git, Maven 2 project, Amazon EC2, HTML publisher etc.
Jenkins supports various version control tools such as Git, SVN, CVS, etc., and can execute different types of projects such as Ant, Maven, Gradle, etc. as well as arbitrary shell scripts and Windows batch commands.
Jenkins Core Concepts
Jenkins Controller (Formerly Master)
The Jenkins architecture supports distributed builds. One Jenkins node functions as the organizer called a Jenkins Controller. This node manages other nodes running the Jenkins Agent. It can also execute builds, although it isn’t as scalable as Jenkins agents.
The controller holds the central Jenkins configuration. It manages agents and their connections, loads plugins, and coordinates project flow.
Jenkins Agent (Formerly Slave)
The Jenkins Agent connects to the Jenkins Controller to run build jobs. To run it, you’ll need to install Java on a physical machine, virtual machine, cloud compute instance, Docker image, or Kubernetes cluster.
You can use multiple Jenkins Agents to balance build load, improve performance, and create a secure environment independent of the Controller.
How to create a freestyle pipeline to print "Hello World!!**
A freestyle pipeline is a type of build job in Jenkins that allows us to configure any build job using a graphical user interface. It is flexible and easy to use for beginners.
To create a simple freestyle pipeline that prints Hello World in Jenkins, follow these steps:
Open your Jenkins dashboard and click on New Item
Enter a name for your pipeline (e.g., Hello World) and select Freestyle project. Then click OK.
On the configuration page, you can add some description for your pipeline if you want.
Under Source Code Management, select None since we are not using any version control tool for this pipeline.
Under Build Triggers, you can choose when you want your pipeline to run automatically. For example, you can select Build periodically and enter a cron expression (e.g.,
* * * * *
) to run your pipeline every minute. For this example, we will leave this section blank and run our pipeline manually.Under Build step, click on the Add build step and select Execute shell (or Execute Windows batch command if you are using Windows). This will allow us to run any shell or batch command as part of our pipeline.
Now, go back to your Jenkins dashboard and click on your pipeline name (e.g., Hello World). Then click on Build Now to run your pipeline.
You will see a new build number appear under Build History with a blue ball indicating that the build is in progress. You can click on it to see the details of the build.
Click on Console Output to see the logs of the build. You should see something like this:
Congratulations! You have successfully created and run a simple freestyle pipeline that prints Hello World in Jenkins.
I hope this blog post helps you understand the basics of Jenkins and how to create a simple freestyle pipeline.
In the next blog post, I will show you how to create more complex pipelines using different types of projects and plugins.
If you have any questions or feedback, please feel free to contact me on:
- LinkedIn: www.linkedin.com/in/avanishsinghnitap
Thank You for reading this article.