Complete the code to specify the agent for the 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 specify a label for the Jenkins agent.
pipeline {
agent {
label '[1]'
}
stages {
stage('Test') {
steps {
echo 'Testing...'
}
}
}
}The label 'linux' directive tells Jenkins to run the pipeline on an agent labeled 'linux'.
Fix the error in the agent directive to use a Docker container.
pipeline {
agent {
docker [1]
}
stages {
stage('Deploy') {
steps {
echo 'Deploying...'
}
}
}
}The Docker image name must be a string, so it needs quotes like 'node:14'.
Fill both blanks to specify a Docker agent with a custom label.
pipeline {
agent {
docker {
image [1]
label [2]
}
}
stages {
stage('Integration') {
steps {
echo 'Running integration tests...'
}
}
}
}The image should be a Docker image string like 'python:3.9', and label should be the agent label like 'docker-agent'.
Fill all three blanks to define a Jenkins pipeline with a Kubernetes agent specifying the YAML file, label, and default container.
pipeline {
agent {
kubernetes {
yamlFile [1]
label [2]
defaultContainer [3]
}
}
stages {
stage('Build') {
steps {
echo 'Building in Kubernetes...'
}
}
}
}The yamlFile should be the Kubernetes pod definition file like 'agent.yaml', the label is the agent label like 'k8s-agent', and defaultContainer is the container name like 'jnlp'.