Azure Devops Self-hosted Agent parallel jobs - azure-devops

We have deployed Azure devops Self-hosted Agent in our own agentpool.
We have also purchased 4 parallel job per agent , but when our build runs, it runs only one job at a time and other pipeline/release jobs have to wait.
How can we run 4 parallel pipeline/release jobs ?

How can we run 4 parallel pipeline/release jobs ?
According to your screenshot, you seem to only register one self-hosted agent, and running a parallel job will consume one agent, so if you want to run 4 jobs in parallel, you need to register at least 4 self-hosted agents.

Running parallel jobs on the same agent can be achieved by container jobs
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/container-phases?view=azure-devops-2019#multiple-jobs-with-agent-pools-on-a-single-hosted-agent
There is a small gotcha around being logged out when multiple jobs are running at the same time and a Docker workaround suggested here
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/container-phases?view=azure-devops-2019#multiple-jobs-with-agent-pools-on-a-single-hosted-agent

Related

Is it possible in Azure DevOps Pipelines to wait for enough agents to run the job

We are running into the following issue:
We have a job in our pipeline that runs tests. The number of tests need to be distributed over 4 agents to run optimal. It can happen that only one agent is available and the job will start to run all the load on that specific agent, which can then time-out because it takes too long for other agents to become available in time to share in the load.
In essence, if we run with 4 agents, the job will run with optimal efficiency.
My question: is it possible to let a job wait for a specific number of agents to become available before starting the tasks in the job?
That`s not possible through out-of-box features.... But you may create a simple PowerShell script that will query your agents statuses: https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/agents/list?view=azure-devops-rest-7.1
and use includeAssignedRequest
GET https://dev.azure.com/{organization}/_apis/distributedtask/pools/{poolId}/agents?includeAssignedRequest={includeAssignedRequest}&api-version=7.1-preview.1
if you see assignedRequest, your build agent is busy...

Do all the tasks across agent jobs in the pipeline run on the same agent?

I'm learning about azure pipelines. By default you get 1 free parallel job for x number of minutes.
A pipeline contains number of tasks. And atleast 1 job. All the tasks in the pipeline (across multiple jobs) run on the same agent?
Does 1 parallel job means 1 pipeline execution containing 2 or more jobs? or only 2 jobs?
No. Each job will run on a new agent.
1 parallel job means that one job can run at a time. Two parallel jobs means that two parallel jobs can run at a time, each on a separate agent. And so on.

How to make and control of parallel execution of Azure DevOps Pipeline?

I am using Windows Self hosted agent for my Azure DevOps pipelines. Currently the pipelines are executed sequentially. If more than one pipelines triggered from different ADO projects, then it has to wait in queue to get the agent. In order to execute the pipeline in parallel, I came to know from some tutorials if we increase the paid parallel jobs for self hosted agent under billing section of Organization setting. Is my understanding correct? If so what are the precautionary steps I need to take. Do we have any control of when the pipelines to be executed in parallel?
Thanks.
In order to run self-hosted parallel jobs, you need to purchase parallel jobs and register several self-hosted agents.
For parallel jobs, you can register any number of self-hosted agents in your organization. If you want to run 3 jobs in parallel, then you must register at least 3 self-hosted agents in one agent pool. DevOps charges based on the number of jobs you want to run at a time, not the number of agents registered. There are no time limits on self-hosted jobs. For private projects, you can have one job and one additional job for each active Visual Studio Enterprise subscriber who is a member of your organization.
About how to purchase parallel jobs, please refer to Buy parallel jobs.
For how to control the use of parallel jobs, please refer to the following:
For classic pipeline, you can specify when to run the job through dependencies and Run this job in Additional options in the agent job. Then the pipeline will run in sequence according to your settings.
For YAML pipeline, you can specify the conditions under which the job should run with "dependsOn" and "condition".
For example:
For more info about conditions, please refer to Specify conditions
If you don't specify a specific order, the jobs will run in parallel based on the parallel jobs you purchased.
I don't know if my experience can help. I'll try. I started a new job and we use self-hosted TFS / Azure DevOps. I am changing our build process to create 3 product SKUs (it uses conditional compilation). Let's call them Good, Better & Best.
I edited the Build definition. First I switched to the Variables tab. I created a Process variable named SKUs and set it to Good,Better,Best. The commas are important.
Next I switched to the Tasks tab. I located the Agent Phase. Mine was called Phase 1. Select it. On the right, under Parallelism, I selected Multi-configuration. In the Multipliers text field I entered SKUs. I set Maximum number of agents to 3.
What I don't yet know is the TFS back-end administration and options that the company purchased beforehand.

How to run more than one pipeline parallelly in Azure DevOps for self hosted agent

I am having one windows self hosted agent for Azure DevOps pipeline. If we run two pipelines, one has to wait for the other to be completed. Is there any way to do parallelly run the pipelines by doing any configuration in agent?
Check this doc(Self-hosted agent):
For public projects that are self-hosted, you can have unlimited parallel jobs running. For private projects, you can have one job and one additional job for each active Visual Studio Enterprise subscriber who is a member of your organization.
Is there any way to do parallelly run the pipelines
If you are using public project, the number of parallel jobs is Unlimited, if you are using private, the default number of parallel job is one self-hosted job. We need to buy self-hosted parallel jobs, then we could run the pipeline in parallel.
In addition, we could open Organization Settings->Parallel jobs to check the number of parallel jobs, check the pic below:
Buy self-hosted parallel jobs steps:
Open Organization Settings->Billing->set up Billing and buy self-hosted parallel jobs. Check the pic below:
Result:
Note: we need to install another self-hosted agent and then we can run two pipelines at the same time.
Update1
Install another agent, we could install it in the same agent pool or create other agent pools and install the new agent.
Steps:
Open org settings->agent pool->open default agent pool and click the button New agent to download self-hosted agent zip.file->install another agent with the file and enter another agent name, click the pic below.
If you buy more parallel executions you can do that. All you need to do is install another azure devops agent service on the same box and register it.

Azure devops- Running the multiple release from single release defnition

I am trying to invoke the multiple releases definition using REST API.Also enabled multiple agents for each Agent job. But even after triggering multiple releases the second release is in Queue and not at all starting. Is there any way to start the deployment parallelly from a single release defition.
Parallel jobs have different restrictions depending on the agents you use and your project is public or private.
Microsoft-hosted agent
If your jobs run on the pool of Microsoft-hosted agents. Microsoft provides a free tier of service by default in every organization:
Public project: 10 free Microsoft-hosted parallel jobs that can run
for up to 360 minutes (6 hours) each time, with no overall time limit
per month.
Private project: One free job that can run for up to 60 minutes each
time, until you've used 1,800 minutes (30 hours) per month.
Note:When you purchase your first Microsoft-hosted parallel job, the number of parallel jobs you have in the organization is still 1. To be able to run two jobs concurrently, you will need to purchase two parallel jobs if you are currently on the free tier. The first purchase only removes the time limits on the first job.
Self-hosted agent
To use self-hosted parallel jobs, you need to deploy self-hosted agents on your machines. You can register any number of these self-hosted agents in your organization. Microsoft charges based on the number of jobs you want to run at a time, not the number of agents registered.
Public project: Unlimited parallel jobs.
Private project: One self-hosted parallel job. Additionally, for each
active Visual Studio Enterprise subscriber who is a member of your
organization, you get one additional self-hosted parallel job.
For private project,when the free tier is no longer sufficient, you can pay for additional capacity per parallel job. Buy self-hosted parallel jobs.There are no time limits on self-hosted jobs.
These are stated in the document, you can refer to the link in Daniel's comment for details.