Complete the code to start a Jenkins build on a remote agent.
node('[1]') { echo 'Building on remote agent' }
The node block specifies the agent where the build runs. Using agent1 runs the build on a remote machine.
Complete the code to run a shell command on a distributed Jenkins agent.
node('agent1') { [1] 'echo Hello from distributed build' }
The sh step runs shell commands on Unix-like agents.
Fix the error in the Jenkins pipeline to distribute builds correctly.
pipeline {
agent [1]
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
}
}Using agent any allows Jenkins to pick any available agent for distributed builds.
Fill both blanks to create a parallel distributed build on two agents.
parallel {
build1: {
node('[1]') {
echo 'Build on first agent'
}
},
build2: {
node('[2]') {
echo 'Build on second agent'
}
}
}Using agent1 and agent2 runs builds in parallel on two different distributed agents.
Fill all three blanks to define a distributed build with environment variables and shell steps.
node('[1]') { env.BUILD_ENV = '[2]' [3] 'echo Building in $BUILD_ENV on distributed agent' }
The build runs on agent3 with environment production and uses sh to run the shell command.