Complete the code to run a shell command in a Jenkins pipeline.
pipeline {
agent any
stages {
stage('Example') {
steps {
[1] 'echo Hello World'
}
}
}
}The sh step runs shell commands on Unix-like agents in Jenkins pipelines.
Complete the code to run a Windows batch command in a Jenkins pipeline.
pipeline {
agent any
stages {
stage('Build') {
steps {
[1] 'dir'
}
}
}
}The bat step runs Windows batch commands in Jenkins pipelines.
Fix the error in the Jenkins pipeline code to run a shell command.
pipeline {
agent any
stages {
stage('Test') {
steps {
[1] "echo Testing"
}
}
}
}Use sh to run shell commands on Unix-like agents. Using bat causes errors on non-Windows agents.
Fill both blanks to run a shell command and a batch command in the same Jenkins pipeline stage.
pipeline {
agent any
stages {
stage('Multi') {
steps {
[1] 'echo Unix command'
[2] 'dir'
}
}
}
}Use sh for shell commands and bat for batch commands in Jenkins pipelines.
Fill all three blanks to create a map of commands with their respective Jenkins steps.
def commands = [ build: [1] 'make build', test: [2] 'pytest', clean: [3] 'rm -rf build' ]
Use sh for Unix shell commands and bat for Windows batch commands in Jenkins pipelines.