0
0
Jenkinsdevops~30 mins

Freestyle job creation in Jenkins - Mini Project: Build & Apply

Choose your learning style9 modes available
Freestyle Job Creation in Jenkins
📖 Scenario: You are a DevOps engineer setting up a simple Jenkins freestyle job to automate a build process. This job will run a shell command to print a welcome message.
🎯 Goal: Build a Jenkins freestyle job configuration that defines the job name, adds a shell build step with a specific command, and outputs the build log showing the command's output.
📋 What You'll Learn
Create a Jenkins freestyle job configuration with the exact job name WelcomeJob.
Add a shell build step that runs the command echo "Welcome to Jenkins freestyle job!".
Print the build log output showing the welcome message.
💡 Why This Matters
🌍 Real World
Jenkins freestyle jobs are commonly used to automate simple build and deployment tasks in software projects.
💼 Career
Understanding how to configure and simulate Jenkins jobs helps DevOps engineers automate workflows and troubleshoot build processes.
Progress0 / 4 steps
1
Create the Jenkins freestyle job configuration
Create a variable called job_config and assign it a dictionary with a key name set to the string "WelcomeJob".
Jenkins
Need a hint?

Use a dictionary with the key "name" and value "WelcomeJob".

2
Add a shell build step command
Add a key build_steps to the job_config dictionary and assign it a list containing the exact string "echo \"Welcome to Jenkins freestyle job!\"".
Jenkins
Need a hint?

Add a list with the exact echo command string as the value for the key "build_steps".

3
Simulate running the build steps
Create a variable called build_log and assign it an empty list. Then use a for loop with variable step to iterate over job_config["build_steps"]. Inside the loop, append the string "Running: " + step to build_log and then append the exact output string "Welcome to Jenkins freestyle job!" to build_log.
Jenkins
Need a hint?

Use a loop to append the command and its output to build_log.

4
Print the build log output
Use a for loop with variable line to iterate over build_log and print each line.
Jenkins
Need a hint?

Print each line from the build_log list using a loop.