├── badges └── badges.md ├── LICENSE └── README.md /badges/badges.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://barradas.visualstudio.com/Contributions/_apis/build/status/ThiagoBarradas.environment-api?branchName=master)](https://barradas.visualstudio.com/Contributions/_build/latest?definitionId=2&branchName=master) 2 | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ThiagoBarradas_environment-api&metric=alert_status)](https://sonarcloud.io/dashboard?id=ThiagoBarradas_environment-api) 3 | ![Sonar Violations (long format)](https://img.shields.io/sonar/violations/ThiagoBarradas_environment-api.svg?format=long&server=https%3A%2F%2Fsonarcloud.io) 4 | ![Sonar Tech Debt](https://img.shields.io/sonar/tech_debt/ThiagoBarradas_environment-api.svg?server=https%3A%2F%2Fsonarcloud.io) 5 | ![Sonar Coverage](https://img.shields.io/sonar/coverage/ThiagoBarradas_environment-api.svg?server=https%3A%2F%2Fsonarcloud.io) 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Thiago Barradas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Azure DevOps - Pipelines Demo 2 | 3 | ## All tools in this demo 4 | 5 | - .NET Core 2.2 / xUnit (Application and tests) 6 | - Azure DevOps (CI/CD) 7 | - Sonarqube (Code quality analysis) 8 | - Docker (Package / Containerization app) 9 | - Docker Hub (Registry for docker images) 10 | - Runscope (Integration tests) 11 | - Azure (Infra to deploy) 12 | 13 | ## 1 - Appliciation development 14 | 15 | - [Application](https://github.com/ThiagoBarradas/environment-api); 16 | - Unit Tests; 17 | - Dockerfile; 18 | - All tests locally; 19 | 20 | ## 2 - Azure DevOps - Overview 21 | 22 | - [Create account and connect with GitHub](https://azure.microsoft.com/pt-br/services/devops/); 23 | - Create a single project to aggregate applications; 24 | - Create variable group in pipelines Library; 25 | 26 | ## 3 - Create Azure Build Pipeline 27 | 28 | - [Predefined variables for Build Pipeline](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml) 29 | 30 | ## 3.1 - Create Build Step 31 | 32 | - Create initial variables 33 | - Create build step and commit; 34 | - See build results; 35 | - Add store artifact; 36 | - Commit and see results again; 37 | 38 | [azure-pipelines.yml result](https://github.com/ThiagoBarradas/azure-devops-pipelines-demo/blob/master/build-pipelines/1-build.yml) 39 | 40 | ## 3.2 - Create Unit Tests Step 41 | 42 | - Create tests step and commit; 43 | - See tests results; 44 | - Add store artifact / publish code coverage and test results; 45 | - Commit and see results again; 46 | 47 | [azure-pipelines.yml result](https://github.com/ThiagoBarradas/azure-devops-pipelines-demo/blob/master/build-pipelines/2-build-test.yml) 48 | 49 | ## 3.3 - Create Quality Analysis Step 50 | 51 | - [Install Sonarcloud Extension](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarcloud) 52 | - [Register and setup project at Sonarcloud](https://sonarcloud.io) 53 | - [Generate SonarCloud token and create a service connection in Azure DevOps](https://sonarcloud.io/account/security); 54 | - Get `project_key` and service connection name and add to pipeline; 55 | - Create QA step and commit; 56 | - See results in Azure DevOps and SonarCloud; 57 | 58 | [azure-pipelines.yml result](https://github.com/ThiagoBarradas/azure-devops-pipelines-demo/blob/master/build-pipelines/3-build-test-qa.yml) 59 | 60 | ## 3.4 - Create Docker Publish Step 61 | 62 | - [Create account and create a project in Docker Hub](https://hub.docker.com) 63 | - Create a service connection in Azure DevOps to connect with Docker Hub; 64 | - [Conditions in Azure Pipelines](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml) 65 | - [Replace Tokens in Dockerfile using other Extension ](https://marketplace.visualstudio.com/items?itemName=qetza.replacetokens) 66 | - Create PublishDocker step and commit; 67 | - See new images in Docker Hub and run locally to check if new image works fine; 68 | 69 | [azure-pipelines.yml result](https://github.com/ThiagoBarradas/azure-devops-pipelines-demo/blob/master/build-pipelines/4-build-test-qa-dockerpublish.yml) 70 | 71 | ## 4 - GitHub Status Check 72 | 73 | - Create a new branch with some change and create a pull request; 74 | - Check commit and PR build status; 75 | - [See about skip CI build](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml) 76 | 77 | ## 5 - Badges 78 | 79 | - Go to Azure DevOps Build Pipelines project dashboard and get your badge in top-right menu, 'Status Badge' 80 | - Go to Sonarcloud Dashboard and click in 'Get Project Badges' 81 | - Get badges for Quality Gate Status, Code Coverage 82 | - Go to Shields.io to generate other badges for SonarCloud; 83 | - Add in project README.md 84 | 85 | [README.md badges result](https://github.com/ThiagoBarradas/azure-devops-pipelines-demo/blob/master/badges/badges.md) 86 | 87 | ## 6 - Prepare Infrastructure 88 | 89 | - [Create a service using Azure App Service](https://portal.azure.com/#create/Microsoft.WebSite) 90 | - [Swap Web App in Azure](https://docs.microsoft.com/pt-br/azure/app-service/deploy-staging-slots#to-rollback-a-production-app-after-swap) 91 | 92 | ## 7 - Create Azure Release Pipeline 93 | 94 | - [Predefined variables for Release Pipeline](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml) 95 | 96 | ## 7.1 - Create Deploy Step 97 | 98 | - Create a single container/environment in Azure Web App 99 | - Simulate Deploy 100 | - Create Staging Environment 101 | - Deploy to staging 102 | - Then Swap Slots 103 | - [Deploy Link](https://aka.ms/azurewebapponcontainerdeployreadme) 104 | - [Swap Link](https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/AzureAppServiceManageV0) 105 | 106 | ## 7.2 - Create Integration Test Step 107 | 108 | - Create Runscope Tests 109 | - Install [Runscope Extension](https://marketplace.visualstudio.com/items?itemName=ThiagoBarradas.runscopetest) 110 | - Setup Runscope Task 111 | 112 | --------------------------------------------------------------------------------