Complete the code to define a Jenkins agent node in the pipeline.
pipeline {
agent { label '[1]' }
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
}
}The master label refers to the Jenkins master node where the pipeline runs if no specific agent is assigned.
Complete the code to run a stage on a specific Jenkins agent labeled 'linux'.
pipeline {
agent none
stages {
stage('Test') {
agent { label '[1]' }
steps {
echo 'Testing on Linux agent'
}
}
}
}The label linux specifies the Jenkins agent node with that label to run the stage.
Fix the error in the Jenkins pipeline code to correctly allocate an agent node.
pipeline {
agent [1]
stages {
stage('Deploy') {
steps {
echo 'Deploying application'
}
}
}
}The keyword any without quotes correctly tells Jenkins to run on any available agent.
Fill both blanks to define a Jenkins pipeline that runs on a specific agent and uses a shell step.
pipeline {
agent { label '[1]' }
stages {
stage('Build') {
steps {
[2] 'echo Building on agent'
}
}
}
}The label linux selects the Linux agent, and sh runs a shell command on that agent.
Fill all three blanks to create a Jenkins pipeline that runs on an agent, checks out code, and runs a build command.
pipeline {
agent { label '[1]' }
stages {
stage('Checkout') {
steps {
[2] scm
}
}
stage('Build') {
steps {
[3] 'make build'
}
}
}
}The pipeline runs on a linux agent, uses checkout to get the source code, and runs the build command with sh.