0
0
Jenkinsdevops~10 mins

Steps within stages 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 define a stage with a single step that echoes a message.

Jenkins
pipeline {
  agent any
  stages {
    stage('Example') {
      steps {
        [1] 'Hello, Jenkins!'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ascript
Bsh
Cecho
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sh' without a shell command.
Using 'input' which waits for user input.
Using 'script' which is for running Groovy code blocks.
2fill in blank
medium

Complete the code to run a shell command inside a stage step.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        [1] 'make build'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ainput
Becho
Cbat
Dsh
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'echo' which only prints text.
Using 'bat' which is for Windows batch commands.
Using 'input' which pauses for user input.
3fill in blank
hard

Fix the error in the stage by completing the step to run a Windows batch command.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        [1] 'dir'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abat
Bsh
Cecho
Dpowershell
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sh' which is for Unix shells.
Using 'echo' which only prints text.
Using 'powershell' which requires a different syntax.
4fill in blank
hard

Fill both blanks to create a stage with two steps: echo a message and run a shell command.

Jenkins
pipeline {
  agent any
  stages {
    stage('Deploy') {
      steps {
        [1] 'Starting deployment'
        [2] 'deploy.sh'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aecho
Bsh
Cbat
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bat' for shell commands on Unix.
Using 'input' which pauses the pipeline.
Mixing up the order of steps.
5fill in blank
hard

Fill all three blanks to create a stage with steps: echo a message, run a shell command, and pause for input.

Jenkins
pipeline {
  agent any
  stages {
    stage('Approval') {
      steps {
        [1] 'Ready for approval'
        [2] 'echo Waiting for user'
        [3] message: 'Proceed?', ok: 'Yes'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aecho
Bsh
Cinput
Dbat
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bat' on Unix agents.
Skipping the input step for approval.
Using 'sh' for the input step.