0
0
Jenkinsdevops~10 mins

Multiple SCM repositories 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 pipeline with two SCM repositories.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        [1] [
          $class: 'GitSCM',
          branches: [[name: '**']],
          userRemoteConfigs: [[url: 'https://github.com/example/repo1.git']]
        ]
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Arun
Bbuild
Ccheckout
Ddeploy
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'build' or 'run' instead of 'checkout' will cause errors.
2fill in blank
medium

Complete the code to add a second SCM repository checkout in the same stage.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        checkout scm
        [1] [
          $class: 'GitSCM',
          branches: [[name: '**']],
          userRemoteConfigs: [[url: 'https://github.com/example/repo2.git']]
        ]
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Acheckout
Brun
Cbuild
Ddeploy
Attempts:
3 left
💡 Hint
Common Mistakes
Using other step names like 'build' will not work.
3fill in blank
hard

Fix the error in the code to correctly checkout two repositories in parallel.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        parallel {
          repo1: {
            [1] [
              $class: 'GitSCM',
              branches: [[name: '**']],
              userRemoteConfigs: [[url: 'https://github.com/example/repo1.git']]
            ]
          },
          repo2: {
            [1] [
              $class: 'GitSCM',
              branches: [[name: '**']],
              userRemoteConfigs: [[url: 'https://github.com/example/repo2.git']]
            ]
          }
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Acheckout
Bbuild
Crun
Ddeploy
Attempts:
3 left
💡 Hint
Common Mistakes
Using different step names causes syntax errors.
4fill in blank
hard

Fill both blanks to define two SCM repositories with different branches.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        checkout scm: [
          $class: 'GitSCM',
          branches: [[name: '[1]']],
          userRemoteConfigs: [[url: 'https://github.com/example/repo1.git']]
        ]
        checkout scm: [
          $class: 'GitSCM',
          branches: [[name: '[2]']],
          userRemoteConfigs: [[url: 'https://github.com/example/repo2.git']]
        ]
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Arefs/heads/main
Brefs/heads/develop
Crefs/heads/feature
Drefs/heads/release
Attempts:
3 left
💡 Hint
Common Mistakes
Using branch names without 'refs/heads/' prefix causes errors.
5fill in blank
hard

Fill all three blanks to create a map of repository names to their URLs and branches.

Jenkins
def repos = [
  '[1]': [url: 'https://github.com/example/repo1.git', branch: '[2]'],
  '[3]': [url: 'https://github.com/example/repo2.git', branch: 'refs/heads/develop']
]
Drag options to blanks, or click blank then click option'
Arepo1
Brefs/heads/main
Crepo2
Drefs/heads/feature
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up repo names or missing the branch prefix.