Pipeline execution sequence - Azure Pipelines (2023)

  • Article
  • 12 minutes to read

Azure DevOps-Dienste | Azure DevOps Server 2022 – Azure DevOps Server 2019

Runs represent the execution of a pipeline. During a run, the pipeline is processed and agents process one or more jobs. A pipeline run includesJobs, steps and tasks. It runs on continuous integration (CI) and continuous delivery (CD) pipelines.

Pipeline execution sequence - Azure Pipelines (1)

When you run a pipeline, a lot happens behind the scenes. While you often don't need to know anything about it, it occasionally helps to stay in control. At a high level, Azure Pipelines:

  • process pipeline
  • Request one or more agents to run jobs
  • Send requests to agents and collect results

On the agent side, an agent for each job:

  • Get ready for work
  • Complete each job step
  • Report results to Azure Pipelines

possibly jobssucceed, fail, or abort.There are also situations in which a jobcannot be completed. Understanding how this happens can help you troubleshoot.

Let's look at each action individually.

(Video) Azure Data Factory - Execute Pipelines in Sequence

process pipeline

Pipeline execution sequence - Azure Pipelines (2)

To convert a pipeline to an execution, Azure Pipelines follows several steps in this order:

  1. first expandmodelsand evaluatemodel expressions.
  2. Then evaluate the dependencies of thescenarioLevel to select the first levels to run.
  3. For each phase selected for execution, two things happen:
    • All resources used in all jobs are logged and validatedpermissionrun.
    • To assessJob-level dependenciesto select the first jobs to run.
  4. Expand for each job selected to runmultiple settings(Strategy: MatrixoStrategy: parallelin YAML) in various runtime jobs.
  5. Evaluate for each runtime jobConditionsto decide whether this job can be run.
  6. request an agentfor each eligible runtime task.

When runtime jobs complete, Azure Pipelines detects whether new jobs can run. If that's the case, repeat steps 4-6 with the new orders. Also, once phases are completed, steps 2 through 6 are repeated for all new phases.

This order helps answer a common question: why can't I use certain variables in my template parameters? Step 1, expanding the template, only affects the body of the YAML document. There are no runtime variables during this step. After step 1, the model parameters have been resolved and no longer exist.

It also answers another common problem: why can't I useVariablesresolve service connection/environment names? Resources are authorized before a stage can run, so the stage and task level variables are not available. Pipeline-level variables can be used, but only variables that are explicitly included in the pipeline. Variable groups themselves are a resource that requires authorization, their data is also not available when checking resource authorization.

request an agent

Whenever Azure Pipelines needs to run a job, it will ask for itPoolforAgent.(server jobsare an exception as they run on the Azure Pipelines server itself).Hosted by MicrosoftYself-hostedAgent groups work a little differently.

Microsoft Hosted Agent Pool Requirements

First, the service checks your company's side jobs. Sums up all jobs run on all Microsoft hosted agents and compares them to the number of parallel jobs purchased. If no parallel slots are available, the job must wait in a slot to be released.

As soon as a parallel slot is available, work is routed to the requested agent type. Conceptually, the pool hosted by Microsoft is a large global pool of machines. (That's actually many different physical groups, broken down by geography and operating system type.) Based onvmImage(in YAML) or group name (in the classic editor), an agent is selected.

Pipeline execution sequence - Azure Pipelines (3)

(Video) 31. Execute Pipeline Activity in Azure Data Factory

All Microsoft group agents are new virtual machines with no pipelines running yet. When the job completes, the agent virtual machine is disposed of.

Self-hosted agent pool requests

similar toGroup hosted by Microsoft, the service first checks for parallel tasks in your organization. Sums all jobs run on all self-hosted agents and compares them to the number of parallel jobs purchased. If no parallel slots are available, the job must wait in a slot to be released.

As soon as a parallel slot becomes available, the self-hosted pool is searched for a compatible agent. Powered by self-hosted agentscapabilities, which are strings that indicate that specific software has been installed or settings have been configuredrequirementsThese are the skills needed to get the job done. If a free agent with skills matching the pipeline requirements cannot be found, the job will continue to wait. If there are no agents in the pool whose skills meet the requirements, the job will fail.

Self-hosted agents are typically reused from one run to the next. For self-hosted agents, a pipeline job can have side effects, for example, B. hot caches or already have most commits in the local repository.

Get ready to run a job

After an agent accepts an assignment, they must do some prep work. The agent downloads them all (and caches them for next time).Tasksnecessary to perform the job. Frees up disk space to store source code, artifacts and output used in execution. so it beginsexecution steps.

complete each step

The steps are performed one after the other. Before a step can be started, all previous steps must be completed (or skipped).

Pipeline execution sequence - Azure Pipelines (4)

The steps are implemented byTasksThe tasks themselves are implemented as Node.js or PowerShell scripts. The task system passes input and output to support scripts. It also offers some general services like changing the system path and creating new ones.pipeline variables.

Each step runs in its own process, isolating it from the environment left by previous steps. Due to this step-by-step model, environment variables are not persisted across Agent steps:registry commands.When a task or script writes a logging command to standard output, the agent performs the requested action.

(Video) Azure Data Factory - Execute Pipelines in Sequence

There is an agent command to create new pipeline variables. Pipe variables are automatically converted to environment variables in the next step to define a new variablemiVarValormeinWert, a script can do this:

echo '##vso[task.setVariable variable=myVar]myValue'
Write-Host "##vso[task.setVariable variable=myVar]myValue"

Report and collect results

Each step can report warnings, errors, and failures. Errors and warnings are reported on the pipeline summary page and the task is marked as "successful with problems". Errors are also reported on the summary page, but mark the task as "failed". .A step is an error if it explicitly reports an error (using a##vsocommand) or terminate the script with a non-zero exit code.

Pipeline execution sequence - Azure Pipelines (5)

As the steps run, the agent continuously sends outbound lines to the service. That's why you can watch a live stream on the console. At the end of each step, the full step output is also uploaded as a log file. Logs can be downloaded once the pipeline is complete. Other items the agent can carry includeartifactsYTest resultsThey will also be available once the channeling is complete.

status and conditions

The agent tracks the success or failure of each step. If the problem steps succeed or fail, the task status is updated. The task always reflects the “worst” result of each of its steps: if a step fails, the task also fails.

Before executing a step, the agent checks that stepIllnessto determine whether to run it. By default, a step runs only when the task status is Succeeded or Succeeded with problems. Many jobs have cleanup steps that need to be done no matter what so they can specify the "always"() condition. Cleanup steps can also be configured to run only forcancellation.A subsequent cleanup step cannot prevent the job from failing; Jobs can never return to success after going into failure.

Wait times and disconnections

Each job has a time limit. If the job is not completed in the specified time, the server will cancel the job. Attempts to tell the agent to stop and marks the job as cancelled, which means canceling all remaining steps and loading all remaining steps.Results.

Jobs have a grace period known as the demolition lead time, in which all demolition work is completed. (Remember that steps can be marked for executionalso in case of cancellation.) If the agent has not reported that the job completed after the timeout plus the interrupt timeout, the server marks the job as an error.

As Azure Pipelines distributes work to agent machines, agents may stop responding to the server from time to time. This can happen when the agent's host computer fails (power failure, VM shutdown) or when a network error occurs. For detection Under these conditions, the agent sends a heartbeat message once a minute to notify the server that it is still operational. If the server does not receive a heartbeat for five consecutive minutes, it assumes that the agent will not return. The job is marked as an error telling the user to retry the pipeline.

(Video) Trigger one pipeline AFTER another in Azure Pipelines

Manage Runs Through the CLI

Using the Azure DevOps CLI, you can list pipeline runs in your project and view details about a specific run. You can also add and remove tags in your pipeline run.

requirements

  • You must have installed the Azure DevOps CLI extension as described inGet started with the Azure DevOps CLI.
  • Enter no Azure DevOps comlogin az.
  • For the examples in this article, set the default organization toaz devops configure --defaults organization=IhreOrganizations-URL.

List pipeline runs

List the pipeline runs in your project with theaz Pipelines ExecutionListDomain. To get started, seeGet started with the Azure DevOps CLI.

az pipelines run list [--branch] [--org] [--pipeline-ids] [--project] [--query-order {FinishTimeAsc, FinishTimeDesc, QueueTimeAsc, QueueTimeDesc, StartTimeAsc, StartTimeDesc}] [--reason {all, batchedCI, buildCompletion, checkInShelveset, individualCI, manual, pullRequest, scheduled, activated, user-created, validShelveset}] [--requested-for] [--result {canceled, failed, none, partialSucceeded, succeeded }] [ -- status {all, canceling, completed, in progress, none, not started, deferred}] [--tags] [--top]

optional parameters

  • Zweig: Filter by builds for this branch.
  • organization: Azure DevOps Organization URL. You can set the default organization withaz devops configure -d Organization=ORG_URL. Required if not set to default or selectedgit config. Example:--org https://dev.azure.com/NombreDeMiOrganización/.
  • ID do pipeline: Space-separated definition IDs to list builds.
  • Project: Project name or ID. You can set the default project withaz devops configure -d projeto=NAME_OR_ID. Required if not set to default or selectedgit config.
  • consultation request: Set the order in which pipeline runs are listed. The accepted values ​​areFinishTimeAsc,EndTimeDesc,QueueTimeAsc,QueueTimeDesc,Start timeAscendant, YStart Time Description.
  • Reason: show only builds for this specified reason. The accepted values ​​areLotes-CI,completion of construction,checkInShelvesset,Individual,Manual,pull request,Time,motivated,user created, YvalidarShelvesset.
  • Request: Restriction on requested builds for a specific user or group.
  • Result: Restriction on builds with a specific result. The accepted values ​​arecanceled,failed,none,partially successful, Ywas successful.
  • state: Restriction on builds with a certain state. The accepted values ​​areem,interrupt,accomplished,no course,none,not started, Ydelay.
  • key words: Restrict to builds with each of the specified tags. separate space.
  • Above: Maximum number of builds to enumerate.

Example

The following command lists the first three pipeline runs with statusaccomplishedand a result ofwas successfuland returns the result in table format.

Pipeline run list az --status completed --successful result --top 3 --output table id number Run state result ID pipeline name source branch end time ------- - -- ----- -- - --------- --------- ---- --- ------ -------- --- ----- -- -------- ---------- ----- --- ---- - - -----125 20200124.1 completed successfully 12 Githubname.pipelines-java- master 2020-01-23 18:56:10.067588 56.633450 Manual122 2021 completed successfully 12 Githubname.pipelines-java master 2020-01-23 11:48:05.574742 manual

View pipeline run details

View the details of a pipeline running in your project withaz tubes shownDomain. To get started, seeGet started with the Azure DevOps CLI.

az pipes running show --id [--open] [--org] [--project]

Parameter

  • I WENT: Necessary. Pipeline run ID.
  • Open: Optional. Opens the build results page in your web browser.
  • organization: Azure DevOps Organization URL. You can set the default organization withaz devops configure -d Organization=ORG_URL. Required if not set to default or selectedgit config. Example:--org https://dev.azure.com/NombreDeMiOrganización/.
  • Project: Project name or ID. You can set the default project withaz devops configure -d projeto=NAME_OR_ID. Required if not set to default or selectedgit config.

Example

The following command displays details of the pipeline run with ID123and returns the results in tabular form. It also opens your web browser with the build results page.

az pipelines running show --id 122 --open --output table run id number status result pipeline id pipeline source name branch queue time reason -------- ---------- -- - - ----- --------- ------------- ------------------- -- - - --- --------------- ---------------------------- -- - --------- -- ---- --123 20200123.2 completed successfully 12 Githubname.pipelines-java master 2020-01-23 11:55:56.633450 manual

Add Tag to Pipeline Run

Add a tag to a pipeline running in your project withthe pipelines execute tag addDomain. To get started, seeGet started with the Azure DevOps CLI.

az-Pipelines executa a tag add --run-id --tags[--org][--project].

Parameter

  • run id: Necessary. Pipeline run ID.
  • key words: Necessary. Tags to add to pipeline execution (comma separated values).
  • organization: Azure DevOps Organization URL. You can set the default organization withaz devops configure -d Organization=ORG_URL. Required if not set to default or selectedgit config. Example:--org https://dev.azure.com/NombreDeMiOrganización/.
  • Project: Project name or ID. You can set the default project withaz devops configure -d projeto=NAME_OR_ID. Required if not set to default or selectedgit config.

Example

The following command adds the tagYAMLto the pipe executed with the ID123and returns the result in JSON format.

az-Pipelines performs adding tags --run-id 123 --tags YAML --output json[ "YAML"]

Show pipeline run labels

List the tags for a pipeline run in your project using theaz-Pipelines run tag listDomain. To get started, seeGet started with the Azure DevOps CLI.

(Video) Trigger Azure Devops build pipelines using REST API

az-pipelines run lista de tags --run-id [--org] [--project]

Parameter

  • run id: Necessary. Pipeline run ID.
  • organization: Azure DevOps Organization URL. You can set the default organization withaz devops configure -d Organization=ORG_URL. Required if not set to default or selectedgit config. Example:--org https://dev.azure.com/NombreDeMiOrganización/.
  • Project: Project name or ID. You can set the default project withaz devops configure -d projeto=NAME_OR_ID. Required if not set to default or selectedgit config.

Example

The following command lists pipeline execution tags by ID123and returns the result in tabular form.

az pipelines executam lista de tags --run-id 123 --output tableTags------YAML

Remove pipeline run tag

Remove a tag from a pipeline running in your projectaz-Pipelines performs tag strippingDomain. To get started, seeGet started with the Azure DevOps CLI.

az-Pipelines performs tag stripping --run-id --tag [--org] [--project].

Parameter

  • run id: Necessary. Pipeline run ID.
  • Signal: Necessary. Label to remove from pipeline run.
  • organization: Azure DevOps Organization URL. You can set the default organization withaz devops configure -d Organization=ORG_URL. Required if not set to default or selectedgit config. Example:--org https://dev.azure.com/NombreDeMiOrganización/.
  • Project: Project name or ID. You can set the default project withaz devops configure -d projeto=NAME_OR_ID. Required if not set to default or selectedgit config.

Example

The following command removes theYAMLpipe tag executed with id123.

az pipelines perform tag removal --run-id 123 --tag YAML

Videos

1. Azure DevOps Tutorial for Beginners | CI/CD with Azure Pipelines
(TechWorld with Nana)
2. Create Pipeline to run automation test cases in Azure DevOps
(Software Development Engineer in Test)
3. Dependency between stages in azure devops pipeline | How to skipped a stage in YAML azure pipeline |
(Viren Automation Testing)
4. Create a sequence of executions with pipelines
(Valohai)
5. Pass variables and parameters between build and release pipelines on Azure DevOps
(geralexgr)
6. Azure DevOps Pipelines with Terraform and Stages
(Travis Roberts)
Top Articles
Latest Posts
Article information

Author: Nathanial Hackett

Last Updated: 12/23/2022

Views: 5752

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Nathanial Hackett

Birthday: 1997-10-09

Address: Apt. 935 264 Abshire Canyon, South Nerissachester, NM 01800

Phone: +9752624861224

Job: Forward Technology Assistant

Hobby: Listening to music, Shopping, Vacation, Baton twirling, Flower arranging, Blacksmithing, Do it yourself

Introduction: My name is Nathanial Hackett, I am a lovely, curious, smiling, lively, thoughtful, courageous, lively person who loves writing and wants to share my knowledge and understanding with you.