0
0
Jenkinsdevops~10 mins

Jenkins in the CI/CD ecosystem - 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 pipeline that runs on any available agent.

Jenkins
pipeline {
  agent [1]
  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
A'any'
Bnone
C'all'
Dany
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around 'any' which causes syntax error
Using 'all' or 'none' which are invalid agent values
2fill in blank
medium

Complete the code to trigger a Jenkins pipeline using periodic SCM polling.

Jenkins
pipeline {
  agent any
  triggers {
    pollSCM('[1]')
  }
  stages {
    stage('Test') {
      steps {
        echo 'Testing...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Arefs/heads/main
BH/5 * * * *
C*/5 * * * *
Dmain
Attempts:
3 left
💡 Hint
Common Mistakes
Using branch specifiers like 'refs/heads/main' or 'main', which are invalid cron expressions for pollSCM
Using '*/5 * * * *' without hashing, which can overload Jenkins at fixed intervals
3fill in blank
hard

Fix the error in the Jenkins pipeline syntax to correctly define environment variables.

Jenkins
pipeline {
  agent any
  environment {
    PATH = '[1]'
  }
  stages {
    stage('Deploy') {
      steps {
        echo "Deploying with PATH: $PATH"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
A/usr/local/bin:$PATH
BPATH:/usr/bin
CPATH:/usr/local/bin
D/usr/bin:$PATH
Attempts:
3 left
💡 Hint
Common Mistakes
Adding 'PATH=' inside the value which duplicates the key
Not including existing $PATH causing path loss
4fill in blank
hard

Fill both blanks to create a Jenkins pipeline stage that runs a shell command and archives the artifacts.

Jenkins
stage('Build') {
  steps {
    sh '[1]'
    archiveArtifacts '[2]'
  }
}
Drag options to blanks, or click blank then click option'
Amake build
Bmake test
C**/target/*.jar
D**/build/*.jar
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'make test' which runs tests but does not build
Archiving wrong artifact paths causing no files saved
5fill in blank
hard

Fill all three blanks to define a Jenkins pipeline that checks out code, runs tests, and sends a notification.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        [1] 'https://github.com/example/repo.git'
      }
    }
    stage('Test') {
      steps {
        sh '[2]'
      }
    }
    stage('Notify') {
      steps {
        [3] 'Build completed successfully'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Agit
Bmake test
Cecho
Dcheckout
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'checkout' instead of 'git' for cloning
Running wrong shell commands for tests
Using 'git' or 'checkout' for notification step