0
0
Jenkinsdevops~30 mins

System configuration management in Jenkins - Mini Project: Build & Apply

Choose your learning style9 modes available
System Configuration Management with Jenkins
📖 Scenario: You are working as a DevOps engineer. Your team wants to automate the setup of a simple Jenkins job that runs a shell command to print system information. This helps ensure consistent system configuration checks across servers.
🎯 Goal: Build a Jenkins pipeline script that defines a job to run a shell command uname -a to display system information.
📋 What You'll Learn
Create a Jenkins pipeline script with a pipeline block
Define an agent to run the job on any available node
Add an environment variable SYS_COMMAND with the value uname -a
Use a stage named System Info to run the shell command stored in SYS_COMMAND
Print the output of the shell command in the Jenkins console
💡 Why This Matters
🌍 Real World
Automating system configuration checks helps teams maintain consistent environments and quickly detect issues.
💼 Career
Jenkins pipelines are widely used in DevOps roles to automate tasks like system monitoring, deployment, and testing.
Progress0 / 4 steps
1
Create the basic Jenkins pipeline structure
Write a Jenkins pipeline script starting with pipeline { and define an agent any block inside it.
Jenkins
Need a hint?

Start by writing pipeline { and inside it add agent any to run on any node.

2
Add an environment variable for the system command
Inside the pipeline block, add an environment block that defines a variable called SYS_COMMAND with the value uname -a.
Jenkins
Need a hint?

Use the environment block to set SYS_COMMAND = 'uname -a'.

3
Add a stage to run the system command
Inside the pipeline block, add a stages block with a stage named System Info. Inside this stage, add a steps block that runs the shell command stored in SYS_COMMAND using sh.
Jenkins
Need a hint?

Use sh SYS_COMMAND inside the steps block to run the command.

4
Print the output of the system command
Add a script block inside the steps of the System Info stage. Use def output = sh(script: SYS_COMMAND, returnStdout: true).trim() to capture the command output, then print it with echo output.
Jenkins
Need a hint?

Use a script block to capture the output and then print it with echo.