How to Create Your First simple Jenkins Pipeline

In our first Jenkins tutorial for beginners, we focused on how to install and configure Jenkins. In this tutorial, How To Create Your First simple Jenkins Pipeline. We’ll keep it simple and avoid Maven or Git at this juncture. We’ll just create a Jenkins freestyle job that invokes the JDK’s runtime instance and prints out the version of the JRE that is currently running in the Jenkins machine (location of Jenkins installation).

STEP: 1 Login into Jenkins and go to Jenkins dashboard

To create a Jenkins freestyle job, log on to your Jenkins dashboard by visiting your Jenkins installation path. Usually, it will be hosted on localhost at http://localhost:8080 If you have installed Jenkins in another path, use the appropriate URL to access your dashboard as shown in the below Jenkins job creation example.

STEP: 2 Create New Item (New job/pipeline)

The first step to creating a Jenkins build job is to click the New Item link in the top left-hand corner of the admin console and enter the Item name & click Ok.

Note: If you are unable to see this icon, it means that you don’t have sufficient privileges. In the next window, type the name of the job such as the first job, select job type as freestyle job, and then click ok:

STEP 3: Configure the new job details

After clicking OK ( in STEP 3), the configuration page for the freestyle Jenkins job will appear as shown in the below snapshot. Notice there are a number of options to configure, including build triggers, source code management options, Jenkins build job steps, and post-build actions. As we mentioned in starting of the post, we are only going to create simple jobs without doing any build or deployment.

In the Jenkins build job, we will change the description to “My_First_JenkinsJob” and Under the “Source Code Management” section, for this example, we are not going to use any GIT URL to download the solution so you can select “None”

In this job/pipeline, we going the check the java version that was installed in our local/Jenkins machine. For this, in the “Build section” choose “Execute Windows batch command” from the drop-down and type the “java -version” in the window batch command section.

STEP 4: Save the job and click on the Build Now link.

Now your Jenkins Job is ready for checking the version of Java installed on the Jenkins machine.

STEP 5: Save the job, click on the Build icon & Check the status.

To run the created job, click on the job which you need to build. Once the new job is opened as shown in the below snapshot, click the “Build Now” to start the job execution. You can check the build status under the “Build History section” at the left bottom of the screen.

STEP 6: View the log for checking the output

In the window batch command, we placed the cmd to check the version of java.  So the same has been executed and you can able to see the output in the log file as shown in the below image.

Based on this simple example, I now hope you can able to Create Your First simple Jenkins Pipeline.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.