0
0
Jenkinsdevops~10 mins

Labels for agent selection in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run the Jenkins pipeline on an agent with the label 'linux'.

Jenkins
pipeline {
  agent { label '[1]' }
  stages {
    stage('Build') {
      steps {
        echo 'Building on Linux agent'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Alinux
Bmac
Cwindows
Ddocker
Attempts:
3 left
💡 Hint
Common Mistakes
Using a label that does not exist on any agent.
Misspelling the label name.
2fill in blank
medium

Complete the code to run the Jenkins pipeline on an agent with the label 'docker'.

Jenkins
pipeline {
  agent { label '[1]' }
  stages {
    stage('Test') {
      steps {
        echo 'Running tests on Docker agent'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Alinux
Bdocker
Cwindows
Dkubernetes
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Docker' with uppercase D instead of 'docker'.
Selecting a label that does not exist.
3fill in blank
hard

Fix the error in the Jenkins pipeline to correctly select an agent with the label 'windows'.

Jenkins
pipeline {
  agent { label '[1]' }
  stages {
    stage('Deploy') {
      steps {
        echo 'Deploying on Windows agent'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Awin
BWindows
Cwin10
Dwindows
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase 'Windows' which does not match the label.
Using shorthand labels like 'win' that are not defined.
4fill in blank
hard

Fill both blanks to run the pipeline on an agent with label 'linux' and specify the stage name as 'Build'.

Jenkins
pipeline {
  agent { label '[1]' }
  stages {
    stage('[2]') {
      steps {
        echo 'Building project'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Alinux
BTest
CBuild
Dwindows
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up stage names with labels.
Using incorrect labels like 'windows' for a Linux agent.
5fill in blank
hard

Fill all three blanks to run the pipeline on an agent with label 'docker', name the stage 'Test', and print 'Running tests'.

Jenkins
pipeline {
  agent { label '[1]' }
  stages {
    stage('[2]') {
      steps {
        echo '[3]'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Alinux
BTest
CRunning tests
Ddocker
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong labels like 'linux' instead of 'docker'.
Incorrect stage names or echo messages.