0
0
Jenkinsdevops~10 mins

Why SCM integration is foundational in Jenkins - Test Your Understanding

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

Complete the code to specify the SCM repository URL in a Jenkins pipeline.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        checkout([$class: 'GitSCM', branches: [[name: '*/main']], userRemoteConfigs: [[url: '[1]']]])
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ahttps://github.com/example/repo.git
Bmain
CGitSCM
Dagent any
Attempts:
3 left
💡 Hint
Common Mistakes
Putting branch name instead of URL
Using incorrect field names
Missing quotes around URL
2fill in blank
medium

Complete the code to define the branch to checkout in the Jenkins pipeline.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        checkout([$class: 'GitSCM', branches: [[name: '[1]']], userRemoteConfigs: [[url: 'https://github.com/example/repo.git']]])
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Afeature
Bdevelop
Cmain
Dmaster
Attempts:
3 left
💡 Hint
Common Mistakes
Using branch names that don't exist
Confusing branch with repository URL
3fill in blank
hard

Fix the error in the Jenkins pipeline code to correctly checkout the code from SCM.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        checkout([$class: '[1]', branches: [[name: '*/main']], userRemoteConfigs: [[url: 'https://github.com/example/repo.git']]])
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AGit
BSCM
CGitCheckout
DGitSCM
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names
Typos in class name
4fill in blank
hard

Fill both blanks to configure polling SCM changes and trigger builds automatically.

Jenkins
pipeline {
  agent any
  triggers {
    pollSCM('[1]')
  }
  stages {
    stage('Checkout') {
      steps {
        checkout([$class: 'GitSCM', branches: [[name: '[2]']], userRemoteConfigs: [[url: 'https://github.com/example/repo.git']]])
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AH/5 * * * *
B*/10 * * * *
Cmain
Ddevelop
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid cron syntax
Wrong branch name in checkout
5fill in blank
hard

Fill all three blanks to define a Jenkins pipeline that checks out code, builds, and archives artifacts.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        checkout([$class: 'GitSCM', branches: [[name: '[1]']], userRemoteConfigs: [[url: '[2]']]])
      }
    }
    stage('Build') {
      steps {
        sh '[3]'
      }
    }
  }
  post {
    success {
      archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
    }
  }
}
Drag options to blanks, or click blank then click option'
Amain
Bhttps://github.com/example/repo.git
Cmvn clean package
Dnpm install
Attempts:
3 left
💡 Hint
Common Mistakes
Wrong branch or URL
Incorrect build command for the project type