LetsDevOps: Parameterized YAML Pipeline in Azure DevOps, how to use parameters in yaml pipeline.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome to Let's devops I am  Sumit and today we will learn how to create   a parameterized yaml pipeline in azure devops  so in this tutorial first we will understand   what is parameters in yaml pipeline second we'll  understand why we need to create a parameterized   ml pipeline third we'll see the syntax and keyword  to create a pipeline and fourth based on the   multiple scenario we'll create a parameterized  pipeline for the demo so let's start let's   discuss what is the parameterized yaml pipeline a  pipeline which gives option to a user to fill the   information before running the pipeline so that is  called as a parameterized pipeline so it's nothing   but like providing a user interface to fill out  the information before running your pipeline   now let's understand why do we need  a parameterized yaml pipeline in some   of the use case or scenario which we will also  discuss in our demo it is required to create a   parameterized pipeline like assume that if I want  to create a pipeline where I have I will give an   option to select which application to build or  deploy in that case we can create a pipeline as   a parameterized pipeline the second may be in  some some kind of automation like if you want   to run or deploy or run some custom script on  a specific environment then in that case also   we can create a parameterized pipeline and also  for uh your custom pipeline like maybe building   uh testing or deploying if you want to only  deploy a specific application or if you want   to only build a specific application then in that  case also we can create a parameterized pipeline   now let's discuss the keyword or the schema of  parameterize pipeline so if you if you notice   here we have the parameters that is a keyword with  that we can um create a parameterized pipeline   and if I see the parameters means that you can  create a multiple parameter in a single pipeline   so for one parameter entity maybe we can Define  with the name the display name the type default   and its values so this details also will see  in our demo but this is kind of on schema to   Define one single parameter entity in pipeline  so as I said that we can also create a multiple   parameters entity but for one we need to First  Define the name the display name the type of   the the parameter and then the default value or  if you want to maybe provide some list of value   where user can select in that case also we can  Define the value so coming to that the keyword   if you see here each are like a keyword and it  has kind of a its own of uh definition in it   right so parameters which is helps to Define  uh your pipeline as a parameterized pipeline   then the name of the parameter then what kind of  a type whether it is stream Boolean or number then   what what the display name you wanted to give  and ah it it comes as a user interface what is   the default value you want to keep but it is  an optional and also the values if you want to   give a kind of a list of value then in that case  you can give it but it is also kind of optional   so name and type is mandatory that we need to give  it let's take a basic example to understand better   let's assume that I have an application which  has a multiple modules in it right like assume   that I have application which also has a payment  module profile module or admin module and I want   to build or a deploy each model separately but  not all of them in one right in that case what   I can do I can maybe create a parameterized  yaml pipeline where user can select Which   models to build or a deploy right so let's see  that maybe in this syntax so here what I did I   created one parameter where maybe your user can  select a project name which needs to be built or   a deployer so what I'll Define I'll Define the  name then the type and then after that display   name and then I also I can provide a values like  maybe I know that I have a four different modules   maybe the payment profile admin and online  payment and based on the selection I need to   build that application or maybe to deploy so  let's see how the user interface looks like   okay so this is how it looks like so  maybe you have options to select it   now so once we created that the yaml parameterized  yaml pipeline then we need to also see how we can   use the parameter values in a subsequent bill or  a deployment right so for that we need to use this   keyword that parameters dot parameter name and  after that we can use that in a ml pipeline so   this is one of the example which I have given  here now coming to the demo in this demo what   we'll do we'll create a parameterized pipeline to  run a specific project under the solution file ah   maybe for a bill or for a deployment okay so if  you notice here in this repository I have one   online deployment.solution file which is kind  of a holds multiple modules like project profile   payment and then the online payment this is  something a sample project which I created   uh for demo purpose and as part of the the  pipeline execution I will I need to set it   up such a way that only a specific model needs  to be billed or deployed right so let's start   so to create a pipeline first I'll go here  and then I will click on the new pipeline and then we will create a yaml pipeline right  because we are going to create it and then   under that you will have a demo and after that  we'll maybe pick it the starter pipeline okay   so this is the starter pipeline as of now  what I'll do I'll try to delete all of them   and maybe maybe I will start with the name so  this is basically the yaml uh yaml format if   you are new to the yaml pipeline I have created  another tutorial you can just go through that I   will add that in a video description so okay  so maybe I will give the name as a demo param   from pipeline okay so this will be the name  and after that to create a parameters right   I need to Define with the keyword parameters  okay and here the first thing that you need   to define the name so what is the name of your  parameter so I'll give a maybe the project name and after that we need to maybe select  the type so maybe it is a string   and then we have also options  to select a default value okay and and okay so since we had the payment  the admin online payment and the profile so   maybe I'll just select the the payment project  as of now and here we can also add the values   like assume that if I want to keep the default as  a payment but the user can also have options to   select some different based on that available  value in that case what I'll do I'll admin   maybe the payment I'll have a online payment  something like that and then maybe I'll have a   profile so this is uh the value which I'm listing  based on the project name maybe for your case you   will have a different profile name or maybe the  different modules you can specify in that way okay   so this is how we Define the parameter so  first what we need to do we need to define   the parameters with the parameter keyword  the name the type default and then its values   so here this is the one parameter right but you  can also Define the multiple assuming that I   want to define the second parameter whether I  want to to also deploy uh definitely I want to   build but also want to deploy or not in that  case I can maybe create a name as a deploy   and then the type should be uh the Boolean and the  default value I'll maybe keep it as a false right   so it can be either true or false but by default  I'll give it so this is how you have to define the   parameters right now coming to that let's define  the pool where it will run so name will be default   okay and after that we need to find the  steps so basically I need to build a   the the visual studio right  so I'll just select the   task Visual Studio build and here I know  because yeah we are building uh one of the   module out of the solution file so just I'll  add the arguments so that it will only build the specific project so T and  then here I can maybe provide   so this is the value which will pick it from the  the parameter right I'll just give the parameters   and this is how you have to  declare the parameters value   so parameters dot the name of the project  right so assume that if I'll go with that way   okay and then maybe let's add it so now we  have uh they created a pipeline let's run   the pipeline and if you run the pipeline  you can see here the options to select   it is giving as a pop-up to pick up the project  name and then here also you see this is a kind   of uh the second parameter which we added just  for kind of information so by default it is kind   of unchecked but if you want to check it that  also you can do that but as of now we haven't   set it up just we have given for example so  I will just uncheck it and then I'll create   I'll just select the payment in this case what it  will do it will only deploy the payment project   in the solutions right so let's trigger  that I think I need to run it like this so now uh the the deployment has been  triggered sorry the pipeline has been triggered   and currently it is running so let's see from the   log also we can see whether it picked  up the right uh project or not okay So currently it is running and right now the  name is coming as a demo 3 you can also rename   it so assume that if I want to change the  name and then I'll give that uh demo param and then here I can just save it okay okay fine so the current lead is running okay now it has been completed so  let's go to the the visual studio here   and let's see whether it  picked it of the right one   so if you notice here it is uh kind of building  this online payment solution and then must use the [Music]   payment right so here if you notice that is just  kind of the the build the payment project and now   it is creating um that effect also so this so  in this demo we just saw a basic ml pipeline   let's discuss some of the scenario where  you can also use a parameterizable pipeline   so scenario one says that assume that if a devops  role like you're a devops engineer and you want to   set up some of the build or release pipeline for  the QA and development because for production or   maybe for the performance you want to handle but  for the Q and Dev you want to set up some Pipeline   and hand it over to them so that they can use  it and in this scenario what you can do maybe   you can configure a pipeline in a user interface  format so that they can go and run it and based   on their request or demand they can trigger the  pipeline maybe if they want to just build or if   you just wanted to do a build and deployment those  kind of uh scenario or like use case you can set   it up in your pipeline and they can use based on  their requirement right so if you if you notice   here this is the yaml kind of a pipeline which I  have added here where you can maybe provide the   parameter as a project name you can also provide  that environment type and whether you wanted to   run the unit test or you wanted to do a deployment  those thing you can go and check it and based on   that information you will deploy like assume  that here I am first building the application   specific project and then if you want to run the  unit test then if it is like true I've added a   condition then it will run this particular part to  do a unit test and if you want to deploy again if   you it is a kind of a Boolean parameter we added  and if it is like true then only it will run this   particular step or a stage right so this is how  we can customize your yaml parameterize pipeline   the other use case also can be or the scenario  can be maybe if you are running or creating some   automation like uh you want to run or you want to  provide some accesses to the the Azure resources   or anything as such you wanted to create that  Pipeline and then you want to maybe hand over   or whether you wanted to use it for your own then  in that case also it is very helpful because you   don't have to always go and check the script and  all you can develop a script and you can maybe   create a UI type of automation where user can  select it and then they can run it as per the   requirement like here in the scenario to what we  are doing we are kind of granting access to Azure   resources so we can create a pipeline where you  can select a subscription web app Resource Group   user account and the access type and then based  on that you will give the access right so here   you can create a multiple parameter user can  select it and based on the selection it will   grant access to a specific resource so these are  some of the use case and scenario maybe you can   use it for a parameterized yaml pipeline and I  for all the automation I found it is very useful   when you wanted to create a multiple automation  or some custom activity that you wanted to do or   perform then it will be very useful let's recap  what we learned today so first we learn what is   a parameterized ml pipeline then we saw why do we  need it ah multiple use case or the scenario we   saw after that we saw the syntax of creating  a parameter in a pipeline and then we saw we   created a basic camel Pipeline and then we also  discussed couple of scenario where you can use or   create your own parameter HTML pipeline so that's  all for this for today's demo and tutorial I hope   this video will be useful if you have any issue  or concern while setting up your own parameterized   yaml pipeline you can write in the comment box  I'll be happy to help thanks for watching this and   if you like this video kindly share and subscribe  to my channel thank you have a good day bye
Info
Channel: Sumit Raj
Views: 4,610
Rating: undefined out of 5
Keywords: LetsDevOps
Id: BjB73WJfhUI
Channel Id: undefined
Length: 15min 25sec (925 seconds)
Published: Sun Aug 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.