This guide will show you how to set up your first freestyle job in Jenkins. You will use Jenkins to download Java source code from GitHub, compile the code using Maven, and view the build output.
Table of Contents
What is a Jenkins freestyle job?
A Jenkins freestyle job is the most flexible type of job that you can do. A Freestyle job allows you to build any project. For example, you can do a Maven build, run a script, and so much more. Jenkins provides the freestyle job option by default without the need to install more plugins.
Let’s create a freestyle job!
First, create a new Freestyle job. You can do this by clicking: Jenkins -> New Item.
Next, enter a name for your Freestyle job and choose the “Freestyle Project” option.
Finally, this will take you to the configuration page for the new Freestyle job you have just created.
Next in the “Source Code Management” section:
- Select “git”
- Then add the following repository URL: https://github.com/RepositoriumCodice/simple-maven-app-for-jenkins.git
- Next for the Branches to build section set the Branch Specifier to: */main
Next in the “Build Environment” section:
- Tick the “Add timestamps to the Console Output” option.
Next, in the “Build” section, click the “Add build step” button.
Finally, add “Invoke top-level Maven targets” and specify “package” as the goal.
Now click the “save” button. You will now see the dashboard for this job.
Run your freestyle job
You can run your freestyle job by clicking on the “build now” button in the job’s dashboard.
Jenkins will then display the build history below.
View the job’s console logs
You can then click on the build history job number (#1 – in this case) to view more information about the specific job that ran.
Next, click the console output option to see the job log.
View the job’s output files
Next, click the “workspace” button to view the files created by this job.
You can then download the files if needed:
Wrapping up
You can do a lot more in a job. For example, you could add post-build triggers to do coverage or archive the build. The possibilities are endless. But, you now know how to set up a Jenkins freestyle job.