Challenge - 5 Problems
Shell Steps Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of this Jenkins shell step?
Consider this Jenkins pipeline shell step using
sh to list files. What will be the output if the workspace contains files file1.txt and file2.txt?Jenkins
sh 'ls *.txt'Attempts:
2 left
💡 Hint
Think about how the shell expands wildcards and how Jenkins captures output.
✗ Incorrect
The
sh step runs the shell command and outputs matching files each on a new line.❓ Troubleshoot
intermediate1:30remaining
Why does this Jenkins
bat step fail on Windows agent?This Jenkins pipeline step runs a Windows batch command but fails with 'command not found'. What is the likely cause?
Jenkins
bat 'echo Hello World'Attempts:
2 left
💡 Hint
Consider the environment where the command runs.
✗ Incorrect
The
bat step runs Windows batch commands and requires a Windows agent. On Linux agents, it fails.❓ Configuration
advanced2:00remaining
How to capture output of a shell step in Jenkins pipeline?
You want to save the output of a shell command into a variable in a Jenkins pipeline scripted syntax. Which snippet correctly captures the output?
Attempts:
2 left
💡 Hint
Look for the option that returns command output as a string.
✗ Incorrect
The
sh step with returnStdout: true returns the command output as a string.✅ Best Practice
advanced2:00remaining
Which approach is best for cross-platform shell steps in Jenkins pipeline?
You want to write a Jenkins pipeline that runs shell commands on both Linux and Windows agents. Which approach is best?
Attempts:
2 left
💡 Hint
Think about agent OS compatibility.
✗ Incorrect
Using
sh for Linux and bat for Windows with OS checks ensures commands run correctly on each platform.🔀 Workflow
expert2:30remaining
Order the steps to run a shell command, capture output, and archive a file in Jenkins pipeline
Arrange these Jenkins pipeline steps in the correct order to run a shell command, save its output, and archive a file named
output.log:Attempts:
2 left
💡 Hint
Think about creating the file before reading and archiving it.
✗ Incorrect
First create the file with shell command (1), then read it (3), archive it (2), and finally print confirmation (4).