Creating Multiple Job

Creating Multiple Job

You may need to set up additional jobs when developing a build pipeline for an application that must be built for multiple operating systems simultaneously. You can create two types of jobs: agent jobs and agentless jobs.

  • Agent Job: Runs on an agent or target computer.
  • Agentless Job: Runs directly on the Azure DevOps application server.

To create additional agent jobs within a build pipeline, follow these steps:

  1. Edit the build pipeline by clicking the "..." symbol and selecting "Edit".


Editing a build pipeline

2. Click on the ... button and select Add an agent job:

Adding an agent job

3. Click on "Agent job" and update the job information with the following details:

- Display name: Agent job 2

- Agent pool: Azure Pipelines

- Agent Specification: ubuntu-latest


Adding another job

4. Click on the + button for the job, type the Command line in the search box, and then click the Add button:

Adding a new task

5. Select the row containing the Command Line Task and update the following fields:

- Task version: Specify the package version of the Command Line Task. Typically, the latest version is used. In this case, it is version 2.

- Display name: Enter a descriptive name for your task. For example, "Second Command Line Task".

- Script: Enter the following basic script: echo "Hello Second Task on Linux". This script will print the specified text on the resultant page after the pipeline execution is complete.

Updating the second command line task

6. After you click Save & queue, you will see the following result:

The result of two agent jobs

Let’s look at some of the advanced options available in the Agent job properties, as shown in the following screenshot:

Advanced options for an agent job
Let's examine these options in more detail:        
- Agent selection:

- Agent pool: Choose either a custom or default agent to build the jobs.

- Demands: Add condition parameters to restrict the job to agents that meet specific criteria. For example, you can specify that only a Linux agent is eligible to run this job.

Execution Plan:

- Parallelism: Choose from the following options:

- None: Jobs will not run in parallel.

- Multi-configuration: Enable this when you have different configurations for each agent job. For example, if you need to run tests on three different browsers (Chrome, Edge, and Firefox), use this option.

- Multi-agent: Enable this when you have multiple agents and need to utilize them for running an agent job concurrently.

- Timeout: Specify the maximum number of minutes an agent job is allowed to run before it is canceled.

- Job cancel timeout: Enter the number of minutes before an agent job is canceled after a cancel request is received.

- Dependencies: Select a previous agent job that must be completed successfully before the next agent job can run.

Additional options:

- Allow scripts to access the OAuth token: Enable this if you need to use the OAuth token to pass data to another agent job via REST API.

- Run this job:

- Only when all previous jobs have succeeded

- Even if a previous job has failed

- Only when a previous job has failed

- Custom condition using variable expressions: For example, succeeded() means the agent job will run only if the previous job completed successfully.

In this section, you learned how to create a second job to separate the Linux operating system. Two jobs can run simultaneously, which is useful for tasks that need to run on different operating systems without dependency on each other. For instance, when creating a build pipeline that needs to deploy an application to Google Play and the Apple Store simultaneously without running in sequence.

Creating Triggers

In this section, We will learn how to create a trigger to make a build pipeline run automatically when you push code to a specific branch:

1. Edit the build pipeline by clicking on the three dots to view the details, then select "Edit":

Editing a build pipeline

2. Click on "Triggers" and update the following settings:

- Enable continuous integration: Turn this on.

- Branch filters:

- Type: Include

- Branch specification: main

With these settings, the build pipeline will run automatically whenever you push code to the main branch, enabling continuous integration.

Turning on continuous integration

In this section, you learned how to enable a build pipeline to run automatically after pushing code. This automation reduces the daily workload by eliminating the need to manually build your code whenever it is pushed to the source code repository.

Creating Stages

In this section, you will learn how to create a stage using the classic editor. A stage is a task group designed for different environments, such as development, non-functional testing, and production. Each group contains jobs and tasks specific to its environment. Utilizing multiple stages is beneficial when deploying applications across several environments. If only one stage is used for both development and production, a failure in the development pipeline would cause the production pipeline to fail as well. Here’s how to create a stage:

1. Click on "Releases" and select "New pipeline":

Creating a new pipeline


2. Enter a stage name and click on Save:

Edit stage properties

3. Select the relevant repository folder. In our case, it is an Azure Repos folder, the root folder for your code, and the Azure pipeline file:

Confirming a pipeline

In the last few days Post, We explored the core features required to create a pipeline. We learned how to set up a build pipeline that includes jobs and tasks, and how to create a trigger to filter branches for running a build agent. These triggers, combined with jobs and tasks, are fundamental to any effective CI/CD pipeline, facilitating automated, efficient, and reliable software delivery.

"In our upcoming post, we'll explore, how to enhance a build pipeline using YAML and run it on an agent."
Important Links to Understand whole core features required to create a pipeline:         

1. Build Pipeline with a Single Job: https://www.dhirubhai.net/pulse/creating-build-pipeline-single-job-ankit-ranjan--sconf/?trackingId=f216PsCNIpNXfZA1OLG63g%3D%3D

2. Creating Tasks: https://www.dhirubhai.net/pulse/creating-tasks-ankit-ranjan--rplvf/?trackingId=NKOOyhatxyhcutnP777oNA%3D%3D

3. Creating Multiple Jobs: https://www.dhirubhai.net/pulse/creating-multiple-jobs-ankit-ranjan--n51bf/?trackingId=Xb%2BAraI8F%2FpSRFQcSzEQUQ%3D%3D

4. Creating Triggers: https://www.dhirubhai.net/pulse/creating-triggers-ankit-ranjan--gzlif/?trackingId=1jRYdCXyCZAuOjJ%2FWf7BJQ%3D%3D

5. Service Connection for Azure Resources: https://www.dhirubhai.net/pulse/creating-service-connection-azure-resources-ankit-ranjan--enwvf/?trackingId=%2FpHibI7xDPfX5VlBWUkgqg%3D%3D

6. Service Connection for Azure Resources: https://www.dhirubhai.net/pulse/creating-service-connection-azure-resources-ankit-ranjan--icsnf/?trackingId=6soMMDWYZRbgdbfeUNl8Gg%3D%3D

7. Tasks Under a Job In Azure: https://www.dhirubhai.net/pulse/creating-tasks-under-job-azure-ankit-ranjan--lksef/?trackingId=cGC9SKM8JWihViMWAB4QYQ%3D%3D

Microsoft Learn Microsoft Azure DevOps Microsoft Azure






要查看或添加评论,请登录

社区洞察

其他会员也浏览了