Complete the code to specify the build agent in Jenkins pipeline.
pipeline {
agent [1]
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
}
}The agent any directive tells Jenkins to run the pipeline on any available agent.
Complete the code to run the build inside a Docker container in Jenkins pipeline.
pipeline {
agent {
docker [1]
}
stages {
stage('Build') {
steps {
sh 'make build'
}
}
}
}The docker 'node:14' agent runs the build inside a Node.js 14 Docker container.
Fix the error in the Jenkins pipeline code to correctly specify the build environment label.
pipeline {
agent [1] 'linux'
stages {
stage('Test') {
steps {
echo 'Testing on Linux agent'
}
}
}
}The agent label 'linux' syntax correctly specifies the build environment by label.
Fill both blanks to define a Jenkins pipeline that runs on a specific node and executes a shell command.
pipeline {
agent [1] 'windows'
stages {
stage('Deploy') {
steps {
[2] 'deploy.bat'
}
}
}
}agent label 'windows' runs the pipeline on a Windows node, and bat 'deploy.bat' runs a batch script.
Fill all three blanks to create a Jenkins pipeline that runs inside a Docker container, sets environment variables, and runs a shell command.
pipeline {
agent {
docker [1]
}
environment {
NODE_ENV = [2]
}
stages {
stage('Test') {
steps {
[3] 'npm test'
}
}
}
}The pipeline runs inside the node:16 Docker container, sets NODE_ENV to production, and runs tests with sh 'npm test'.