Create your first pipeline

本文内容

Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017

This is a step-by-step guide to using Azure Pipelines to build a GitHub repository.

Prerequisites

  • A GitHub account, where you can create a repository. If you don't have one, you can create one for free.

  • An Azure DevOps organization. If you don't have one, you can create one for free. (An Azure DevOps organization is different from your GitHub organization. Give them the same name if you want alignment between them.)

If your team already has one, then make sure you're an administrator of the Azure DevOps project that you want to use.

Note

If you want create a new pipeline by copying another pipeline, see Clone a pipeline.

Create your first pipeline

Get the Java sample code

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

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

Create your first Java pipeline

  • Sign in to your Azure DevOps organization and navigate to your project.

  • In your project, navigate to the Pipelines page. Then choose the action to create a new pipeline.

  • Walk through the steps of the wizard by first selecting GitHub as the location of your source code.

  • You might be redirected to GitHub to sign in. If so, enter your GitHub credentials.

  • When the list of repositories appears, select your desired sample app repository.

  • Azure Pipelines will analyze your repository and recommend a Maven pipeline template. Select Save and run, then select Commit directly to the master branch, and then choose Save and run again.

  • A new run is started. Wait for the run to finish.

Learn more about working with Java in your pipeline.

Get the .NET Core sample code

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

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

Create your first .NET Core pipeline

  • Sign in to your Azure DevOps organization and navigate to your project.

  • Go to Pipelines, and then select New Pipeline.

  • Walk through the steps of the wizard by first selecting GitHub as the location of your source code.

Select GitHub

Note

If this is not what you see, then make sure the Multi-stage pipelines experience is turned on.

  • You might be redirected to GitHub to sign in. If so, enter your GitHub credentials.

  • When the list of repositories appears, select your repository.

  • You might be redirected to GitHub to install the Azure Pipelines app. If so, select Approve and install.


When the Configure tab appears, select ASP.NET Core.


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

  • 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!

  • 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.

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

Create your first Python pipeline

  • Sign in to your Azure DevOps organization and navigate to your project.

  • Go to Pipelines, and then select New Pipeline.

  • Walk through the steps of the wizard by first selecting GitHub as the location of your source code.

Select GitHub

Note

If this is not what you see, then make sure the Multi-stage pipelines experience is turned on.

  • You might be redirected to GitHub to sign in. If so, enter your GitHub credentials.

  • When the list of repositories appears, select your repository.

  • You might be redirected to GitHub to install the Azure Pipelines app. If so, select Approve and install.


When the Configure tab appears, select Python package. This will create a Python package to test on multiple Python versions.


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

  • 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!

  • 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.

  1. https://github.com/MicrosoftDocs/pipelines-javascript

Create your first JavaScript pipeline

  • Sign in to your Azure DevOps organization and navigate to your project.

  • In your project, navigate to the Pipelines page. Then choose the action to create a new pipeline.

  • Walk through the steps of the wizard by first selecting GitHub as the location of your source code.

  • You might be redirected to GitHub to sign in. If so, enter your GitHub credentials.

  • When the list of repositories appears, select your Node.js sample repository.

  • Azure Pipelines will analyze the code in your repository and recommend Node.js template for your pipeline. Select that template.

  • Azure Pipelines will generate a YAML file for your pipeline. Select Save and run, then select Commit directly to the master branch, and then choose Save and run again.

  • A new run is started. Wait for the run to finish.

When you're done, you'll have a working YAML file (azure-pipelines.yml) in your repository that's ready for you to customize.

Learn more about working with JavaScript in your pipeline.

Clone a pipeline

If your new pipeline can be created by copying another pipeline in the same project, follow the instructions in this section. If your pipeline is in another project, you can use import/export to copy the pipeline.

Pipeline details

  • Copy the pipeline YAML from the editor, and paste it into the YAML editor for your new pipeline.

  • To customize your newly cloned pipeline, see Customize your pipeline.

Clone pipeline menu

  • Your pipeline is cloned with -clone appended to the name. Choose Save or Save & queue to save the cloned pipeline.

Export and Import a pipeline

You can create a new pipeline by exporting an existing one and then importing it. This is especially useful in cases where the new pipeline has to be created in a separate project.

Pipeline details

  • When prompted, save the JSON file to your local machine. The browser will save the file in the download directory as per your browser settings.

  • To import a pipeline, Navigate to the pipelines landing page in your project.

  • Choose and select Import.

Pipeline details

  • You will now be prompted to select a JSON file to import its contents. Browse to and select the JSON file that you previously exported.

upload JSON

  • After import is complete, you will be shown the new pipeline that is created. Note that exporting a pipeline strips any project specific data like agent pools, service connections etc. You will have to once again provide these details.

You can also create new build or release definitions by exporting an existing one and then importing it. This is especially useful in cases where the new definition has to be created in a separate project.

  • Navigate to the pipeline details page for your pipeline.

  • Choose and select Export.

Export pipeline menu

  • When prompted, save the JSON file in your local machine. The browser will save the file in the download directory as per your browser settings.

  • To import the pipeline, navigate to the Builds or Releases page in your project. Choose +New and select the corresponding import pipeline option.

Import pipeline menu

  • You will now be prompted to select a JSON file to import its contents. Browse to and select the JSON file that you previously exported.

  • After import is complete, you will be shown the new pipeline that is created. Note that exporting a pipeline strips any project specific data like agent pools, service connections etc. You will have to once again provide these details.

Add a status badge to your repository

Many developers like to show that they're keeping their code quality high by displaying a status badge in their repo.

Status badge shows Azure pipeline succeeded

To copy the status badge to your clipboard:

  • In Azure Pipelines, go to the Pipelines page to view the list of pipelines. Select the pipeline you created in the previous section.

  • In the context menu for the pipeline, select Status badge.

  • Copy the sample Markdown from the status badge panel.

Now with the badge Markdown in your clipboard, take the following steps in GitHub:

  • Go to the list of files and select Readme.md. Select the pencil icon to edit.

  • Paste the status badge Markdown at the beginning of the file.

  • Commit the change to the master branch.

  • Notice that the status badge appears in the description of your repository.

To configure anonymous access to badges:

  • Navigate to Project Settings

  • Open the Settings tab under Pipelines

  • Toggle the Disable anonymous access to badges slider under General

Note

Even in a private project, anonymous badge access is enabled by default. With anonymous badge access enabled, users outside your organization might be able to query information such as project names, branch names, job names, and build status through the badge status API.

Because you just changed the Readme.md file in this repository, Azure Pipelines automatically builds your code, according to the configuration in the azure-pipelines.yml file at the root of your repository. Back in Azure Pipelines, observe that a new run appears. Each time you make an edit, Azure Pipelines starts a new run.

Next steps

You've just learned how to create your first Azure Pipeline. Learn more about configuring pipelines in the language of your choice:

Or, you can proceed to customize the pipeline you just created.

To run your pipeline in a container, see Container jobs.

For details about building GitHub repositories, see Build GitHub repositories.

To learn what else you can do in YAML pipelines, see YAML schema reference.

Clean up

If you created any test pipelines, they are easy to delete when you are done with them.

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

Delete pipeline

To delete a pipeline using Azure CLI, you can use the az pipeline delete command. This command requires the id of the pipeline to delete, which you can get using the az pipeline list command.

List pipelines | Delete pipeline | Example

Note

If this is your first time using az pipelines commands, see Get started with Azure DevOps CLI.

List pipelines

You can list your pipelines using the az pipelines list command.

  1. az pipelines list [--detect {false, true}]
  2. [--folder-path]
  3. [--name]
  4. [--org]
  5. [--project]
  6. [--query-order {ModifiedAsc, ModifiedDesc, NameAsc, NameDesc, None}]
  7. [--repository]
  8. [--repository-type {bitbucket, git, github, githubenterprise, svn, tfsgit, tfsversioncontrol}]
  9. [--top]

Parameters

  • detect: Automatically detect organization. Accepted values: false, true
  • folder-path: If specified, filters to definitions under this folder.
  • name: Limit results to pipelines with this name or starting with this name. Examples: "FabCI" or "Fab*".
  • org or organization: Azure DevOps organization URL. You can configure the default organization using az devops configure -d organization=ORG_URL. Required if not configured as default or picked up via git config. Example: https://dev.azure.com/MyOrganizationName/.
  • project or p: Name or ID of the project. You can configure the default project using az devops configure -d project=NAME_OR_ID. Required if not configured as default or picked up via git config.
  • query-order: Order of the results. Accepted values: ModifiedAsc, ModifiedDesc, NameAsc, NameDesc, None
  • repository: Limit results to pipelines associated with this repository.
  • repository-type: Limit results to pipelines associated with this repository type. It is mandatory to pass repository argument along with this argument. Accepted values: bitbucket, git, github, githubenterprise, svn, tfsgit, tfsversioncontrol
  • top: Maximum number of pipelines to list.

Delete pipeline

You can delete a pipeline using the az pipelines delete command.

  1. az pipelines delete --id
  2. [--detect {false, true}]
  3. [--org]
  4. [--project]
  5. [--yes]

Parameters

  • id: (Required) ID of the pipeline.
  • detect: Automatically detect organization. Accepted values: false, true
  • org or organization: Azure DevOps organization URL. You can configure the default organization using az devops configure -d organization=ORG_URL. Required if not configured as default or picked up via git config. Example: https://dev.azure.com/MyOrganizationName/.
  • project or p: Name or ID of the project. You can configure the default project using az devops configure -d project=NAME_OR_ID. Required if not configured as default or picked up via git config.
  • yes or y: Do not prompt for confirmation.

Example

The following example lists pipelines in table format, and then deletes the pipeline with an ID of 6. This example uses the following default configuration: az devops configure —defaults organization=https://dev.azure.com/fabrikam-tailspin project=FabrikamFiber

  1. az pipelines list --output table
  2. ID Path Name Status Default Queue
  3. ---- ------ ------------- -------- ------------------
  4. 6 \ FabrikamFiber enabled Hosted Ubuntu 1604
  5. az pipelines delete --id 6
  6. Are you sure you want to delete this pipeline? (y/n): y
  7. Pipeline 6 was deleted successfully.

Note

In Microsoft Team Foundation Server (TFS) 2018 and previous versions,run and release pipelines are called definitions,runs are called builds,service connections are called service endpoints,stages are called environments,and jobs are called phases.

Note

This guidance applies to TFS version 2017.3 and newer.

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".

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

Prerequisites

Initialize your repository


If you already have a repository in your project, you can skip to the next step: Add a script to your repository


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

Repos files

  • 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

  • Navigate to your repository by clicking Code in the top navigation.

  • 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

Add a script to your repository

Create a PowerShell script that prints Hello world.

  • Go to Azure Repos.

  • Add a file.

On the Files tab, from the repo node, select the 'New -> File' option

  • In the dialog box, name your new file and create it.
  1. HelloWorld.ps1
  • Copy and paste this script.
  1. Write-Host "Hello world"
  • Commit (save) the file.
  • Go to the Code hub.

  • Add a file.

On the Files tab, from the repo node, select the 'New -> File' option

On the Files tab, from the repo node, select the 'New -> File' option

On the Files tab, from the repo node, select the 'Add file' option

  • In the dialog box, name your new file and create it.
  1. HelloWorld.ps1
  • Copy and paste this script.
  1. Write-Host "Hello world"
  • Commit (save) the file.

In this tutorial, our focus is on CI/CD, so we're keeping the code part simple. We're working in an Azure Repos Git repository directly in your web browser.


When you're ready to begin building and deploying a real app, you can use a wide range of version control clients and services with Azure Pipelines CI builds. Learn more.


Create a build pipeline

Create a build pipeline that prints "Hello world."

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

navigate to builds tab

  • Create a new pipeline.

builds-tab-mine-new-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

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

  • Start with an Empty job.

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

  • 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.

builds-tab-add-task-to-job

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

  • For the Script Path argument, select the … button to browse your repository and select the script you created.

PowerShell task

  • Select Save & queue, and then select Save.
  • Select Build and Release, and then choose Builds.

navigate to builds tab

  • Create a new pipeline.

builds-tab-mine-new-button

  • Start with an empty pipeline

  • Select Pipeline and specify whatever Name you want to use. For the Agent pool, select Default.

  • On the left side, select + Add Task to add a task to the job, and then on the right side select the Utility category, select the PowerShell task, and then choose Add.

builds-tab-add-task-to-job

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

  • For the Script Path argument, select the … button to browse your repository and select the script you created.

PowerShell task

  • Select Save & queue, and then select Save.
  • Select Azure Pipelines, and then the Builds tab.

navigate to builds tab

  • Create a new pipeline.

builds-tab-mine-new-button

  • Start with an empty pipeline.

  • Select Pipeline and specify whatever Name you want to use.

  • On the Options tab, select Default for the Agent pool, or select whichever pool you want to use that has Windows build agents.

  • On the Tasks tab, make sure that Get sources is set with the Repository and Branch in which you created the script.

  • On the left side select Add Task, and then on the right side select the Utility category, select the PowerShell task, and then select Add.

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

  • For the Script Path argument, select the … button to browse your repository and select the script you created.

PowerShell task

  • Select Save & queue, and then select Save.

A build pipeline is the entity through which you define your automated build pipeline. In the build pipeline, you compose a set of tasks, each of which perform a step in your build. The task catalog provides a rich set of tasks for you to get started. You can also add PowerShell or shell scripts to your build pipeline.


Publish an artifact from your build

A typical build produces an artifact that can then be deployed to various stages in a release. Here to demonstrate the capability in a simple way, we'll simply publish the script as the artifact.

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

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

publish artifact task

Path to publish: Select the … button to browse and select the script you created.

Artifact name: Enter drop.

Artifact publish location: Select Azure Artifacts/TFS.

  • On the Tasks tab, select Add Task.

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

publish artifact task

Path to Publish: Select the … button to browse and select the script you created.

Artifact Name: Enter drop.

Artifact Type: Select Server.


Artifacts are the files that you want your build to produce. Artifacts can be nearly anything your team needs to test or deploy your app. For example, you've got a .DLL and .EXE executable files and .PDB symbols file of a C# or C++ .NET Windows app.


To enable you to produce artifacts, we provide tools such as copying with pattern matching, and a staging directory in which you can gather your artifacts before publishing them. See Artifacts in Azure Pipelines.


Enable continuous integration (CI)

  • Select the Triggers tab.

  • Enable Continuous integration.


A continuous integration trigger on a build pipeline indicates that the system should automatically queue a new build whenever a code change is committed. You can make the trigger more general or more specific, and also schedule your build (for example, on a nightly basis). See Build triggers.


Save and queue the build

Save and queue a build manually and test your build pipeline.

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

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

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

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

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.

build console

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

build console

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

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

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

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

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.

build console

build console


  • Go to the build summary.

build console link to build summary

  • On the Artifacts tab of the build, notice that the script is published as an artifact.

artifacts explorer


You can view a summary of all the builds or drill into the logs for each build at any time by navigating to the Builds tab in Azure Pipelines. For each build, you can also view a list of commits that were built and the work items associated with each commit. You can also run tests in each build and analyze the test failures.


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

  • On the dialog box, select the Queue button.

This queues a new build on the agent. 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.

build console

  • Go to the build summary.

build console link to build summary

  • On the Artifacts tab of the build, notice that the script is published as an artifact.

artifacts explorer


You can view a summary of all the builds or drill into the logs for each build at any time by navigating to the Builds tab in Build and Release. For each build, you can also view a list of commits that were built and the work items associated with each commit. You can also run tests in each build and analyze the test failures.


Add some variables and commit a change to your script

We'll pass some build variables to the script to make our pipeline a bit more interesting. Then we'll commit a change to a script and watch the CI pipeline run automatically to validate the change.

  • Edit your build pipeline.

  • On the Tasks tab, select the PowerShell script task.

  • Add these arguments.

build console

PowerShell task

PowerShell task

PowerShell task

Arguments

  1. -greeter "$(Build.RequestedFor)" -trigger "$(Build.Reason)"

Finally, save the build pipeline.

Next you'll add the arguments to your script.

  • Go to your Files in Azure Repos (the Code hub in the previous navigation and TFS).

  • Select the HelloWorld.ps1 file, and then Edit the file.

  • Change the script as follows:

  1. Param(
  2. [string]$greeter,
  3. [string]$trigger
  4. )
  5. Write-Host "Hello world" from $greeter
  6. Write-Host Trigger: $trigger
  • Commit (save) the script.

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.

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

  • Select the new build that was created and view its log.

  • Notice that the person who changed the code has their name printed in the greeting message. You also see printed that this was a CI build.

Build a summary PowerShell script log

build summary powershell script log


We just introduced the concept of build variables in these steps. We printed the value of a variable that is automatically predefined and initialized by the system. You can also define custom variables and use them either in arguments to your tasks, or as environment variables within your scripts. To learn more about variables, see Build variables.


You've got a build pipeline. What's next?

You've created a build pipeline that automatically builds and validates whatever code is checked in by your team. At this point, you can continue to the next section to learn about release pipelines. Or, if you prefer, you can skip ahead to create a build pipeline for your app.

Create a release pipeline

Define the process for running the script in two stages.

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

  • 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.

  • Select the action to start with an Empty job.

  • Name the stage QA.

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

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

trigger continuous deployment

  • Select the Tasks tab and select your QA stage.

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

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

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

  • For the Script Path argument, select the … button to browse your artifacts and select the script you created.

  • Add these Arguments:

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

clone-release-environment

  • Rename the cloned stage Production.

  • Rename the release pipeline Hello world.

rename release pipeline

  • Save the release pipeline.
  • Go to the Build and Release tab, and then select Releases.

  • 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 definition.

  • Select the action to start with an Empty definition.

  • Name the stage QA.

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

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

trigger continuous deployment

trigger continuous deployment


  • Select the Tasks tab and select your QA stage.

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

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

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

  • For the Script Path argument, select the … button to browse your artifacts and select the script you created.

  • Add these Arguments:

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

clone-release-environment

  • Rename the cloned stage Production.

  • Rename the release pipeline Hello world.

rename release pipeline

  • Save the release pipeline.
  • Go to Azure Pipelines, and then to the Releases tab.

  • Select the action to create a New pipeline.

  • On the dialog box, select the Empty template and select Next.

  • Make sure that your Hello world build pipeline that you created above is selected. Select Continuous deployment, and then select Create.

  • Select Add tasks in the stage.

  • On the Task catalog dialog box, select Utility, locate the PowerShell task, and then select its Add button. Select the Close button.

  • For the Script Path argument, select the … button to browse your artifacts and select the script you created.

  • Add these Arguments:

  1. -greeter "$(Release.RequestedFor)" -trigger "$(Build.DefinitionName)"
  • Rename the stage QA.

rename release environment

  • Clone the QA stage.

clone-release-environment

Leave Automatically approve and Deploy automatically… selected, and select Create.

  • Rename the new stage Production.

  • Rename the release pipeline Hello world.

rename release pipeline

  • Save the release pipeline.

A release pipeline is a collection of stages to which the application build artifacts are deployed. It also defines the actual deployment pipeline for each stage, as well as how the artifacts are promoted from one stage to another.


Also, notice that we used some variables in our script arguments. In this case, we used release variables instead of the build variables we used for the build pipeline.


Deploy a release

Run the script in each stage.

  • Create a new release.

create release

When Create new release appears, select Create.

  • Open the release that you created.

release created

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

release logs

  • Create a new release.

create release

When Create new release appears, select Create (TFS 2018.2) or Queue (TFS 2018 RTM).

  • Open the release that you created.

release created

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

release logs

  • Create a new release.

create release

  • Open the release that you created.

release created

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

release logs


You can track the progress of each release to see if it has been deployed to all the stages. You can track the commits that are part of each release, the associated work items, and the results of any test runs that you've added to the release pipeline.


Change your code and watch it automatically deploy to production

We'll make one more change to the script. This time it will automatically build and then get deployed all the way to the production stage.

  • Go to the Code hub, Files tab, edit the HelloWorld.ps1 file, and change it as follows:
  1. Param(
  2. [string]$greeter,
  3. [string]$trigger
  4. )
  5. Write-Host "Hello world" from $greeter
  6. Write-Host Trigger: $trigger
  7. Write-Host "Now that you've got CI/CD, you can automatically deploy your app every time your team checks in code."
  • Commit (save) the script.

  • Select the Builds tab to see the build queued and run.

  • After the build is completed, select the Releases tab, open the new release, and then go to the Logs.

Your new code automatically is deployed in the QA stage, and then in the Production stage.

release script step final log

release script step final log

release script step final log


In many cases, you probably would want to edit the release pipeline so that the production deployment happens
only after some testing and approvals are in place. See Approvals and gates overview.


Next steps

You've learned the basics of creating and running a pipeline.Now you're ready to configure your build pipeline for the programming language you're using.Go ahead and create a new build pipeline, and this time, use one of the following templates.

LanguageTemplate to use
.NETASP.NET
.NET CoreASP.NET Core
C++.NET Desktop
GoGo
JavaGradle
JavaScriptNode.js
XcodeXcode

Q & A

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

What is Continuous Integration?

What is Continuous Delivery?

What is DevOps?

What kinds of version control 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:

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.

all-definitions-build-action-menu-replicate-actions

all-definitions-build-action-menu-replicate-actions

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.

save-as-draft

save-as-draft

You can edit and test your draft as needed.

edit draft

edit draft

When you're ready you can publish the draft to merge the changes into your build pipeline.

publish draft

publish draft

Or, if you decide to discard the draft, you can delete it from the All Pipeline tab shown above.

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.

What else can I do when I queue a build?

You can queue builds automatically or manually.

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

You can queue builds automatically or manually.

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

Where can I learn more about build pipeline settings?

To learn more about build pipeline settings, see:

To learn more about build pipeline settings, see:

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.