What is a freestyle job/project?
A freestyle project is a simple build job or task. This task can be running some commands, building code, testing source code, deploying code on some other server, and much more. The freestyle project is the most configurable and flexible option and the setup is quite easy. It provides the UI option to configure steps which makes it easy to work with.
The freestyle job has limited actions like build and post-build steps. This limitation is solved in Jenkins by the use of plugins.
Creating a freestyle job.
In this example, we are going to create a freestyle job that will run some simple Linux commands.
Step 1. Login in Jenkins
First, you need to login into Jenkins with the credentials that you have used while installing Jenkins.
Step 2. Create a New Item
Click on the “New Item” at the top left of the Jenkins dashboard.
Step 3. Provide Item details
✔ Enter the name of the project.
✔ Choose Freestyle Project.
✔ Click Ok at the bottom
Step 4. Enter the Project Details
Enter some description about the project.
Step 5. Adding a build step
✔ Click on Add build step.
✔ Choose Execute shell
✔ Write some Linux commands. For ex. pwd and whoami
Step 6. Save the project.
Click on Apply and then Save.
Step 7. Build the Project
Now, click on Build Now to build the project.
Step 8. Check the Output and Status
Click on the build number and then click on Console Output and you will able to see the logs and build status.
We have created a simple freestyle project that performs Linux commands. A freestyle project can do much more, from running simple commands to deploying the build to a server.
✔ Create a freestyle project which takes the absolute path of a directory as input,
✔ able to list all files and folders inside that,
✔ prints “directory does not exist” if the directory is not present there,
✔ prints “Not allowed” if you don’t have permission to list the files.
✔ And able to list only the last 10 builds of the last 2 days in “Build History”.