0
0
Jenkinsdevops~10 mins

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

Choose your learning style9 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.