Friday, November 15, 2024
Google search engine
HomeGuest BlogsJenkins Build: Set Up Freestyle Project in Jenkins

Jenkins Build: Set Up Freestyle Project in Jenkins

Introduction

Jenkins is an open-source server used for automating software development and deployment. It allows developers to create repeatable jobs that contain all the code necessary to build an application.

In this tutorial, we will define what a Jenkins Freestyle Project is and show you how to set one up.

Jenkins build - set up a freestyle project in JenkinsJenkins build - set up a freestyle project in Jenkins

Prerequisites

What Is a Build Job?

A Jenkins build job contains the configuration for automating a specific task or step in the application building process. These tasks include gathering dependencies, compiling, archiving, or transforming code, and testing and deploying code in different environments.

Jenkins supports several types of build jobs, such as freestyle projects, pipelines, multi-configuration projects, folders, multibranch pipelines, and organization folders.

Note: Learn more about how Jenkins works in our Jenkins tutorial for beginners.

What is a Jenkins Freestyle Project?

Jenkins freestyle projects allow users to automate simple jobs, such as running tests, creating and packaging applications, producing reports, or executing commands. Freestyle projects are repeatable and contain both build steps and post-build actions.

Jenkins freestyle project flowchartJenkins freestyle project flowchart

Even though freestyle jobs are highly flexible, they support a limited number of general build and post-build actions. Any specialized or non-typical action a user wants to add to a freestyle project requires additional plugins.

How to Set up a Build Job in Jenkins

Follow the steps outlined below to set up and run a new Jenkins freestyle project.

Step 1: Create a New Freestyle Project

1. Click the New Item link on the left-hand side of the Jenkins dashboard.

Click the New Item link on the left-hand side of the Jenkins dashboardClick the New Item link on the left-hand side of the Jenkins dashboard

2. Enter the new project’s name in the Enter an item name field and select the Freestyle project type. Click OK to continue.

Enter the project name, select the project type, and click OK to confirmEnter the project name, select the project type, and click OK to confirm

3. Under the General tab, add a project description in the Description field.

Add a Jenkins project descriptionAdd a Jenkins project description

Step 2: Add a Build Step

1. Scroll down to the Build section.

2. Open the Add build step drop-down menu and select Execute Windows batch command.

Select Execute Windows batch command from the Add build step drop-down menuSelect Execute Windows batch command from the Add build step drop-down menu

3. Enter the commands you want to execute in the Command field. For this tutorial, we are using a simple set of commands that display the current version of Java and Jenkins working directory:

java -version
dir

4. Click the Save button to save changes to the project.

Save changes to the projectSave changes to the project

Note: Need a cheap sandboxing environment with automated OS-deployment options? See how easy it is to deploy a development sandbox for as little as $0.10/hour.

Step 3: Build the Project

1. Click the Build Now link on the left-hand side of the new project page.

Use the Build Now link to build the a new project versionUse the Build Now link to build the a new project version

2. Click the link to the latest project build in the Build History section.

Click the link to open the latest build versionClick the link to open the latest build version

3. Click the Console Output link on the left-hand side to display the output for the commands you entered.

Click the link to open the build console outputClick the link to open the build console output

4. The console output indicates that Jenkins is successfully executing the commands, displaying the current version of Java and Jenkins working directory.

Jenkins project console outputJenkins project console output

Note: Learn how to configure Jenkins Shared Libraries to make your deployment and development more efficient.

Conclusion

After reading this tutorial, you should be able to create and run your first Jenkins freestyle project.

Check out our rundown of the best CI/CD tools for Jenkins alternatives or additions.

Was this article helpful?
YesNo

RELATED ARTICLES

Most Popular

Recent Comments