0
0
Jenkinsdevops~10 mins

Why build environment 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 specify the build agent in Jenkins pipeline.

Jenkins
pipeline {
  agent [1]
  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Adocker
Bnode
Cany
Dlabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'node' instead of 'any' causes syntax errors in declarative pipelines.
2fill in blank
medium

Complete the code to run the build inside a Docker container in Jenkins pipeline.

Jenkins
pipeline {
  agent {
    docker [1]
  }
  stages {
    stage('Build') {
      steps {
        sh 'make build'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
A'ubuntu:latest'
B'node:14'
C'python:3.8'
D'alpine:3.12'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing an image that does not have required tools causes build failures.
3fill in blank
hard

Fix the error in the Jenkins pipeline code to correctly specify the build environment label.

Jenkins
pipeline {
  agent [1] 'linux'
  stages {
    stage('Test') {
      steps {
        echo 'Testing on Linux agent'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aany
Bnode
Cdocker
Dlabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'node' or 'any' with a label causes syntax errors.
4fill in blank
hard

Fill both blanks to define a Jenkins pipeline that runs on a specific node and executes a shell command.

Jenkins
pipeline {
  agent [1] 'windows'
  stages {
    stage('Deploy') {
      steps {
        [2] 'deploy.bat'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Alabel
Bsh
Cbat
Ddocker
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sh' to run Windows batch files causes errors.
5fill in blank
hard

Fill all three blanks to create a Jenkins pipeline that runs inside a Docker container, sets environment variables, and runs a shell command.

Jenkins
pipeline {
  agent {
    docker [1]
  }
  environment {
    NODE_ENV = [2]
  }
  stages {
    stage('Test') {
      steps {
        [3] 'npm test'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
A'node:16'
B'production'
Csh
D'ubuntu:20.04'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong Docker image or shell command causes build failures.