Bird
Raised Fist0
Jenkinsdevops~10 mins

Freestyle job creation in Jenkins - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Freestyle job creation
Open Jenkins Dashboard
↓
Click 'New Item'
↓
Enter Job Name
↓
Select 'Freestyle project'
↓
Configure Job Settings
↓
Save Job
↓
Run Job
↓
View Console Output
This flow shows the step-by-step process to create and run a freestyle job in Jenkins.
Execution Sample
Jenkins
1. Open Jenkins Dashboard
2. Click 'New Item'
3. Enter job name 'MyJob'
4. Select 'Freestyle project'
5. Configure build steps
6. Save and run job
This sequence creates a freestyle job named 'MyJob', configures it, saves, and runs it.
Process Table
StepActionInput/SelectionResult/State Change
1Open Jenkins DashboardN/ADashboard page loads
2Click 'New Item'N/A'Create a new job' page opens
3Enter job name'MyJob'Job name field set to 'MyJob'
4Select job type'Freestyle project'Freestyle project selected
5Configure jobAdd build step: Execute shell 'echo Hello'Build step added
6Save jobClick 'Save'Job 'MyJob' created and saved
7Run jobClick 'Build Now'Job 'MyJob' starts running
8View outputOpen 'Console Output'Console shows 'Hello' output
9ExitJob finishedJob run completed successfully
💡 Job run completes and console output is available
Status Tracker
VariableStartAfter Step 3After Step 5After Step 6After Step 7Final
Job NameNoneMyJobMyJobMyJobMyJobMyJob
Job TypeNoneNoneFreestyle projectFreestyle projectFreestyle projectFreestyle project
Build StepsEmptyEmptyExecute shell 'echo Hello'Execute shell 'echo Hello'Execute shell 'echo Hello'Execute shell 'echo Hello'
Job StatusNot createdNot createdNot createdCreatedRunningCompleted
Key Moments - 3 Insights
Why do we need to select 'Freestyle project' after entering the job name?
Selecting 'Freestyle project' defines the type of job Jenkins will create. Without this, Jenkins cannot configure the job properly. See execution_table step 4.
What happens if we don't add any build steps before saving?
The job will be created but running it will do nothing because no tasks are defined. See execution_table step 5 for adding build steps.
How do we know the job ran successfully?
By checking the console output after running the job, which shows the expected output. See execution_table step 8.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the job status after step 6?
ARunning
BNot created
CCreated
DCompleted
💡 Hint
Check the 'Job Status' variable in variable_tracker after step 6
At which step does the console output become available?
AStep 8
BStep 7
CStep 6
DStep 5
💡 Hint
Look at execution_table row for viewing output
If you skip selecting 'Freestyle project', what will happen?
AJob will be created as freestyle by default
BJenkins will not allow saving the job
CJob will run but no output
DJob will be created but with errors
💡 Hint
Refer to key_moments about selecting job type (step 4)
Concept Snapshot
Freestyle Job Creation in Jenkins:
1. Open Jenkins Dashboard
2. Click 'New Item' and enter job name
3. Select 'Freestyle project' as job type
4. Configure build steps (e.g., shell commands)
5. Save the job
6. Run the job and view console output
Key: Selecting job type is mandatory before saving.
Full Transcript
To create a freestyle job in Jenkins, start by opening the Jenkins dashboard. Click on 'New Item' to create a new job. Enter a name for your job, for example, 'MyJob'. Then select 'Freestyle project' as the job type. Configure the job by adding build steps such as executing shell commands. Save the job to create it. After saving, you can run the job by clicking 'Build Now'. Once the job runs, view the console output to see the results. The job status changes from not created to created, then running, and finally completed. Selecting the job type is essential before saving, or Jenkins will not allow the job to be saved. If no build steps are added, the job will run but perform no actions. Checking the console output confirms the job ran successfully.

Practice

(1/5)
1. What is the main purpose of a freestyle job in Jenkins?
easy
A. To monitor server hardware status
B. To create complex pipelines with multiple stages
C. To manage Jenkins user permissions
D. To run simple automated tasks configured via the Jenkins UI

Solution

  1. Step 1: Understand freestyle job basics

    Freestyle jobs are designed for simple automation tasks in Jenkins, easy to set up through the UI.
  2. Step 2: Compare options

    Monitoring server hardware, creating complex pipelines, and managing user permissions are other Jenkins features or unrelated tasks, not freestyle jobs.
  3. Final Answer:

    To run simple automated tasks configured via the Jenkins UI -> Option D
  4. Quick Check:

    Freestyle job = simple automation [OK]
Hint: Freestyle jobs are for simple tasks, not complex pipelines [OK]
Common Mistakes:
  • Confusing freestyle jobs with pipeline jobs
  • Thinking freestyle jobs manage users or hardware
  • Assuming freestyle jobs require scripting
2. Which of the following is the correct way to start creating a freestyle job in Jenkins?
easy
A. Go to 'Manage Jenkins' and select 'Create Freestyle Job'
B. Run the command 'jenkins create freestyle' in the terminal
C. Click 'New Item', enter a name, select 'Freestyle project', then click OK
D. Edit the Jenkinsfile to add a freestyle job

Solution

  1. Step 1: Recall Jenkins UI steps

    To create a freestyle job, you click 'New Item', name it, choose 'Freestyle project', and confirm.
  2. Step 2: Eliminate incorrect options

    Going to 'Manage Jenkins', running terminal commands, and editing a Jenkinsfile are not how freestyle jobs are created.
  3. Final Answer:

    Click 'New Item', enter a name, select 'Freestyle project', then click OK -> Option C
  4. Quick Check:

    Create freestyle job = New Item + Freestyle project [OK]
Hint: Start with 'New Item' and pick 'Freestyle project' [OK]
Common Mistakes:
  • Looking for freestyle job creation in 'Manage Jenkins'
  • Trying to create freestyle jobs via terminal commands
  • Editing Jenkinsfile instead of using UI
3. Given a freestyle job configured to run a shell command echo Hello Jenkins, what will be the output in the build console?
medium
A. Hello Jenkins
B. echo Hello Jenkins
C. Error: command not found
D. Build failed

Solution

  1. Step 1: Understand shell command execution in freestyle job

    The shell command echo Hello Jenkins prints the text 'Hello Jenkins' to the console.
  2. Step 2: Analyze output options

    'Hello Jenkins' matches the expected output. 'echo Hello Jenkins' shows the command itself, which is not the output. Error and build failure do not occur here.
  3. Final Answer:

    Hello Jenkins -> Option A
  4. Quick Check:

    echo command prints text [OK]
Hint: echo prints text, not the command itself [OK]
Common Mistakes:
  • Confusing command output with command text
  • Assuming shell commands fail without reason
  • Expecting build failure without errors
4. You created a freestyle job but the build fails immediately with 'No such file or directory' error when running a shell command. What is the most likely cause?
medium
A. The freestyle job was not saved properly
B. The shell command references a file that does not exist on the Jenkins agent
C. Jenkins server is offline
D. The job type should be pipeline, not freestyle

Solution

  1. Step 1: Understand the error message

    'No such file or directory' means the shell command tries to access a missing file on the Jenkins agent machine.
  2. Step 2: Evaluate other options

    The freestyle job was not saved properly is unlikely because saving issues cause different errors. Jenkins server is offline would prevent any build start. The job type should be pipeline, not freestyle is unrelated to file errors.
  3. Final Answer:

    The shell command references a file that does not exist on the Jenkins agent -> Option B
  4. Quick Check:

    File missing on agent = 'No such file' error [OK]
Hint: Check file paths on Jenkins agent for shell commands [OK]
Common Mistakes:
  • Assuming job type causes file errors
  • Ignoring agent environment differences
  • Thinking Jenkins server offline causes this error
5. You want to create a freestyle job that triggers automatically every day at 2 AM and runs a shell script. Which configuration steps are needed?
hard
A. Set 'Build Triggers' to 'Build periodically' with schedule '0 2 * * *' and add shell command in 'Build' section
B. Add a cron job on the Jenkins server to run the job at 2 AM
C. Configure 'Poll SCM' with schedule '0 2 * * *' and add shell command in 'Post-build Actions'
D. Use 'Build after other projects are built' trigger and add shell command in 'Build' section

Solution

  1. Step 1: Identify correct trigger for scheduled builds

    In freestyle jobs, 'Build periodically' with cron syntax schedules automatic runs at specified times.
  2. Step 2: Place shell command in the 'Build' section

    The shell script should be added under 'Build' steps, not post-build or external cron.
  3. Final Answer:

    Set 'Build Triggers' to 'Build periodically' with schedule '0 2 * * *' and add shell command in 'Build' section -> Option A
  4. Quick Check:

    Scheduled build = 'Build periodically' + shell in 'Build' [OK]
Hint: Use 'Build periodically' with cron for scheduled freestyle jobs [OK]
Common Mistakes:
  • Using external cron instead of Jenkins triggers
  • Putting shell commands in post-build actions
  • Confusing 'Poll SCM' with scheduled builds
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard