Jenkins Freestyle Project

Karan Kaushik
3 min readMay 10, 2021

--

We will cover how to create a Freestyle Project in Jenkins and execute shell commands.

Courtesy: www.jenkins.io

Installing Jenkins

Jenkins runs using Java, before install Jenkins you will need to install java. Follow the steps mentioned here to complete installation.

Creating Freestyle Project

Go to “New Item”, select “Freestyle Project”, add name “hello-jenkins”.

Jenkins Home Page
Jenkins New Item Page

Once the project is created, we are displayed the following page with multiple options.

  • General: Descriptions and management tasks for the project.
  • Source Code Management: Adding a Git repository to the project.
  • Build Triggers: Trigger actions for the project to take new build (run).
  • Build Environment: Prerequisites needed for the build to run.
  • Build: Actual steps/commands that will run.
  • Post-build Actions: Steps/Commands that need to run after the build is completed.
Jenkins Freestyle Project

Select “Add timestamps to the Console Output” in Build Environment

Select “Execute Shell” in Build.

Build Environment and Build Step in Freestyle Project

Enter echo “Hello Jenkins” in the command prompt to execute command.

echo “Hello Jenkins” in command shell

Click “Save” and then “Build Now” to run the Project.

Build Now to execute project

Go to the latest build from the Build History margin

Check build #1

Click on “Console Output” to view output of the build.

Console Output for more information
Console Output

Click on ‘Back to Project” to take you to the Project page.

Back to Project Page

Go to “Configure” to change Build steps and execute another command.

Configure Project to run more commands

Enter the follow commands in command shell

echo "Hello Jenkins" > hello-jenkins.txt
cat hello-jenkins.txt
Change and Save

Save and Build Project. Open Build #2 to check output.

Check output for Build #2

Check Console Output for complete output.

Console Output for Build #2

This completes the blog to create a Freestyle Project in Jenkins and execute shell commands.
Stay tuned for more posts on Jenkins.

--

--