Calling a job from another job in Azure Devops pipeline - azure-devops

Hey Azure Devops experts,
Do you have any advise how can we call a job from another job in Azure Devops pipeline?
I have already explored and spent time in resources pipeline, however with this another pipeline gets triggered after the completion of first pipeline.
What i want to do is from one job task i may call another job with certain parameters in a loop. So first job will have a loop which will call another job

No, that's not possible.
When the pipeline is compiled, this works out all the stages and jobs to be run, and that structure is then fixed for the run; by the time your pipeline is running, it's not possible to add extra jobs.

Related

Running azure pipelines after 15days of the trigger

My requirement is, i have to run azure pipeline after 15days of the trigger. I have 2 pipelines where first pipeline will execute and after that pipeline is started, the second pipeline should trigger after 15days only. How can i do that? Can we tweak cron to do this?
I tried using cron but there is no way to set this up.
There is no out-of-the-box type of trigger to achieve it according to Microsoft document at present.
But you can make the job depends on an agentless job that includes delay task to pause execution of the pipeline for a fixed delay time. Please refer to doc:Delay task
for example:
1 add a delay task in an agentless job and configure delay time 21600 minutes(15 days)
2 make the job depend on agentless job
3 set build trigger
Note :set build job timeout to 0

Is it possible to make the pass/fail status of an Azure pipeline dependent of the pass/fail status of a downstream pipeline?

I'm currently migrating code from Gitlab to Azure DevOps and Azure Pipelines. In Gitlab I have a two repo setup like this:
Pipeline A in repo 1 runs build & UTs. It triggers:
Pipeline B in repo 2 runs solution tests. If it passes:
Pipeline A publishes artifacts
You can do this in Gitlab using a depend strategy in your trigger job. This means that if Pipeline B fails, Pipeline A also fails, and so the publishing stage in Pipeline A is skipped.
Am I right in thinking that this setup is not natively supported in Azure Pipelines, e.g. with pipeline completion triggers? I don't think you can have one pipeline pausing half way through and waiting for another, or have the upstream pipeline's pass/fail status mirror that of the downstream pipeline.
If so, what do you think would be a good solution here? Is it possible to gate PR Build Validation on the downstream pipeline, so if pipeline A passed on repo 1's branch X but pipeline B failed, Azure wouldn't let me merge branch X?
I've had a couple of ideas for hacky workarounds if this isn't supported:
Write a script in pipeline A that kicks off pipeline B, sleeps and periodically polls the API to check whether pipeline B has
passed/failed
Checkout repo 2's code during pipeline A, and run the solution tests there
Do either of them sound sensible?
Is it possible to make the pass/fail status of an Azure pipeline
dependent of the pass/fail status of a downstream pipeline?
There is no such out of box way to achieve this at this moment.
Personally, your ideas are sound. I have encountered similar requests before, but it was about release, but the concept of their implementation is the same.
The main idea is:
Add a powershell task to Pipeline A to call the REST API to queue pipeline B, 2. Cyclically monitor the construction results of pipeline B.
After getting the result of pipeline B, call the log command according to the result of pipeline B.
To set the construction result of pipeline A.
You could checkmy previous thread for some more details:
Is it possible to run a "final stage" in Azure Pipelines without knowing how many stages there are in total?
And the log command set the build result:
##vso[task.complete result=Failed;]DONE

How to run scheduled Azure DevOps pipeline with two different agents pools

I have Azure DevOps pipeline and I want to run it nightly run with two different agent pool, one dev and one prod.
This is the pipeline with default dev agent pool:
In the schedule setting there is no option to set different agent pool to the runs:
I saw this answer (solution with yaml settings), but I didn't found a way to use it in my pipeline (my pipeline defined in Azure DevOps UI settings).
As you use GUI classic pipelines you could define two different jobs that will run on different agent pools. This way you could have a single pipeline that you will run depending on your schedule.
When using YAML syntax you could define different stages to accomplish the same result.
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/stages?view=azure-devops&tabs=yaml
Create a new Stage. The first stage's job will use one pool and the second stage will use a different pool. They can then be scheduled or triggered independently. You can also clone the first stage to save you the time of duplicating the tasks.
Reference

How to run multiple Copy Files task in a Azure DevOps Release pipeline simultaneously with Custom Conditions?

I am using Azure DevOps Server 2020 and I have a release pipeline which has around 21 copy file tasks in it to copy the output of multiple microservices to different target paths and this takes almost around 23 mins to complete the release pipeline.
I want to optimize the release pipeline and save some time and thus I am thinking of running all the copy task simultaneously.
Under the copy tasks in Control Options section, I see Run this task option is available where we do have the option to define custom conditions but I am not sure which custom conditions do I need to define exactly so that all my copy tasks gets executed parallelly.
Could anyone please let me know what custom conditions will allow all the copy task to get executed in one go?
Currently it is not possible to have tasks run in parallel. It has been raised as a suggestion here but the feature hasn't been implemented
How to run multiple Copy Files task in a Azure DevOps Release pipeline simultaneously with Custom Conditions?
Just as TheWinterCoder pointed, Currently it is not possible to have tasks run in parallel.
But, as a workaround, you could divide the replication task into several different jobs and make the jobs run in parallel:
This requires you to have multiple agents available in the local agent pool:

API to Get All Tasks to be Executed in the Azure DevOps Pipeline

Is there a way of getting the order of all tasks running in a build pipeline. As we are building a pipeline decorator, we want to know if there is a way to check if the pipeline has specific tasks. We tried using the timeline api but it will only display all jobs and tasks that have been executed or currently executing. As we are executing the pipeline decorator at the start, we want to get all tasks to be executed in the pipeline.
There isn't such an API to get all tasks to be executed (including the decorator ones) directly in Azure DevOps Pipeline.
However we can get the order of all tasks running from the logs of a build pipeline by calling the Get Build Logs REST API, and then calling the Get Build Log REST API to get the specific task log to get the specific task name. It will also include the auto-injected decorator tasks.
But it has the reverse order from the response. For example,in below screenshot the task showed in log1 is the last task running in the pipeline.