0
0
Jenkinsdevops~5 mins

Jenkinsfile per branch - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Jenkinsfile?
A Jenkinsfile is a text file that contains the pipeline code for Jenkins to automate tasks like building, testing, and deploying software.
Click to reveal answer
beginner
Why use a Jenkinsfile per branch?
Using a Jenkinsfile per branch lets each branch have its own pipeline steps, so you can test or deploy differently depending on the branch.
Click to reveal answer
intermediate
How does Jenkins decide which Jenkinsfile to use when building a branch?
Jenkins checks out the branch code and uses the Jenkinsfile found in that branch's root directory to run the pipeline.
Click to reveal answer
intermediate
What is a simple way to test different Jenkinsfiles for different branches?
Create a Jenkinsfile in each branch with the specific pipeline steps you want, then Jenkins will run the pipeline from that file when building that branch.
Click to reveal answer
beginner
Can you use a shared Jenkinsfile for all branches instead of one per branch?
Yes, you can use one Jenkinsfile for all branches, but using one per branch gives more flexibility to customize pipelines per branch.
Click to reveal answer
What does Jenkins use to run a pipeline for a specific branch?
AA Jenkinsfile from a random branch
BA global Jenkinsfile from the master branch
CA Jenkinsfile stored on the Jenkins server only
DThe Jenkinsfile in that branch's code
Why might you want a different Jenkinsfile per branch?
ATo customize build and deploy steps per branch
BTo confuse the Jenkins server
CBecause Jenkins requires it
DTo avoid using pipelines
If you add a Jenkinsfile only to the main branch, what happens when Jenkins builds a feature branch without a Jenkinsfile?
AJenkins will use the main branch Jenkinsfile automatically
BJenkins will create a Jenkinsfile for the branch
CJenkins will fail or not run the pipeline
DJenkins will skip the build
How can you manage common pipeline steps across branches while using Jenkinsfile per branch?
AUse shared libraries or include common scripts
BCopy the entire Jenkinsfile manually to each branch
CUse no Jenkinsfile at all
DRun pipelines only on the master branch
What is the best practice for storing Jenkinsfiles in a Git repository?
AStore Jenkinsfile in a separate repository
BStore Jenkinsfile in the root directory of each branch
CStore Jenkinsfile only on the Jenkins server
DStore Jenkinsfile in a hidden folder outside the repo
Explain how Jenkins uses Jenkinsfiles when building different branches in a Git repository.
Think about how Jenkins finds and runs pipeline code per branch.
You got /4 concepts.
    Describe the advantages of having a Jenkinsfile per branch compared to a single Jenkinsfile for all branches.
    Consider why branches might need different automation steps.
    You got /4 concepts.