Azure Pipeline Part 3 – steps jobs stages

Azure Pipeline Part 3 – steps jobs stages

Azure Pipeline Part 3 – steps jobs stages

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

Today we are going to discuss steps, jobs and stages in Azure Pipelines. Azure pipeline consists of one or more stages that describe a CI/CD process. Stages are the major divisions in a pipeline. For example, your pipeline can have one stage each for build, test and deploy your application.

A stage consists of one or more jobs, which are units of work assignable to the same machine. You can arrange both stages and jobs into dependency graphs. For example, your build stage can have multiple jobs for each component of your application.

A job consists of one or more steps. Steps can be tasks, scripts, or references to external templates. Steps are the lowest performable actions in your pipeline. For example, you can have multiple steps to build a component of your application.

This hierarchy is reflected in the structure of a YAML file like:

  • Pipeline
    • Stage 1
      • Job 1
        • Step 1.1
        • Step 1.2
      • Job 2
        • Step 2.1
        • Step 2.2
    • Stage 2

Azure Pipeline Part 3 – steps jobs stages

Prerequisites:

Setup:

Azure Pipeline – Steps:

A step is a linear sequence of operations that make up a job. Each step runs in its own process on an agent and has access to the pipeline workspace on a local hard drive. This behavior means environment variables aren’t preserved between steps but file system changes are. Azure Pipeline supports below types of steps –

  • script: Using script, you can run a script using cmd.exe on Windows and Bash on other platforms.
  • bash: Using bash, you can run a script or command in Bash on Windows, macOS, and Linux.
  • pwsh: Using pwsh, you can run a script or command in PowerShell Core on Windows, macOS, and Linux.
  • powershell: Using powershell, you can run a script or command in Windows PowerShell.
  • task: Using task, you can perform various pre-configured steps in your pipeline.
  • checkout: Using checkout, you can clone and use an external repository in your pipeline.
  • templates: Using template, you can define a set of steps in one file and use it multiple times in another file.

Azure Pipeline – Steps syntax:

Azure Pipeline – Steps examples:

Azure Pipelines – Jobs

You can organize your pipeline into jobs. Every pipeline has at least one job. A job is a series of steps that run sequentially as a unit. In other words, a job is the smallest unit of work that can be scheduled to run. Jobs can be of different types, depending on where they run.

  • Agent pool jobs run on an agent in an agent pool.
  • Server jobs run on the Azure DevOps Server.
  • Container jobs run in a container on an agent in an agent pool.

Azure Pipelines – Jobs syntax:

Azure Pipelines – Jobs examples:

Azure Pipelines – Stages:

Stages are logical boundaries in your pipeline where you can pause the pipeline and perform various checks. Every pipeline has at least one stage even if you do not explicitly define it. You can also arrange stages into a dependency graph so that one stage runs before another one. Each stage can have one or more collection of related jobs. There is a limit of 256 jobs for a stage.

Azure Pipelines – Stages syntax:

Azure Pipelines – Stages examples:

Clean up:

Hope you have enjoyed this article. To know more about Azure DevOps, please refer below official documentation

https://docs.microsoft.com/en-us/azure/devops/?view=azure-devops

Leave a Reply

Close Menu