Jenkins Tutorials For Beginners — Part 05

Jenkins is a powerful application that allows continuous integration and continuous delivery of projects, regardless of the platform you are working on. It is a free source that can handle any kind of build or continuous integration. You can integrate Jenkins with a number of testing and deployment technologies. In this tutorial, we would explain how you can use Jenkins to build and test your software projects continuously.

How to Create and builds With the Jenkins FreeStyle Project

Jenkins

What is a Jenkins freestyle project?

A Jenkins project is a repeatable build job which contains steps and post-build actions. The types of actions you can perform in a build step or post-build action are quite limited. There are many standard plugins available within a Jenkins freestyle project to help you overcome this problem. They allow you to configure build triggers and offer project-based security for your Jenkins project.

Creating a Freestyle Build Job

The freestyle build job is a highly flexible and easy-to-use option. You can use it for any type of project; it is easy to set up, and many of its options appear in other build jobs.

Step 1) 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:8000 If you have installed Jenkins in another path, use the appropriate URL to access your dashboard.

Step 2) Click on “New Item” at the top left-hand side of your dashboard.

Step 3) In the next screen,

  1. Enter the name of the item you want to create. We shall use the “Hello world” for this demo.
  2. Select Freestyle project
  3. Click Okay

Step 4) Enter the details of the project you want to test.

Step 5) Under Source Code Management, Enter your repository URL. We have a test repository located at https://github.com/LakmalAsh/JenkinsFreestyle.git

It is also possible for you to use a local repository.

If your GitHub repository is private, Jenkins will first validate your login credentials with GitHub and only then pull the source code from your GitHub repository.

Step 6) Now that you have provided all the details, it’s time to build the code. Tweak the settings under the build section to build the code at the time you want. You can even schedule the build to happen periodically, at set times.

Underbuild,

1. Click on “Add build step

2. Click on “Execute Windows batch command” and add the commands you want to execute during the build process.

Here, I have added the java commands to compile the java code.

I have added the following windows commands:

javac HelloWorld.java

java HelloWorld

Step 7) When you have entered all the data,

  1. Click Apply
  2. Save the project.

Step 8) Now, on the main screen, click the Build Now button on the left-hand side to build the source code.

Step 9) After clicking on Build now, you can see the status of the build you run under Build History.

Step 10) Click on the build number and then Click on console output to see the status of the build you run. It should show you a success message, provided you have followed the setup properly

In sum, we have executed a HelloWorld program hosted on GitHub. Jenkin pulls the code from the remote repository and builds continuously at a frequency you define.

So we discuss now until the freestyle project creation. Next, we discuss the Jenkins Pipeline. Thank you.

Post a Comment

0 Comments