0
0
Jenkinsdevops~10 mins

Master-agent architecture 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 define a Jenkins agent node in the pipeline.

Jenkins
pipeline {
  agent { label '[1]' }
  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Amaster
Bagent
Cnode
Dslave
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'slave' which is deprecated terminology.
Using 'agent' which is a keyword, not a label.
Using 'node' which is a pipeline step, not a label.
2fill in blank
medium

Complete the code to run a stage on a specific Jenkins agent labeled 'linux'.

Jenkins
pipeline {
  agent none
  stages {
    stage('Test') {
      agent { label '[1]' }
      steps {
        echo 'Testing on Linux agent'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Awindows
Blinux
Cmac
Ddocker
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'windows' when the agent is Linux.
Using 'docker' which is not a label here.
Using 'mac' which is a different OS.
3fill in blank
hard

Fix the error in the Jenkins pipeline code to correctly allocate an agent node.

Jenkins
pipeline {
  agent [1]
  stages {
    stage('Deploy') {
      steps {
        echo 'Deploying application'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Alabel('any')
B'any'
Cany
D{ label: 'any' }
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around 'any' which causes syntax error.
Using a dictionary or function call which is invalid here.
4fill in blank
hard

Fill both blanks to define a Jenkins pipeline that runs on a specific agent and uses a shell step.

Jenkins
pipeline {
  agent { label '[1]' }
  stages {
    stage('Build') {
      steps {
        [2] 'echo Building on agent'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Alinux
Bsh
Cbat
Dwindows
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bat' which is for Windows agents.
Using 'windows' label with 'sh' step which causes errors.
5fill in blank
hard

Fill all three blanks to create a Jenkins pipeline that runs on an agent, checks out code, and runs a build command.

Jenkins
pipeline {
  agent { label '[1]' }
  stages {
    stage('Checkout') {
      steps {
        [2] scm
      }
    }
    stage('Build') {
      steps {
        [3] 'make build'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Alinux
Bcheckout
Csh
Dbat
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bat' on Linux agents causing errors.
Forgetting to use 'checkout' to get code.
Using wrong agent label.