0
0
Jenkinsdevops~10 mins

Branch discovery configuration 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 enable branch discovery in Jenkins Multibranch Pipeline.

Jenkins
branchSources {
  git {
    id('1234')
    remote('https://github.com/example/repo.git')
    [1]
  }
}
Drag options to blanks, or click blank then click option'
AbranchDiscovery { strategyId(2) }
BbranchDiscovery { strategyId(1) }
CbranchDiscovery { strategyId(3) }
DbranchDiscovery { strategyId(4) }
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong strategyId disables branch discovery.
2fill in blank
medium

Complete the code to configure Jenkins to discover pull requests from origin.

Jenkins
branchSources {
  git {
    id('5678')
    remote('https://github.com/example/repo.git')
    pullRequestDiscovery {
      [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
AstrategyId(2)
BstrategyId(1)
CstrategyId(3)
DstrategyId(4)
Attempts:
3 left
💡 Hint
Common Mistakes
Using strategyId for fork PRs instead of origin PRs.
3fill in blank
hard

Fix the error in the branch discovery configuration to correctly discover branches.

Jenkins
branchSources {
  git {
    id('91011')
    remote('https://github.com/example/repo.git')
    branchDiscovery {
      [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
AstrategyId(0)
BstrategyId(5)
CstrategyId(1)
DstrategyId(2)
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid strategyId causes Jenkins to ignore branches.
4fill in blank
hard

Fill both blanks to configure Jenkins to discover branches and pull requests from forks.

Jenkins
branchSources {
  git {
    id('121314')
    remote('https://github.com/example/repo.git')
    branchDiscovery {
      [1]
    }
    pullRequestDiscovery {
      [2]
    }
  }
}
Drag options to blanks, or click blank then click option'
AstrategyId(2)
BstrategyId(1)
CstrategyId(4)
DstrategyId(3)
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up strategy IDs for branch and PR discovery.
5fill in blank
hard

Fill all three blanks to configure Jenkins Multibranch Pipeline for branch discovery, origin PRs, and fork PRs.

Jenkins
branchSources {
  git {
    id('151617')
    remote('https://github.com/example/repo.git')
    branchDiscovery {
      [1]
    }
    pullRequestDiscovery {
      strategyId([2])
    }
    pullRequestDiscovery {
      strategyId([3])
    }
  }
}
Drag options to blanks, or click blank then click option'
AstrategyId(2)
B3
C4
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing strategy IDs for origin and fork PRs.