0
0
Jenkinsdevops~10 mins

Why Docker simplifies build environments 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 Docker agent in Jenkins pipeline.

Jenkins
pipeline {
  agent {
    docker { image '[1]' }
  }
  stages {
    stage('Build') {
      steps {
        sh 'echo Building inside Docker'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aalpine:3.12
Bubuntu:latest
Cpython:3.8
Dnodejs:14
Attempts:
3 left
💡 Hint
Common Mistakes
Using an image that does not match the build requirements.
Forgetting to specify the image name as a string.
2fill in blank
medium

Complete the code to run a shell command inside the Docker container in Jenkins.

Jenkins
pipeline {
  agent {
    docker { image 'python:3.8' }
  }
  stages {
    stage('Test') {
      steps {
        sh '[1]'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Apytest tests/
Bpip install requests
Cpython --version
Decho Hello World
Attempts:
3 left
💡 Hint
Common Mistakes
Running commands that do not execute tests.
Using commands that require prior setup not shown.
3fill in blank
hard

Fix the error in the Docker agent declaration to ensure the build runs inside the container.

Jenkins
pipeline {
  agent {
    docker {
      [1] 'maven:3.6.3-jdk-11'
    }
  }
  stages {
    stage('Build') {
      steps {
        sh 'mvn clean install'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Acontainer
Blabel
Cimage
Dnode
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'container' instead of 'image' causes syntax errors.
Confusing Docker agent keywords with node labels.
4fill in blank
hard

Fill both blanks to define a Docker agent with a custom label and reuse the container.

Jenkins
pipeline {
  agent {
    docker {
      image '[1]'
      [2] true
    }
  }
  stages {
    stage('Deploy') {
      steps {
        sh 'echo Deploying application'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Anodejs:16
BreuseNode
CalwaysPullImage
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alwaysPullImage' instead of 'reuseNode' changes behavior.
Putting 'true' in the wrong place causes syntax errors.
5fill in blank
hard

Fill all three blanks to create a Docker pipeline that builds, tests, and cleans up.

Jenkins
pipeline {
  agent {
    docker {
      image '[1]'
      args '[2]'
      reuseNode [3]
    }
  }
  stages {
    stage('Build') {
      steps {
        sh 'make build'
      }
    }
    stage('Test') {
      steps {
        sh 'make test'
      }
    }
  }
  post {
    always {
      sh 'make clean'
    }
  }
}
Drag options to blanks, or click blank then click option'
Agolang:1.18
B--network host
Ctrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'false' for reuseNode disables container reuse.
Omitting Docker args may cause network issues.