0
0
Jenkinsdevops~10 mins

Multi-branch pipeline job creation 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 define a multi-branch pipeline job in Jenkins using the correct job type.

Jenkins
job = Jenkins.createJob('[1]', 'MyMultiBranchJob')
Drag options to blanks, or click blank then click option'
AMultiBranchPipelineJob
BPipelineJob
CFreestyleProject
DMatrixProject
Attempts:
3 left
💡 Hint
Common Mistakes
Using PipelineJob instead of MultiBranchPipelineJob
Using FreestyleProject which does not support multi-branch pipelines
2fill in blank
medium

Complete the code to set the Git repository URL for the multi-branch pipeline job.

Jenkins
job.setSource(new GitSCMSource('[1]'))
Drag options to blanks, or click blank then click option'
Agit@github.com:example/repo.git
Bhttps://github.com/example/repo.git
Chttp://example.com/repo.git
Dftp://example.com/repo.git
Attempts:
3 left
💡 Hint
Common Mistakes
Using FTP URL which is not supported for Git SCM
Using SSH URL without proper credentials setup
3fill in blank
hard

Fix the error in the code to correctly add a branch source to the multi-branch pipeline job.

Jenkins
job.getSourcesList().add(new [1](new GitSCMSource('https://github.com/example/repo.git')))
Drag options to blanks, or click blank then click option'
ABranchSource
BGitBranchSource
CSCMSource
DMultiBranchSource
Attempts:
3 left
💡 Hint
Common Mistakes
Using GitBranchSource which does not exist
Using SCMSource which is abstract and cannot be added directly
4fill in blank
hard

Fill both blanks to configure the multi-branch pipeline job to scan branches every 1 day and set the script path.

Jenkins
job.setTriggers([new [1](1)])
job.setScriptPath('[2]')
Drag options to blanks, or click blank then click option'
APeriodicFolderTrigger
BSCMTrigger
CJenkinsfile
Dpipeline.groovy
Attempts:
3 left
💡 Hint
Common Mistakes
Using SCMTrigger which triggers on SCM changes, not periodic scans
Setting script path to pipeline.groovy which is not the default
5fill in blank
hard

Fill all three blanks to complete the multi-branch pipeline job creation with credentials and orphaned item strategy.

Jenkins
job.setSources([new BranchSource(new GitSCMSource('[1]').withCredentials('[2]'))])
job.setOrphanedItemStrategy(new [3](7))
Drag options to blanks, or click blank then click option'
Ahttps://github.com/example/repo.git
Bgithub-credentials-id
CDiscardOldItemsStrategy
DKeepAllItemsStrategy
Attempts:
3 left
💡 Hint
Common Mistakes
Using KeepAllItemsStrategy which never deletes old branches
Forgetting to set credentials causing SCM access errors