0
0
Jenkinsdevops~10 mins

Branch indexing and scanning 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 trigger branch indexing in a Jenkins Pipeline.

Jenkins
properties([pipelineTriggers([[1]('H/5 * * * *')])])
Drag options to blanks, or click blank then click option'
Acron
BgithubPush
CpollSCM
DtimerTrigger
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cron' instead of 'pollSCM' triggers a scheduled job but does not specifically trigger branch indexing.
Using 'githubPush' only triggers on GitHub push events, not branch indexing.
Using 'timerTrigger' is not a valid Jenkins trigger.
2fill in blank
medium

Complete the code to scan all branches in a Multibranch Pipeline job.

Jenkins
multibranchPipelineJob('example') {
  branchSources {
    git {
      id('1234')
      remote('https://github.com/example/repo.git')
    }
  }
  [1] {
    cron('H * * * *')
  }
}
Drag options to blanks, or click blank then click option'
AscanTriggers
Bscanners
Ctriggers
DbranchSources
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'triggers' configures build triggers, not branch scanning.
Using 'branchSources' defines the source repositories, not scanning triggers.
Using 'scanners' is not a valid block name.
3fill in blank
hard

Fix the error in the Jenkinsfile to correctly scan branches every 15 minutes.

Jenkins
multibranchPipelineJob('example') {
  scanTriggers {
    cron('[1]')
  }
}
Drag options to blanks, or click blank then click option'
AH/15 * * * *
B*/15 * * * *
C15 * * * *
DH/5 * * * *
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*/15 * * * *' works in standard cron but Jenkins recommends 'H/15' for better load distribution.
Using '15 * * * *' runs only once per hour at minute 15.
Using 'H/5 * * * *' runs every 5 minutes, not 15.
4fill in blank
hard

Fill both blanks to configure branch indexing to exclude branches matching a pattern and to set the scan interval.

Jenkins
multibranchPipelineJob('example') {
  branchSources {
    git {
      remote('https://github.com/example/repo.git')
      [1]('feature/*')
    }
  }
  scanTriggers {
    cron('[2]')
  }
}
Drag options to blanks, or click blank then click option'
AexcludeBranches
BincludeBranches
CH/10 * * * *
DH/30 * * * *
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'includeBranches' instead of 'excludeBranches' changes which branches are scanned.
Using 'H/30 * * * *' scans every 30 minutes, not 10.
Omitting branch exclusion causes all branches to be scanned.
5fill in blank
hard

Fill all three blanks to create a Jenkinsfile snippet that scans branches, includes only 'main' and 'release/*' branches, and triggers scanning every 20 minutes.

Jenkins
multibranchPipelineJob('example') {
  branchSources {
    git {
      remote('https://github.com/example/repo.git')
      [1]('main')
      [2]('release/*')
    }
  }
  scanTriggers {
    cron('[3]')
  }
}
Drag options to blanks, or click blank then click option'
AincludeBranches
BexcludeBranches
CH/20 * * * *
DbranchFilter
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'excludeBranches' instead of 'includeBranches' changes the scanning behavior.
Using 'branchFilter' is not a valid method here.
Using incorrect cron syntax causes scanning to fail or run at wrong intervals.