Bird
Raised Fist0
Jenkinsdevops~10 mins

Why multi-branch pipelines matter in Jenkins - Test Your Understanding

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

Complete the code to define a multi-branch pipeline in Jenkinsfile.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        [1] 'echo Building...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abat
Bscript
Csh
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'script' instead of 'sh' for shell commands.
2fill in blank
medium

Complete the code to specify the branch source in a Jenkins multi-branch pipeline configuration.

Jenkins
multibranchPipelineJob('example') {
  branchSources {
    git {
      id('[1]')
      remote('https://github.com/example/repo.git')
    }
  }
}
Drag options to blanks, or click blank then click option'
A1234abcd
Bmain
Corigin
Dmaster
Attempts:
3 left
💡 Hint
Common Mistakes
Using branch names like 'main' or 'master' as the id.
3fill in blank
hard

Fix the error in the Jenkinsfile to correctly define a multi-branch pipeline stage.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        [1] 'echo Testing...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abat
Bsh
Cinput
Dstage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stage' inside steps or 'input' instead of 'sh'.
4fill in blank
hard

Fill both blanks to complete the Jenkins multi-branch pipeline script that checks out the code and runs a build.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        [1] scm
      }
    }
    stage('Build') {
      steps {
        [2] 'make build'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Acheckout
Bsh
Cbat
Dscript
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'script' instead of 'sh' for build commands.
5fill in blank
hard

Fill all three blanks to create a Jenkins multi-branch pipeline that triggers on branch changes, checks out code, and runs tests.

Jenkins
multibranchPipelineJob('project') {
  triggers {
    [1] {
      interval('1d')
    }
  }
  branchSources {
    git {
      id('abc123')
      remote('https://github.com/example/project.git')
    }
  }
  factory {
    workflowBranchProjectFactory {
      scriptPath('[2]')
    }
  }
}
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        [3] 'pytest'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AperiodicFolderTrigger
BJenkinsfile
Csh
DpollSCM
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pollSCM' instead of 'periodicFolderTrigger' for triggers.

Practice

(1/5)
1. What is the main benefit of using a multi-branch pipeline in Jenkins?
easy
A. It disables branch-specific testing.
B. It only builds the main branch to save resources.
C. It requires manual setup for each branch.
D. It automatically creates pipelines for all branches in a repository.

Solution

  1. Step 1: Understand multi-branch pipeline purpose

    Multi-branch pipelines automatically detect branches and create pipelines for each.
  2. Step 2: Compare options

    Only It automatically creates pipelines for all branches in a repository. describes automatic creation for all branches, others are incorrect.
  3. Final Answer:

    It automatically creates pipelines for all branches in a repository. -> Option D
  4. Quick Check:

    Multi-branch pipelines = automatic branch pipelines [OK]
Hint: Multi-branch means all branches get pipelines automatically [OK]
Common Mistakes:
  • Thinking pipelines run only on main branch
  • Assuming manual setup is needed per branch
  • Believing multi-branch disables testing
2. Which Jenkinsfile location is correct for a multi-branch pipeline to detect a branch?
easy
A. In the root directory of each branch
B. Only in the main branch root
C. In a separate shared folder outside branches
D. Inside Jenkins system configuration

Solution

  1. Step 1: Identify Jenkinsfile placement

    Multi-branch pipelines look for Jenkinsfile in each branch root to build that branch.
  2. Step 2: Evaluate options

    Only In the root directory of each branch correctly states Jenkinsfile must be in each branch root.
  3. Final Answer:

    In the root directory of each branch -> Option A
  4. Quick Check:

    Jenkinsfile per branch root = correct location [OK]
Hint: Jenkinsfile must be in each branch root for detection [OK]
Common Mistakes:
  • Placing Jenkinsfile only in main branch
  • Putting Jenkinsfile outside branch folders
  • Expecting Jenkins to read Jenkinsfile from config
3. Given a multi-branch pipeline setup, what happens when a new branch is pushed to the repository?
medium
A. Jenkins ignores the new branch until manually added.
B. Jenkins automatically creates and runs a pipeline for the new branch.
C. Jenkins deletes old branches automatically.
D. Jenkins merges the new branch into main automatically.

Solution

  1. Step 1: Understand multi-branch pipeline behavior on new branches

    Multi-branch pipelines detect new branches and create pipelines automatically.
  2. Step 2: Analyze options

    Only Jenkins automatically creates and runs a pipeline for the new branch. correctly describes automatic creation and running of pipeline for new branch.
  3. Final Answer:

    Jenkins automatically creates and runs a pipeline for the new branch. -> Option B
  4. Quick Check:

    New branch triggers automatic pipeline creation [OK]
Hint: New branches trigger automatic pipeline creation [OK]
Common Mistakes:
  • Thinking manual addition is required
  • Confusing branch creation with branch deletion
  • Assuming Jenkins merges branches automatically
4. You set up a multi-branch pipeline but Jenkins does not detect new branches. What is the most likely cause?
medium
A. The Jenkins server is offline.
B. The repository URL is incorrect.
C. The Jenkinsfile is missing in the new branches.
D. The main branch Jenkinsfile has syntax errors.

Solution

  1. Step 1: Check Jenkinsfile presence in branches

    Multi-branch pipelines require Jenkinsfile in each branch to detect and build it.
  2. Step 2: Evaluate other causes

    While repository URL or server issues can cause problems, missing Jenkinsfile in new branches is the most common cause for detection failure.
  3. Final Answer:

    The Jenkinsfile is missing in the new branches. -> Option C
  4. Quick Check:

    Missing Jenkinsfile = no branch detection [OK]
Hint: Check Jenkinsfile exists in each branch to fix detection [OK]
Common Mistakes:
  • Ignoring Jenkinsfile absence in new branches
  • Assuming main branch Jenkinsfile affects others
  • Blaming server offline without checking files
5. How does using multi-branch pipelines improve project safety and developer productivity?
hard
A. By automatically testing every branch, catching errors early, and saving manual setup time.
B. By only building the main branch to reduce resource usage.
C. By requiring developers to manually trigger builds for each branch.
D. By disabling builds on feature branches to avoid conflicts.

Solution

  1. Step 1: Understand benefits of multi-branch pipelines

    They automate testing for all branches, catching errors early and saving manual setup time.
  2. Step 2: Compare options

    Only By automatically testing every branch, catching errors early, and saving manual setup time. correctly lists these benefits; others limit builds or require manual work.
  3. Final Answer:

    By automatically testing every branch, catching errors early, and saving manual setup time. -> Option A
  4. Quick Check:

    Auto test + early error catch + save time = multi-branch benefit [OK]
Hint: Multi-branch pipelines catch errors early and save setup time [OK]
Common Mistakes:
  • Thinking only main branch is built
  • Believing manual triggers are needed
  • Assuming feature branches are skipped
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