Skip to content

Latest commit

 

History

History
794 lines (472 loc) · 30 KB

File metadata and controls

794 lines (472 loc) · 30 KB
title Create your first pipeline
ms.custom devx-track-azurecli, py-fresh-zinc, copilot-scenario-highlight
description Create your first pipeline in Azure Pipelines, Azure DevOps, & Team Foundation Server
ms.topic get-started
ms.assetid 038A5329-1B8F-46D9-A0C3-DA3FCFA43996
ms.author sdanie
author steved0x
ms.date 03/10/2026
monikerRange <= azure-devops
ai-usage ai-assisted

Create your first pipeline

[!INCLUDE version-lt-eq-azure-devops]

::: moniker range="azure-devops"

This is a step-by-step guide to using Azure Pipelines to build a sample application from a Git repository. This guide uses YAML pipelines configured with the YAML pipeline editor.

For more information on the different sections in a YAML pipeline, see pipeline in the Azure Pipelines YAML schema and Customize your YAML pipeline.

If you'd like to use Classic pipelines instead, see Define your Classic pipeline. For guidance on using TFVC, see Build TFVC repositories.

Prerequisites - Azure DevOps

[!INCLUDE include]

[!INCLUDE ai-assistance]

Create your first pipeline

Get the Java sample code

To get started, fork the following repository into your GitHub account.

https://github.com/MicrosoftDocs/pipelines-java

Create your first Java pipeline

[!INCLUDE include]

  1. Azure Pipelines will analyze your repository and recommend the Maven pipeline template.

  2. When your new pipeline appears, take a look at the YAML to see what it does. When you're ready, select Save and run.

  3. You're prompted to commit a new azure-pipelines.yml file to your repository. After you're happy with the message, select Save and run again.

    If you want to watch your pipeline in action, select the build job.

    You just created and ran a pipeline that we automatically created for you, because your code appeared to be a good match for the Maven template.

    You now have a working YAML pipeline (azure-pipelines.yml) in your repository that's ready for you to customize!

  4. When you're ready to make changes to your pipeline, select it in the Pipelines page, and then Edit the azure-pipelines.yml file.

Learn more about working with Java in your pipeline.

Get the .NET sample code

To get started, fork the following repository into your GitHub account.

https://github.com/MicrosoftDocs/pipelines-dotnet-core

Create your first .NET Core pipeline

[!INCLUDE include]

  1. Azure Pipelines will analyze your repository and recommend the ASP.NET Core pipeline template.

  2. When your new pipeline appears, take a look at the YAML to see what it does. When you're ready, select Save and run.

  3. You're prompted to commit a new azure-pipelines.yml file to your repository. After you're happy with the message, select Save and run again.

    If you want to watch your pipeline in action, select the build job.

    You just created and ran a pipeline that we automatically created for you, because your code appeared to be a good match for the ASP.NET Core template.

    You now have a working YAML pipeline (azure-pipelines.yml) in your repository that's ready for you to customize!

  4. When you're ready to make changes to your pipeline, select it in the Pipelines page, and then Edit the azure-pipelines.yml file.

Learn more about working with .NET Core in your pipeline.

Get the Python sample code

To get started, fork the following repository into your GitHub account.

https://github.com/Microsoft/python-sample-vscode-flask-tutorial

Create your first Python pipeline

[!INCLUDE include]

  1. Azure Pipelines will analyze your repository and recommend the Python package pipeline template.

  2. When your new pipeline appears, take a look at the YAML to see what it does. When you're ready, select Save and run.

  3. You're prompted to commit a new azure-pipelines.yml file to your repository. After you're happy with the message, select Save and run again.

    If you want to watch your pipeline in action, select the build job.

    You just created and ran a pipeline that we automatically created for you, because your code appeared to be a good match for the Python package template.

    You now have a working YAML pipeline (azure-pipelines.yml) in your repository that's ready for you to customize!

  4. When you're ready to make changes to your pipeline, select it in the Pipelines page, and then Edit the azure-pipelines.yml file.

Learn more about working with Python in your pipeline.

Get the JavaScript sample code

To get started, fork the following repository into your GitHub account.

https://github.com/Azure-Samples/js-e2e-express-server

Create your first JavaScript pipeline

[!INCLUDE include]

  1. Azure Pipelines will analyze your repository and recommend the Node.js pipeline template.

  2. When your new pipeline appears, take a look at the YAML to see what it does. When you're ready, select Save and run.

  3. You're prompted to commit a new azure-pipelines.yml file to your repository. After you're happy with the message, select Save and run again.

    If you want to watch your pipeline in action, select the build job.

    You just created and ran a pipeline that we automatically created for you, because your code appeared to be a good match for the Node.js template.

    You now have a working YAML pipeline (azure-pipelines.yml) in your repository that's ready for you to customize!

  4. When you're ready to make changes to your pipeline, select it in the Pipelines page, and then Edit the azure-pipelines.yml file.

Learn more about working with JavaScript in your pipeline.


::: moniker-end

::: moniker range="<=azure-devops"

View and manage your pipelines

You can view and manage your pipelines by choosing Pipelines from the left-hand menu to go to the pipelines landing page.

:::image type="content" source="get-started/media/pipelines-overview.png" alt-text="Screenshot of pipelines landing page.":::

From the pipelines landing page you can view pipelines and pipeline runs, create and import pipelines, manage security, and drill down into pipeline and run details.

Choose Recent to view recently run pipelines (the default view), or choose All to view all pipelines.

Screenshot of options for viewing pipeline runs on the pipelines landing page.

Select a pipeline to manage that pipeline and view the runs. Select the build number for the last run to view the results of that build, select the branch name to view the branch for that run, or select the context menu to run the pipeline and perform other management actions.

Screenshot of recently run pipelines.

Select Runs to view all pipeline runs. You can optionally filter the displayed runs.

Screenshot of pipeline runs.

Select a pipeline run to view information about that run.

You can choose to Retain or Delete a run from the context menu. For more information on run retention, see Build and release retention policies.

Screenshot of pipeline run context menu.

View pipeline details

The details page for a pipeline allows you to view and manage that pipeline.

Screenshot of pipeline details page.

Choose Edit to edit your pipeline. For more information, see YAML pipeline editor. You can also edit your pipeline by modifying the azure-pipelines.yml file directly in the repository that hosts the pipeline.

View pipeline run details

From the pipeline run summary you can view the status of your run, both while it is running and when it is complete.

Screenshot of pipeline run summary.

From the summary pane you can view job and stage details, download artifacts, and navigate to linked commits, test results, and work items.

Jobs and stages

The jobs pane displays an overview of the status of your stages and jobs. This pane may have multiple tabs depending on whether your pipeline has stages and jobs, or just jobs. In this example, the pipeline has two stages named Build and Deploy. You can drill down into the pipeline steps by choosing the job from either the Stages or Jobs pane.

Screenshot of pipeline jobs and stages.

Choose a job to see the steps for that job.

Screenshot of pipeline tasks.

From the steps view, you can review the status and details of each step. From the More actions :::image type="icon" source="../media/icons/more-actions.png"::: you can toggle timestamps or view a raw log of all steps in the pipeline.

Screenshot of pipeline tasks content menu.

Cancel and re-run a pipeline

If the pipeline is running, you can cancel it by choosing Cancel. If the run has completed, you can re-run the pipeline by choosing Run new.

Screenshot of cancelling a pipeline run.

Pipeline run more actions menu

From the More actions :::image type="icon" source="../media/icons/more-actions.png"::: menu you can download logs, add tags, edit the pipeline, delete the run, and configure retention for the run.

Screenshot of pipeline run summary page more actions menu.

Note

You can't delete a run if the run is retained. If you don't see Delete, choose Stop retaining run, and then delete the run. If you see both Delete and View retention releases, one or more configured retention policies still apply to your run. Choose View retention releases, delete the policies (only the policies for the selected run are removed), and then delete the run.

::: moniker-end

::: moniker range="azure-devops"

[!INCLUDE include]

::: moniker-end

::: moniker range="<azure-devops"

We'll show you how to use the classic editor in Azure DevOps Server 2019 to create a build and release that prints "Hello world".

::: moniker-end

::: moniker range="<azure-devops"

  1. Go to Azure Repos. (The Code hub in the previous navigation)

    Repos files

  2. If your project is empty, you will be greeted with a screen to help you add code to your repository. Choose the bottom choice to initialize your repo with a readme file:

    Initialize repository

::: moniker-end

::: moniker range="<azure-devops"

  1. Go to Azure Repos.

  2. Add a file.

    [!div class="mx-imgBorder"] On the Files tab, from the repo node, select the New File option

  3. In the dialog box, name your new file and create it.

    HelloWorld.ps1
    
  4. Copy and paste this script.

    Write-Host "Hello world"
  5. Commit (save) the file.

::: moniker-end

::: moniker range="<azure-devops"

  1. Select Azure Pipelines, it should automatically take you to the Builds page.

    [!div class="mx-imgBorder"] Go to Builds tab

  2. Create a new pipeline.

    [!div class="mx-imgBorder"] Select the build tab button

    For new Azure DevOps users, this will automatically take you to the YAML pipeline creation experience. To get to the classic editor and complete this guide, you must turn off the preview feature for the New YAML pipeline creation experience:

    Click settings in top right of screen and click preview features

    Click toggle to turn yaml preview feature off

  3. Make sure that the source, project, repository, and default branch match the location in which you created the script.

  4. Start with an Empty job.

  5. On the left side, select Pipeline and specify whatever Name you want to use. For the Agent pool, select Hosted VS2017.

  6. On the left side, select the plus sign ( + ) to add a task to Job 1. On the right side, select the Utility category, select the PowerShell task from the list, and then choose Add.

    [!div class="mx-imgBorder"] Add the build task to the job

  7. On the left side, select your new PowerShell script task.

  8. For the Script Path argument, select the :::image type="icon" source="../media/icons/more-actions.png" border="false"::: button to browse your repository and select the script you created.

    [!div class="mx-imgBorder"] Select your script

  9. Select Save & queue, and then select Save.

    ::: moniker-end

::: moniker range="<azure-devops"

  1. On the Tasks tab, select the plus sign ( + ) to add a task to Job 1.

  2. Select the Utility category, select the Publish Build Artifacts task, and then select Add.

    Add the publish artifact task

    Path to publish: Select the :::image type="icon" source="../media/icons/actions-icon.png" border="false"::: button to browse and select the script you created.

    Artifact name: Enter drop.

    Artifact publish location: Select Azure Artifacts/TFS.

::: moniker-end

::: moniker range="<azure-devops"

  1. Select Save & queue, and then select Save & queue.

  2. On the dialog box, select Save & queue once more.

    This queues a new build on the Microsoft-hosted agent.

  3. You see a link to the new build on the top of the page.

    [!div class="mx-imgBorder"] build console

    Choose the link to watch the new build as it happens. Once the agent is allocated, you'll start seeing the live logs of the build. Notice that the PowerShell script is run as part of the build, and that "Hello world" is printed to the console.

    [!div class="mx-imgBorder"] Watch in the build console

  4. Go to the build summary. On the Artifacts tab of the build, notice that the script is published as an artifact.

    [!div class="mx-imgBorder"] Open the build console to see the artifact

::: moniker-end

::: moniker range="<azure-devops"

[!div class="mx-imgBorder"] Open the PowerShell task in the build console

::: moniker-end

::: moniker range="<azure-devops"

Now you can see the results of your changes. Go to Azure Pipelines and select Queued. Notice under the Queued or running section that a build is automatically triggered by the change that you committed.

::: moniker-end

::: moniker range="<azure-devops"

[!div class="mx-imgBorder"] Build a summary PowerShell script log

::: moniker-end

::: moniker range="<azure-devops"

  1. Go to the Pipelines tab, and then select Releases.

  2. Select the action to create a New pipeline. If a release pipeline is already created, select the plus sign ( + ) and then select Create a release pipeline.

  3. Select the action to start with an Empty job.

  4. Name the stage QA.

  5. In the Artifacts panel, select + Add and specify a Source (Build pipeline). Select Add.

  6. Select the Lightning bolt to trigger continuous deployment and then enable the Continuous deployment trigger on the right.

    [!div class="mx-imgBorder"] Select lightning bolt to trigger continuous deployment

  7. Select the Tasks tab and select your QA stage.

  8. Select the plus sign ( + ) for the job to add a task to the job.

  9. On the Add tasks dialog box, select Utility, locate the PowerShell task, and then select its Add button.

  10. On the left side, select your new PowerShell script task.

  11. For the Script Path argument, select the :::image type="icon" source="../media/icons/actions-icon.png" border="false"::: button to browse your artifacts and select the script you created.

  12. Add these Arguments:

    -greeter "$(Release.RequestedFor)" -trigger "$(Build.DefinitionName)"
    
  13. On the Pipeline tab, select the QA stage and select Clone.

    [!div class="mx-imgBorder"] Clone the release environment in QA

  14. Rename the cloned stage Production.

  15. Rename the release pipeline Hello world.

    [!div class="mx-imgBorder"] Rename the release pipeline hello world

  16. Save the release pipeline.

::: moniker-end

::: moniker range="<azure-devops"

  1. Create a new release.

    [!div class="mx-imgBorder"] Create release - DevOps 2019 and 2020

    When Create new release appears, select Create.

  2. Open the release that you created.

    [!div class="mx-imgBorder"] release created - DevOps 2019 and 2020

  3. View the logs to get real-time data about the release.

    [!div class="mx-imgBorder"] release logs - DevOps 2019 and 2020

    ::: moniker-end

::: moniker range="<azure-devops"

[!div class="mx-imgBorder"] release script step final log - DevOps 2019 and 2020

::: moniker-end

Use AI to create your first pipeline

If you configure the Azure DevOps MCP Server, you can get help creating, understanding, and troubleshooting your first pipeline using natural language.

Get started

Task Example prompt
Create a starter pipeline Create a basic pipeline YAML for this repo in project <Contoso>
Minimal build pipeline What's the smallest pipeline that will build this project in <Contoso>?
Explain pipeline YAML Explain each section of this pipeline YAML in <Contoso>
Choose an agent pool Which agent pool should I use for this project in <Contoso>?
Scaffolding help Help me create my first pipeline for this repo in <Contoso>

Verify permissions and access

Task Example prompt
Check repo access Can this pipeline access the repo in project <Contoso>?
Verify build service permissions Does the build service have permission to run pipelines in project <Contoso>?
Artifact publishing access Will this pipeline be able to publish artifacts in <Contoso>?
Agent requirements Does this repo require a Microsoft-hosted or self-hosted agent in <Contoso>?
OS selection What OS should the pipeline run on for this project in <Contoso>?

Troubleshoot first-run failures

Task Example prompt
Debug a first-run failure Why did my first pipeline fail in project <Contoso>?
Explain an error Explain this pipeline error in plain English for project <Contoso>
Identify the failing step What step failed and why in the latest run for <Contoso>?
Permission error help Why would a new pipeline fail with a permission error in <Contoso>?
Targeted fix How do I fix this error without changing the entire pipeline in <Contoso>?

Optimize and extend

Task Example prompt
Production readiness What's missing from this pipeline for a production repo in <Contoso>?
PR validation Should I add PR validation to this pipeline in <Contoso>?
Security scans What security scans are recommended for first pipelines in <Contoso>?
Common next steps What steps are commonly added after the initial pipeline in <Contoso>?
Trigger recommendations What triggers should I use for my first pipeline in <Contoso>?
Agent capabilities Do we already have custom agent capabilities this pipeline needs in <Contoso>?
Suggest improvements Suggest improvements to this pipeline in <Contoso>

Tip

If you're using Visual Studio Code, agent mode is especially helpful for scaffolding new pipelines and troubleshooting first-run failures.

Next steps

:::moniker range="azure-devops"

[!INCLUDE include]

:::moniker-end

FAQ

Where can I read articles about DevOps and CI/CD?

What is Continuous Integration?

What is Continuous Delivery?

What is DevOps?

What version control system can I use?

When you're ready to get going with CI/CD for your app, you can use the version control system of your choice:

::: moniker range="azure-devops"

::: moniker-end

::: moniker range="<azure-devops"

How do I replicate a pipeline?

If your pipeline has a pattern that you want to replicate in other pipelines, clone it, export it, or save it as a template.

[!div class="mx-imgBorder"] all-definitions-build-action-menu-replicate-actions

::: moniker-end

::: moniker range="< azure-devops"

After you clone a pipeline, you can make changes and then save it.

After you export a pipeline, you can import it from the All pipelines tab.

After you create a template, your team members can use it to follow the pattern in new pipelines.

Tip

If you're using the New Build Editor, then your custom templates are shown at the bottom of the list.

How do I work with drafts?

If you're editing a build pipeline and you want to test some changes that are not yet ready for production, you can save it as a draft.

::: moniker-end

::: moniker range="<azure-devops"

[!div class="mx-imgBorder"] save-as-draft

::: moniker-end

::: moniker range="<azure-devops"

[!div class="mx-imgBorder"] edit draft - DevOps 2019 and 2020

::: moniker-end

::: moniker range="<azure-devops"

[!div class="mx-imgBorder"] publish draft - DevOps 2019 and 2020

::: moniker-end

How can I delete a pipeline?

To delete a pipeline, navigate to the summary page for that pipeline, and choose Delete from the ... menu in the top-right of the page. Type the name of the pipeline to confirm, and choose Delete.

::: moniker range="<= azure-devops"

What else can I do when I queue a build?

::: moniker-end

::: moniker range="azure-devops"

You can queue builds automatically or manually.

When you manually queue a build, you can, for a single run of the build:

::: moniker-end

Where can I learn more about pipeline settings?

::: moniker range="azure-devops"

To learn more about pipeline settings, see:

::: moniker-end

::: moniker range="<= azure-devops"

How do I programmatically create a build pipeline?

REST API Reference: Create a build pipeline

Note

You can also manage builds and build pipelines from the command line or scripts using the Azure Pipelines CLI.

::: moniker-end