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.
Prerequisites
- A copy of Jenkins installed and ready to use (learn how to Install Jenkins on Windows 10, Ubuntu 18.04, Debian 10, CentOS 8, or install Jenkins on a Kubernetes cluster)
- Access to a web browser
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.
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.
2. Enter the new project's name in the Enter an item name field and select the Freestyle project type. Click OK to continue.
3. Under the General tab, add a project description in the Description field.
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.
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.
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.
2. Click the link to the latest project build in the Build History section.
3. Click the Console Output link on the left-hand side to display the output for the commands you entered.
4. The console output indicates that Jenkins is successfully executing the commands, displaying the current version of Java and Jenkins working directory.
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.