0
0
Jenkinsdevops~10 mins

Shell steps (sh, bat) in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run a shell command in a Jenkins pipeline.

Jenkins
pipeline {
  agent any
  stages {
    stage('Example') {
      steps {
        [1] 'echo Hello World'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abat
Bpowershell
Cscript
Dsh
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bat' on Unix agents causes errors.
Using 'powershell' without Windows agent.
2fill in blank
medium

Complete the code to run a Windows batch command in a Jenkins pipeline.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        [1] 'dir'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Apowershell
Bsh
Cbat
Dcmd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sh' on Windows agents without a Unix shell.
Using 'cmd' which is not a Jenkins pipeline step.
3fill in blank
hard

Fix the error in the Jenkins pipeline code to run a shell command.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        [1] "echo Testing"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ash
Bscript
Cpowershell
Dbat
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bat' on Unix agents.
Using 'powershell' without Windows.
4fill in blank
hard

Fill both blanks to run a shell command and a batch command in the same Jenkins pipeline stage.

Jenkins
pipeline {
  agent any
  stages {
    stage('Multi') {
      steps {
        [1] 'echo Unix command'
        [2] 'dir'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ash
Bpowershell
Cbat
Dscript
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bat' for shell commands.
Using 'powershell' instead of 'bat' for batch commands.
5fill in blank
hard

Fill all three blanks to create a map of commands with their respective Jenkins steps.

Jenkins
def commands = [
  build: [1] 'make build',
  test: [2] 'pytest',
  clean: [3] 'rm -rf build'
]
Drag options to blanks, or click blank then click option'
Ash
Bbat
Dpowershell
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'powershell' where not needed.
Mixing up 'sh' and 'bat' steps.