-
Notifications
You must be signed in to change notification settings - Fork 14
dsf azure pipelines
The following steps will allow you to create a basic pipeline in Azure Devops from scratch
In order to deploy in Azure, we’ve created an automatic pipeline in Azure Devops that will be executed automaticaly when developers make a push to the Azure repositories, the pipeline will compile the code, build the application and ensure with automatic tests that the build is not going to break the application, to ensure a good quality code the code will be analyzed by sonar as well as your code coverage and last but not least, your application will be deployed using Azure App Services.
1- Sign in to your Azure DevOps organization and navigate to your project.
2- Go to Pipelines, and then select New Pipeline.
3- Choose the location of your source code(Github, Bitbucket,Azure repos..etc), in this case we have our code in Azure Repos Git.
A list of your repositories will be shown here:
4- When the list of repositories appears, select your repository.
Depending on your project type(Java, .NET, Python or JavaScript) the following configuration will change, in this case our project is a .NET, for more type of projects please follow the official documentation.
5- When the Configure tab appears, select ASP.NET Core(or the one according to your project)
6- A .yaml file in your ./ location will be generated with all the required steps to run your pipeline. The name of this .yaml file is 'azure-pipelines.yaml' wich is the default name that will be used in your pipeline settings.
Note:If you change the name or the location, you will need to specify in the pipeline settings the new name or location:
The pipeline is created with the minimum required steps to run it which are the following:
Variables that will be used in the next steps
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
For .NET:
-NuGet Tool Installer task:
- task: NuGetToolInstaller@1
Use this task to find, download, and cache a specified version of NuGet and add it to the PATH.
-The NuGet command to run:
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
The NuGet command to run.
For more info use the official documentation.
-Visual Studio Build task:
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
Use this task to build with MSBuild and set the Visual Studio version property.
For more info use the official documentation
-Visual Studio Test task:
- task: DotNetCoreCLI@2
inputs:
command: 'test'
arguments: '/p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=$(Agent.TempDirectory)/'
projects: '$(solution)'
publishTestResults: true
continueOnError: false
displayName: 'Dot Net Core CLI Test'
Use this task to run unit and functional tests (Selenium, Appium, Coded UI test, and more) using the Visual Studio Test Runner.
For more info use the official documentation
This steps are the ones generated when your pipeline is created, we can create the ones we need using the Azure Devops wizard in an easy way.
In our case, apart from build and test, we also need to deploy
While deploying with App Services, 2 steps are required:
Use this task in a pipeline to publish artifacts for the Azure Pipeline
- task: PublishPipelineArtifact@0
inputs:
artifactName: 'Bad_Weather_Backend'
targetPath: '$(Build.ArtifactStagingDirectory)'
To know more about the use of predefined variables in azure take a look at the documentation
Use this task to deploy to a range of App Services on Azure
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'bad-weather-poc-rs-bw-dev'
appType: 'webApp'
WebAppName: 'bwbackendbe'
packageForLinux: '$(build.artifactStagingDirectory)\WebApp.zip'
This task has 2 prerequisites:
1-App Service instance:
The task is used to deploy a Web App project or Azure Function project to an existing Azure App Service instance, which must exist before the task runs.
2-Azure Subscription:
In order to deploy to Azure, an Azure subscription must be linked to the pipeline.
To know more about the input arguments for this task, make use of the offcial documentation
This documentation is licensed under the Creative Commons License (Attribution-NoDerivatives 4.0 International).
-
cicd configuration
-
Manual configuration
-
Automatic configuration
-
-
Custom Services
-
Azure DevOps