Create Multibranch Pipeline with Git - Jenkins Pipeline Tutorial for Beginners 2/4
Skills:
Delivery Management80%Tool Use & Function Calling70%Project Management Foundations60%AI Tools for PMs50%
Key Takeaways
Create a multibranch pipeline in Jenkins using Git, configure credentials, and discover branches by names using Java regular expressions.
Full Transcript
so now that we have our Jenkins set up we're gonna create a multi branch pipeline so the first step is we're gonna go to create new jobs or you can also use new item and create let's say pipeline and here the types of projects or builds that you can create and one of them here is multi branch pipeline so I'm gonna create this one and it opens the configuration options so let's go through some of these options so the first one is just a metadata name and description and branch source is basically the project which it's gonna build so here we're gonna add our gig project I have some demo projects which I'm gonna use and I'm just gonna just clone the URL of my project another thing that I need to configure here is which branches I want to build so this pipeline is multi branch so it allows me to build multiple branches with the same configuration so here I'm gonna say that I want to discover branches using regular expression and this is a Java regular expression so this one the default one right here means that it matches every branch so right now I just have two branches which is master and DEF and if I leave it like this it basically gonna build every branch that I have so if I were to add a new branch here like a feature branch it's gonna build that one as well so another part of build this build configuration is that is gonna build from jenkins file and this is just default configuration which we're going to leave as it is and the rest of it we're gonna leave for now as well now obviously it can connect to the git repository without credentials so what we need here is we need the username and password for this git repository so that Jenkins could check the code out of that git repository so in order to do that let's actually look at what credentials are in Jenkins and how to create and use them okay so let's go back to the main view of Jenkins and look at the credentials option in the sidebar so this is actually a plug-in that we installed and this is a pretty recent plug in addition to Jenkins so basically now Janie's offers a way to store and manage credentials centrally so instead of having it distributed across different plugins for different services you can create them in one place and then use that or reference it in different places including your projects Jenkins file so let's actually go inside and see that by default we just have one scope which is Jenkins go this is a global one and you have one domain under it so if I click here then I can go inside a domain and I see that I have no credentials so let's create one and here we see that we have two different scopes and this is important distinction here a system credential in Jenkins is basically available only for Jenkins server so for example if you're a Jenkins administrator that administers the Jenkins server that does all the administrative work for example configures Jenkins communication or interface with other services etc you're gonna create a system credential because system credential is not visible or accessible by Jenkins jobs for examples of in our pipeline we wouldn't see the Jenkins system credential the global credential however is accessible everywhere it's accessible to the janki's administrators and all the build jobs pipelines all shops so everything across Jenkins so that's the scope of the credential and then there is a type of credential the most commonly used one is username and password but of course you can also have other types so you can have a certificate you can have a secret file secret text if Jenkins needs to connect to some other services it might be using a secret file and not a username and password so I have different options here and also note that depending on what other plugins you have installed in Jenkins you might get new types of credentials so a new Jenkins plug-in might actually come with its own type of credential for example github I think has its own github user access token type so we're gonna use the username and password and I'm gonna actually create the global credential in the so username and password is obvious and the ID is very important here because this is how you're gonna reference credentials everywhere so in your build job or in a Jenkins file so this is an important one this is a handle to your credential so to say and I'm gonna create that one and I'm gonna create another one is system variables so I'm gonna call it system so now I have two of them and if I go back to my pipeline so note here this is very important as well so you have the credentials option here on the main page of Jenkins and if we go inside the newly created my pipeline you also see a credentials button here so what that is is basically a third scope so we just saw a system scope global scope and now this is a third scope and this scope is basically limited to your project and this comes only with the multi branch pipeline so other job types do not have this and this actually comes from a folder plugin so folder plug-in is basically for organizing your build jobs in folders and this enables you to have credentials scoped to your project so it means that if I create a pro credentials here in this scope so really again let's go here you see here we're not in Jenkins credentials but we are in Jenkins my pipeline credentials and here in this domain if I create credentials here and let's actually use username password I don't have a scope here anymore because it scoped to this pipeline so I'm gonna actually call it my pipeline I mean the names are pretty stupid but it's good for demonstrating the accessibility so I'm gonna create that one and if I go back to credentials I see that I have two credentials available for these projects for my pipeline so the global one that we created and my pipeline scope that we created so the system credential is not accessible for this project or for any other projects and this is a pretty good way to organize your credentials but also separate them so if we have for example a very complex very big deployment projects or we have two teams that have their own projects on the same Jenkins you can actually hide the credentials between the projects so each one will have their own credentials that will not be visible by others so for example we can actually see that as well so if I create another multi pipeline project and see here I only see the global credential that I created in a global scope but I don't see the my pipeline credentials here because it's only visible for my pipeline project so let's delete it and go back here so remember in config we still have to configure the credentials for the git repository so I'm gonna create in my pipeline scope so here my pipeline scope let's actually delete this one I don't need this and I'm gonna create here a username password for my git repository and I'm gonna call it what is this demo app its credentials or something which was created and now if I go back to my configuration so first of all I have it here this is the idea that we gave this is the reference to it so now if I actually refresh this and copy it again and if I click here I have all the available credentials to select from so the global one is here and one in my pipeline scope is also there so I'm gonna choose the correct one and I'm gonna save it so it's gonna build right away off her skin and then build so here you see that it's connected to the repository and it checked the branches but I didn't find Jenkins file in any of the branches because I don't have it yet and you didn't build anything so as the next step we're gonna create a Jenkins file in our repository but before that we're gonna see how to explicitly configure which branches of our repository we want to be built so let's see that so by default as you see the pipeline will scan all the branches that I have in the repository there is no limitation but in some cases you don't want to build all the branches let's say you have master and develop branches let's actually go and see our branches and let's say you have a lot of feature branches and you have a lot of bug fix branches but you don't want to build all of them with every commit maybe just want to build the dev branch and mast branch and some feature branches but you never want to build bug fix branches so how do you actually configure that in your pipeline so the way to do that is in discover branches section here you just say filter by name and by default as we saw it scans all the branches so this is actually a Java regular expression and this one here means that it's going to match any character 0 or many times so here we're gonna delete that one and we're gonna explicitly say that we want dev branch or master branch or feature branches right but future branches have different names so we're gonna add a regular expression here so we're gonna match any character after feature any number of times and since it's a Java a regular expression we can actually it start off line and end of line characters as well so this expression will not match any bug fix branches if they start with the name puck or bug fix for example so let's actually test that I'm gonna save it and it's a game kind of skin master and if now let's actually add a new branch called feature branch let's call it test or feature 1 whatever create branch and let's also create a bug one so now we have these branches and using a regular expression should match only these three and do not match bug so if I do skin multi branch pipeline now and I go to see the lock I see that master branch was skinned feature one in depth so that's how you decide explicitly which branches you want to be built using this a multi branch pipe line so you can exclude or include branches as you wish so now as you see in the skin locks it checks the branches but it doesn't find Jenkins file in any of them and it does nothing so let's go ahead and create a jenkins file in dev branch
Original Description
Create Multibranch Pipeline, configure credentials in Jenkins and discover branches by names.
In this video I show how to create a multibranch pipeline, explain how credentials plugin work in Jenkins and configure to filter branches by name.
▬▬▬▬▬▬ Topics covered
* Create Multibranch Pipeline
* Explain how Credentials Plugin work in Jenkins
* Filter Branches by Name
This is the 2nd part of a complete jenkins tutorial for beginners:
1) Run Jenkins in a Docker Container
2) Create Multibranch Pipeline with Git
3) Basic Jenkinsfile Syntax
4) Git Integration - Trigger Jenkins build automatically
⭐️Full Playlist: https://www.youtube.com/playlist?list=PLy7NrYWoggjw_LIiDK1LXdNN82uYuuuiC
For any questions/issues/feedback, please leave me a comment and I will get back to you as soon as possible.
#devops #jenkins #docker #techworldwithnana #devopstools
-------------------------------------------------------------------------------------------------------
Complete Docker and Kubernetes tutorial ► https://bit.ly/2YGeRp9
What is Kubernetes? ► https://youtu.be/VnvRFRk_51k
Docker 🐳 vs Kubernetes ► https://youtu.be/9_s3h_GVzZc
Complete Jenkins Pipeline Tutorial ► https://youtu.be/7KCS70sCoK0
--------------------------------------------------------------------------------------------------------
✅ Connect with me
Youtube ► https://www.youtube.com/channel/UCdngmbVKX1Tgre699-XLlUA
DEV ► https://dev.to/techworld_with_nana
Instagram ► https://www.instagram.com/techworld_with_nana/
Twitter ► https://twitter.com/Njuchi_/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from TechWorld with Nana · TechWorld with Nana · 25 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
▶
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
What is Docker? Docker container concept explained || Docker Tutorial 1
TechWorld with Nana
What is a Docker Container? Docker Demo || Docker Tutorial 2
TechWorld with Nana
How to install docker? Step by Step || Docker Tutorial 3
TechWorld with Nana
8 Basic Docker Commands || Docker Tutorial 4
TechWorld with Nana
Debugging Docker Containers with docker exec and docker logs || Docker Tutorial 5
TechWorld with Nana
Docker vs Virtual Machine | simply explained || Docker Tutorial 6
TechWorld with Nana
Overview of Workflow with Docker - Docker in Practice || Docker Tutorial 7
TechWorld with Nana
Developing with Docker - Docker in Practice || Docker Tutorial 8
TechWorld with Nana
Docker Compose Tutorial - Docker in Practice || Docker Tutorial 9
TechWorld with Nana
Dockerfile Tutorial - Docker in Practice || Docker Tutorial 10
TechWorld with Nana
Private Repository explained | Registry on AWS - Docker in Practice || Docker Tutorial 11
TechWorld with Nana
Docker Volumes explained in 6 minutes
TechWorld with Nana
Deploying the containerized application with Docker Compose || Docker Tutorial 12
TechWorld with Nana
Docker Volumes Demo || Docker Tutorial 13
TechWorld with Nana
Docker vs Kubernetes vs Docker Swarm | Comparison in 5 mins
TechWorld with Nana
What is Kubernetes | Kubernetes explained in 15 mins
TechWorld with Nana
Kubernetes Components explained! Pods, Services, Secrets, ConfigMap | Kubernetes Tutorial 14
TechWorld with Nana
Kubernetes Architecture explained | Kubernetes Tutorial 15
TechWorld with Nana
Benefits of Kubernetes | Scalability, High Availability, Disaster Recovery | Kubernetes Tutorial 16
TechWorld with Nana
Minikube and Kubectl explained | Setup for Beginners | Kubernetes Tutorial 17
TechWorld with Nana
Top 3 programming languages to learn in 2020 | meta analysis
TechWorld with Nana
Kubectl Basic Commands - Create and Debug Pod in a Minikube cluster | Kubernetes Tutorial 18
TechWorld with Nana
Kubernetes YAML File Explained - Deployment and Service | Kubernetes Tutorial 19
TechWorld with Nana
Run Jenkins in Docker Container - Jenkins Pipeline Tutorial for Beginners 1/4
TechWorld with Nana
Create Multibranch Pipeline with Git - Jenkins Pipeline Tutorial for Beginners 2/4
TechWorld with Nana
Jenkinsfile - Jenkins Pipeline Tutorial for Beginners 3/4
TechWorld with Nana
Trigger Jenkins Build automatically - Jenkins Pipeline Tutorial for Beginners 4/4
TechWorld with Nana
Complete Application Deployment using Kubernetes Components | Kubernetes Tutorial 20
TechWorld with Nana
Kubernetes Namespaces Explained in 15 mins | Kubernetes Tutorial 21
TechWorld with Nana
Configure Build Tools in Jenkins and Jenkinsfile | Jenkins Tutorial
TechWorld with Nana
Complete Jenkins Pipeline Tutorial | Jenkinsfile explained
TechWorld with Nana
Kubernetes Ingress Tutorial for Beginners | simply explained | Kubernetes Tutorial 22
TechWorld with Nana
What is Helm in Kubernetes? Helm and Helm Charts explained | Kubernetes Tutorial 23
TechWorld with Nana
How Websites Work | simply explained with examples
TechWorld with Nana
What is JavaScript? | JavaScript Tutorial #1
TechWorld with Nana
What is Ansible | Ansible Playbook explained | Ansible Tutorial for Beginners
TechWorld with Nana
JavaScript Variables & JavaScript Data Types explained | JavaScript Tutorial #2
TechWorld with Nana
How Prometheus Monitoring works | Prometheus Architecture explained
TechWorld with Nana
Where to write JavaScript | Where to execute JavaScript Code | JavaScript Tutorial #3
TechWorld with Nana
JavaScript Operators & JavaScript Conditionals | JavaScript Tutorial #4
TechWorld with Nana
Pods and Containers - Kubernetes Networking | Container Communication inside the Pod
TechWorld with Nana
Kubernetes Volumes explained | Persistent Volume, Persistent Volume Claim & Storage Class
TechWorld with Nana
Kubernetes ConfigMap and Secret as Kubernetes Volumes | Demo
TechWorld with Nana
Pull Image from Private Docker Registry in Kubernetes cluster | Demo
TechWorld with Nana
Kubernetes StatefulSet simply explained | Deployment vs StatefulSet
TechWorld with Nana
Yaml Tutorial | Learn YAML in 18 mins
TechWorld with Nana
Terraform explained in 15 mins | Terraform Tutorial for Beginners
TechWorld with Nana
Setup Prometheus Monitoring on Kubernetes using Helm and Prometheus Operator | Part 1
TechWorld with Nana
Managed Kubernetes Cluster explained | Kubernetes on Cloud (1/2)
TechWorld with Nana
Step by Step Application Deployment on LKE using Helm | Kubernetes on Cloud (2/2)
TechWorld with Nana
Kubernetes Operator simply explained in 10 mins
TechWorld with Nana
What is Infrastructure as Code? Difference of Infrastructure as Code Tools
TechWorld with Nana
AWS EKS - Create Kubernetes cluster on Amazon EKS | the easy way
TechWorld with Nana
Prometheus Monitoring - Steps to monitor third-party apps using Prometheus Exporter | Part 2
TechWorld with Nana
GitHub Actions Tutorial - Basic Concepts and CI/CD Pipeline with Docker
TechWorld with Nana
Docker Tutorial for Beginners [FULL COURSE in 3 Hours]
TechWorld with Nana
Kubernetes Services explained | ClusterIP vs NodePort vs LoadBalancer vs Headless Service
TechWorld with Nana
Kubernetes Tutorial for Beginners [FULL COURSE in 4 Hours]
TechWorld with Nana
Containers on AWS Overview: ECS | EKS | Fargate | ECR
TechWorld with Nana
Kubernetes is dropping Docker support - What does it mean for YOU?
TechWorld with Nana
More on: Delivery Management
View skill →
🎓
Tutor Explanation
DeepCamp AI