Nov 122019
 

This part of the build chain in DevOps was a huge riddle for me. I never quite get my head around it. But now that I have got some idea I will try to tell the story from top down approach.

So in a development process we start to have the code on developer machine. In order to share this code with the other developers we use code repositories and normally we use online/central repositories which all the developers can access. We can achieve this  by using Git or VSTS or any other code repository.

Once the code is pushed to an online repository it not only serves the purpose of sharing the code but it is also used to build the code. Once that code is pushed there then the code is build. After a successfull build the application artifacts are generate that are then published to released. Now these artifacts could be deployable files or executables.

The release ready artifacts are then directed towards the installation platform which is a normally a service on a machines and the artifcats are deployed there. In our case this will be a web app in azure cloud services.

So to achieve this process I first created the ‘code on the developer machine’ part so I created a helloworld website in .netcore. For my example I will use the github as the online repository you can also use git (available in VSTS) which can directly be used by VSTS.

  • Gubhub: is website which is using git the azure devops gives integration with the git hub but in visual studio you can also use Git.
  • VS Git: this is using the azure devops git and once you push the code here all the code will be pushed to the devops.

I am using github to host my code. Now I will push all my code to my github repository. I also created a ignore file of type visual studio to my github as I don’t want to push the unwanted files. Finally my code is now on github. But how can I introduce a end to end processes where every code push should re-deploy my website.

So this is the process that I followed.

First of you need to create a new organization I have already done that with the name Asadmirza0855. Once that is done you need to open it. To open an organization on VSTS just click it and you will be in that context.

 

cicd4

Once you open that organization now we need to create a new project in that organization.

cicd2

You can see that you can create a public of provate project by clicking on the left top corner where it says ‘new project’. I have already created a project called CICD3.

Now lets setup the build process. So to do that you need to go to the build menu under Pipelines. Once you are there then hit ‘New’. Now you will be able to create the build process here. This is a four step process

Step1: Where is your code, in our case we will select github. Its going to to authetciate you on github and then will fetch all the repos from there.

cicd3

Step2: After that you need to select which repo you want to build

cicd4

Step3: In this step you need to configure the type of the application you are trying to build. VSTS have provided some predefined template so I will use those. In my case I will use ASP.NET Core.

cicd5

In the review its going to generate the Yml file that I will use for the build. In my case my yml file looks like this.

cicd6

This is the not the standard generated file I have modified it a bit. There are two main tasks here to build the project which will generate the artefact and the other task is two publish that artefact. You can also use varaibles in the YAML file. Now push that YAML file and once that is pushed the build will be triggered.

The next step is to create a release pipeline. But first lets create the Web App in azure portal. I will not explain how to create a web app here so I assume you know that. Once that web app is created we will create a release pipeline using the ‘Azure app service deplyment’ which is a service template.

  1. Click new under release and select Azure App service Deployment.

cicd7

I have selected my project CICD3, then I need to select to latest version so it knows which version to pick and the source alias.

  1. You also need to select a trigger. I have selected the very basic trigger that is to release after every new build. You also need to update the task and deployment paramaters.

cicd8

  1. In the default stage when you click on the task you will be presented with this page

 

cicd9

cicd10

in this page you need to provide the web app name and also the azure subscription under which that web app exists.

You can also view this confgiration in YAML file as well.

 

Once all of this setup is done you can trigger the build by triggering the build using a fake push. This will perform the following steps.

cicd11

 

 

 

 

 Posted by at 8:34 am

Sorry, the comment form is closed at this time.