Bird
Raised Fist0
Jenkinsdevops~20 mins

Branch indexing and scanning in Jenkins - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Branch Indexing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What happens during branch indexing in Jenkins Multibranch Pipeline?

In Jenkins Multibranch Pipeline, what is the main purpose of branch indexing?

AIt runs all the builds for every branch found in the repository.
BIt deletes old build artifacts from all branches to save disk space.
CIt scans the source repository to discover branches and creates jobs for each branch.
DIt merges all branches into the main branch automatically.
Attempts:
2 left
💡 Hint

Think about what Jenkins needs to do before it can build branches.

💻 Command Output
intermediate
2:00remaining
Output of branch indexing scan log in Jenkins

What output would you expect to see in Jenkins logs after a successful branch indexing scan?

Jenkins
Started branch indexing
Found branches: feature1, bugfix2
Created jobs for branches
Finished branch indexing
ADeleted old branches\nCleaned workspace
BError: No branches found\nBranch indexing aborted
CStarted build for branch feature1\nBuild successful
DStarted branch indexing\nFound branches: feature1, bugfix2\nCreated jobs for branches\nFinished branch indexing
Attempts:
2 left
💡 Hint

Look for messages about scanning and job creation, not building or errors.

❓ Configuration
advanced
2:00remaining
Configuring branch indexing frequency in Jenkins Multibranch Pipeline

Which configuration snippet correctly sets branch indexing to run every 15 minutes in a Jenkinsfile?

Aproperties([pipelineTriggers([cron('H/15 * * * *')])])
Btriggers { cron('*/15 * * * *') }
Coptions { timeout(time: 15, unit: 'MINUTES') }
Dpipeline { triggers { pollSCM('H/15 * * * *') } }
Attempts:
2 left
💡 Hint

Branch indexing frequency is set via pipeline triggers with cron syntax.

❓ Troubleshoot
advanced
2:00remaining
Why does Jenkins fail to detect new branches during indexing?

After adding new branches to the repository, Jenkins Multibranch Pipeline does not detect them during branch indexing. What is a likely cause?

AThe Jenkinsfile in the new branches contains syntax errors.
BThe repository credentials used by Jenkins lack read permission for the new branches.
CThe build triggers are set to manual only.
DThe Jenkins server is running out of disk space.
Attempts:
2 left
💡 Hint

Think about access rights Jenkins needs to see branches.

🔀 Workflow
expert
3:00remaining
Order the steps Jenkins performs during branch indexing and scanning

Put the following Jenkins branch indexing steps in the correct order.

A1,2,3,4
B1,3,2,4
C2,1,3,4
D3,1,2,4
Attempts:
2 left
💡 Hint

Think about discovery first, then job creation, then triggers, then finishing.

Practice

(1/5)
1. What is the main purpose of branch indexing in Jenkins Multibranch Pipeline jobs?
easy
A. To manually trigger builds for a single branch
B. To delete old builds from the Jenkins server
C. To automatically discover and build all branches in a repository
D. To configure user permissions for branches

Solution

  1. Step 1: Understand branch indexing concept

    Branch indexing automatically finds all branches in a source code repository for Jenkins to build.
  2. Step 2: Identify its main benefit

    This avoids manual job creation for each branch, saving time and effort.
  3. Final Answer:

    To automatically discover and build all branches in a repository -> Option C
  4. Quick Check:

    Branch indexing = automatic branch discovery [OK]
Hint: Branch indexing means Jenkins finds branches itself [OK]
Common Mistakes:
  • Thinking branch indexing triggers manual builds only
  • Confusing branch indexing with build cleanup
  • Assuming it manages user permissions
2. Which Jenkins job type should you use to enable branch indexing and scanning?
easy
A. Multibranch Pipeline
B. Freestyle project
C. Matrix project
D. External job

Solution

  1. Step 1: Identify job types in Jenkins

    Freestyle and Matrix projects do not support automatic branch discovery.
  2. Step 2: Recognize Multibranch Pipeline features

    Multibranch Pipeline jobs are designed to scan repositories and index branches automatically.
  3. Final Answer:

    Multibranch Pipeline -> Option A
  4. Quick Check:

    Branch indexing requires Multibranch Pipeline job [OK]
Hint: Use Multibranch Pipeline for branch scanning [OK]
Common Mistakes:
  • Choosing Freestyle project which lacks branch scanning
  • Confusing Matrix project with Multibranch Pipeline
  • Selecting External job which is unrelated
3. Given a Multibranch Pipeline job configured to scan every 1 hour, what happens when a new branch is pushed to the repository?
medium
A. Jenkins immediately builds the new branch
B. Jenkins ignores the new branch until manual scan
C. Jenkins deletes the new branch from the repository
D. Jenkins detects and indexes the new branch during the next scheduled scan

Solution

  1. Step 1: Understand scan trigger timing

    The job is set to scan branches every 1 hour, not instantly.
  2. Step 2: Predict behavior on new branch push

    Jenkins will detect and index the new branch during the next scheduled scan, not immediately.
  3. Final Answer:

    Jenkins detects and indexes the new branch during the next scheduled scan -> Option D
  4. Quick Check:

    Scheduled scan finds new branches [OK]
Hint: Scheduled scans find new branches, not instant builds [OK]
Common Mistakes:
  • Assuming immediate build on branch push
  • Thinking Jenkins ignores new branches without manual scan
  • Believing Jenkins deletes new branches automatically
4. You configured a Multibranch Pipeline job but Jenkins does not detect new branches after pushing them. What is the most likely cause?
medium
A. The Jenkins server is offline
B. Branch indexing is disabled or scan trigger is not set
C. The repository URL is incorrect
D. The branches are deleted automatically after scan

Solution

  1. Step 1: Check branch indexing settings

    If branch indexing or scan triggers are disabled, Jenkins won't detect new branches automatically.
  2. Step 2: Consider other causes

    Incorrect repo URL or offline server would cause broader failures, not just missing branches.
  3. Final Answer:

    Branch indexing is disabled or scan trigger is not set -> Option B
  4. Quick Check:

    Branch indexing must be enabled for detection [OK]
Hint: Enable branch indexing and scan triggers to detect branches [OK]
Common Mistakes:
  • Ignoring branch indexing settings
  • Assuming Jenkins deletes branches automatically
  • Blaming repository URL without checking indexing
5. How can you configure a Jenkins Multibranch Pipeline job to automatically build only branches matching the pattern feature/* during branch indexing?
hard
A. Set the Branch Sources filter with feature/* under 'Include branches matching' pattern
B. Manually create jobs for each feature branch
C. Use a post-build script to delete other branches
D. Configure the job to scan all branches without filters

Solution

  1. Step 1: Use branch source filtering

    Jenkins Multibranch Pipeline allows filtering branches by patterns in the Branch Sources settings.
  2. Step 2: Apply the pattern filter

    Setting 'Include branches matching' to feature/* ensures only those branches are indexed and built.
  3. Final Answer:

    Set the Branch Sources filter with feature/* under 'Include branches matching' pattern -> Option A
  4. Quick Check:

    Branch filters limit builds to matching branches [OK]
Hint: Use branch source filters to build specific branch patterns [OK]
Common Mistakes:
  • Creating manual jobs instead of using filters
  • Not applying branch filters and building all branches
  • Using post-build scripts to filter branches incorrectly
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard