0
0
Jenkinsdevops~10 mins

Why knowing alternatives matters in Jenkins - Test Your Understanding

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

Complete the code to trigger a Jenkins build manually.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        [1] 'echo Building project'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ash
Bbuild
Cscript
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'build' instead of 'sh' causes errors.
Using 'run' is not a Jenkins pipeline step.
2fill in blank
medium

Complete the code to define an environment variable in Jenkins pipeline.

Jenkins
pipeline {
  agent any
  environment {
    GREETING = [1]
  }
  stages {
    stage('Example') {
      steps {
        sh 'echo $GREETING'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
A"Hello World"
B'Hello World'
CHello World
DGREETING
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes causes syntax errors.
Using unquoted text is invalid.
3fill in blank
hard

Fix the error in the Jenkins pipeline 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
Bshell
Crun
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'shell' or 'run' causes syntax errors.
Using 'execute' is not recognized.
4fill in blank
hard

Fill both blanks to create a Jenkins pipeline stage that runs a shell command and sets a variable.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        script {
          [1] = [2] 'echo Hello'
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Adef
Bsh
Cvar
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'var' instead of 'def' causes errors.
Using 'run' instead of 'sh' is invalid.
5fill in blank
hard

Fill all three blanks to create a Jenkins pipeline that defines a map with keys and values filtered by a condition.

Jenkins
pipeline {
  agent any
  stages {
    stage('Filter') {
      steps {
        script {
          def data = [a: 1, b: 2, c: 3, d: 4]
          def filtered = data.findAll { [1], [2], [3] }
          echo "Filtered: ${filtered}"
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ak, v ->
Bv > 2
Ck, v -> v > 2
D{ k, v -> v > 2 }
Attempts:
3 left
💡 Hint
Common Mistakes
Using incomplete closure syntax causes errors.
Putting the whole closure in one blank is invalid here.