title | author |
---|---|
Introduction to Azure Pipelines |
Part 1 of 3 in the [Build end-to-end CI/CD capabilities with Azure Pipelines](https://github.com/msusdev/end-to-end-ci-cd) series |
Presenter Name
☁️ Presenter Title
For questions or help with this series: [email protected]
All demos and source code available on GitHub:
- Session 1:
- ↪️ Introduction to Azure Pipelines
- Session 2:
- Automatically build and test your code with Azure Pipelines
- Session 3:
- Deploy your code to Azure with Azure Pipelines
- What are Azure Pipelines?
- Learn the YAML syntax
- Building a simple project
::: notes
Learn how Azure Pipelines enable you to automate your software development cycle for code hosted in GitHub. We’ll walk you through using everyday actions in your first pipeline. You’ll learn how to:
- Create a pipeline
- Add actions to a pipeline
- Trigger the pipeline
:::
- Packaged pipelines
- Automates common build, test, and deployment actions
- Highly configurable and extendable
- Supports an open marketplace of free and paid tools
- Includes a rich user interface system native in Azure DevOps
- Run any command-line script
- Example:
echo 'Hello World'
- Run one of the built-in complex tasks
- Example:
- Publish to Azure
::: notes
-
Start with an empty Azure DevOps project
-
Create a GitHub repository with a single README file
-
Use Visual Studio Code to create a new .NET console application with the following commands and code:
dotnet new console dotnet add package Colorful.Console dotnet new gitignore dotnet new sln dotnet sln add <name-of-project-folder>.csproj
using static System.Drawing.Color; using Console = Colorful.Console; Console.WriteAscii("Hello, World!", Red);
dotnet run
Note: You can use GitHub Codespaces to perform this task quickly.
-
Commit your changes to the local repository and push the changes to GitHub.
-
Return to the new Azure DevOps project.
-
Create, save, and then run a new pipeline with the following settings:
- Source: GitHub
- Repository: Select GitHub repository you created earlier
- Template: .NET Desktop
-
Observe the job output logs.
:::
Language | Install required packages | Run application |
---|---|---|
.NET | dotnet restore |
dotnet run |
Node.js | npm install |
node [file.js] |
Python | pip install [package] |
python [file.py] |
Ruby | gem install [package] |
ruby [file.rb] |
.NET CLI | |
---|---|
Install packages | dotnet restore |
Build project | dotnet build |
Run project | dotnet run |
Test project | dotnet test |
Publish project | dotnet publish |
stages:
stages:
- stage: <name_of_stage>
- stage: <name_of_stage>
stages:
- stage: continuous_integration
stages:
- stage: continuous_integration
jobs:
stages:
- stage: continuous_integration
jobs:
- job: <job_name>
- job: <job_name>
stages:
- stage: continuous_integration
jobs:
- job: build
stages:
- stage: continuous_integration
jobs:
- job: build
steps:
- Run any command-line script
- Example:
dotnet build
- Run one of the built-in complex tasks
- Example:
- Create an Artifact
stages:
- stage: continuous_integration
jobs:
- job: build
steps:
- script: <some_script_to_execute>
- task: <name_of_builtin_task>
dotnet restore
dotnet build
stages:
- stage: continuous_integration
jobs:
- job: build
steps:
- script: dotnet restore
- script: dotnet build
::: notes
-
Return to the GitHub project.
-
Remove every file in the project except for the following three files:
- <name-of-project-folder>.csproj
- Program.cs
- .gitignore
-
Create a new pipeline YAML file in your project.
Note: The filename of the pipeline is arbitrary. For the remainder of the demos, we will assume you named the pipeline pipeline.yml.
-
Add the following content to the pipeline YAML file:
stages: - stage: continuous_integration jobs: - job: build steps: - script: dotnet restore - script: dotnet build
-
Commit your changes to the local repository and push the changes to GitHub.
-
Return to the Azure DevOps project.
-
Create, save, and then run a new pipeline with the following settings:
- Source: GitHub
- Repository: Select GitHub repository you created earlier
- Template: Existing Azure Pipelines YAML file
- Branch: main
- Path: /pipeline.yml
-
Observe the job output logs.
-
Update the content of the pipeline YAML file:
stages: - stage: continuous_integration jobs: - job: build steps: - script: dotnet --version - script: dotnet restore - script: dotnet build - script: dotnet run
-
Commit your changes to the local repository and push the changes to GitHub.
-
Return to the Azure DevOps project and your new pipeline.
-
Observe the job output logs for the latest automated run.
:::
Task | Name |
---|---|
Single Stage | continuous_integration |
Single Job | build |
Script (dotnet restore ) |
CmdLine |
Script (dotnet build ) |
CmdLine |
stages:
- stage: continuous_integration
displayName: Continuous Integration
jobs:
- job: build
displayName: Build
steps:
- script: dotnet restore
displayName: Restore NuGet packages
::: notes
-
Return to the GitHub project.
-
Update the content of the pipeline YAML file:
stages: - stage: continuous_integration displayName: Continuous Integration jobs: - job: build displayName: Build steps: - script: dotnet --version displayName: Check .NET SDK version - script: dotnet restore displayName: Restore NuGet packages - script: dotnet build displayName: Build .NET project - script: dotnet run displayName: Run .NET application
-
Commit your changes to the local repository and push the changes to GitHub.
-
Return to the Azure DevOps project and your pipeline.
-
Observe the job output logs for the latest automated run.
:::
Image | Specification |
---|---|
Windows Server 2022 & Visual Studio 2022 | windows-2022 |
Windows Server 2019 & Visual Studio 2019 | windows-latest or windows-2019 |
Ubuntu 20.04 | ubuntu-latest or ubuntu-20.04 |
Ubuntu 18.04 | ubuntu-18.04 |
macOS 11 Big Sur | macOS-latest or macOS-11 |
macOS X Catalina 10.15 | macOS-10.15 |
- Ansible
- Azure CLI
- Docker
- .NET SDK
- Git
- Helm
- Node.js
- Terraform
- Python
pool:
vmImage: ubuntu-latest
stages:
- stage: continuous_integration
jobs:
- job: build
steps:
- script: dotnet build
displayName: Build .NET project
pool:
vmImage: ubuntu-latest
stages:
- stage: continuous_integration
jobs:
- job: build
container: mcr.microsoft.com/dotnet/sdk:latest
steps:
- script: dotnet build
::: notes
-
Return to the GitHub project.
-
Update the content of the pipeline YAML file:
pool: vmImage: ubuntu-20.04 stages: - stage: continuous_integration displayName: Continuous Integration jobs: - job: build displayName: Build container: mcr.microsoft.com/dotnet/sdk:6.0 steps: - script: dotnet --version displayName: Check .NET SDK version - script: dotnet restore displayName: Restore NuGet packages - script: dotnet build displayName: Build .NET project - script: dotnet run displayName: Run .NET application
-
Commit your changes to the local repository and push the changes to GitHub.
-
Return to the Azure DevOps project and your pipeline.
-
Observe the job output logs for the latest automated run.
:::
- Azure Pipelines
- YAML syntax
- Building projects