Create an Azure DevOps Pipeline
This tutorial will guide you through the process of creating your first CI/CD pipeline in Azure DevOps. Pipelines allow you to automate the build, test, and deployment of your applications.
Step 1: Navigate to Pipelines
Sign in to your Azure DevOps organization. Navigate to the "Pipelines" section in the left-hand navigation menu.
Step 2: Create a New Pipeline
Click on the "Create Pipeline" button, usually located prominently on the Pipelines overview page. You might need to select your project first if you haven't already.
Azure DevOps will then prompt you to configure your pipeline. You'll typically choose where your code is hosted (e.g., Azure Repos Git, GitHub, Bitbucket).
Step 3: Select Your Repository
Choose the repository that contains the code for your application. If it's not immediately visible, you may need to authorize Azure DevOps to access your repository host.
Step 4: Configure Your Pipeline (YAML)
Azure DevOps will suggest a pipeline configuration based on your repository's content. For most modern applications, you'll use YAML to define your pipeline. This provides a version-controlled and reproducible way to manage your CI/CD processes.
You can start with a template or write your own YAML file.
Example YAML Pipeline (.azure-pipelines.yml)
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
displayName: 'Use .NET SDK 6.x'
inputs:
version: '6.x'
- script: dotnet build --configuration Release
displayName: 'Build Solution'
- script: dotnet test --configuration Release --logger trx --results-directory tests
displayName: 'Run Unit Tests'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: 'tests/**/*.trx'
mergeTestResults: true
failTaskOnFailedTests: true
This example defines a pipeline that triggers on changes to the main
branch, uses an Ubuntu agent, sets up the .NET SDK, builds the project, runs unit tests, and publishes the test results.
Step 5: Save and Run
Once you're satisfied with your YAML configuration, click the "Save and run" button. This will commit the azure-pipelines.yml
file to your repository and start the first pipeline run.
You can choose to commit directly to the main branch or create a new branch and open a pull request.
Step 6: Monitor Your Pipeline
After initiating the run, you'll be redirected to the pipeline run details page. Here you can monitor the progress of each stage and step. If any step fails, you can examine the logs to diagnose the issue.
Successful pipeline runs indicate that your CI process is working correctly.
Next Steps
Now that you have a basic CI pipeline, you can extend it to include deployment stages (CD), code quality checks, security scanning, and more.