Jenkins Build: Set Up Freestyle Project in Jenkins

January 25, 2022

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 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 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 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 confirm

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

Add 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 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 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 version

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

Click 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 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 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
Aleksandar Kovačević
With a background in both design and writing, Aleksandar Kovacevic aims to bring a fresh perspective to writing for IT, making complicated concepts easy to understand and approach.
Next you should read
Jenkins Logs - Viewing and Customizing
December 30, 2021

Jenkins is an open-source automation server for code development. Jenkins logs offer a wealth of information about your projects and the Jenkins app itself.
Read more
Jenkins Environment Variables: Ultimate Guide
December 23, 2021

Jenkins is an open-source automation server used for automating code development. In this tutorial, we show you how to use environment variables in Jenkins to make automation even easier.
Read more
How to Restart Jenkins Manually
December 16, 2021

Jenkins offers a way for developers to automate building, testing, and deploying their applications. This tutorial show you how to restart Jenkins manually.
Read more
How to Change Port for Jenkins
December 29, 2021

Jenkins uses port 8080 by default, but it also lets users set a custom port. This tutorial shows you how to change the default Jenkins port in Windows, Linux, and macOS.
Read more