-2

The problem we have is that we want to check over 1000 repos in our Azure DevOps whether they are using a specific task. We need this for a tracking metric to measure how much coverage we have. I am thinking of a pseudocode to get this working.

  1. Use Azure DevOps REST API -> Get /_apis/git/repositories -> Find all yml file -> See if it includes this task name
  2. Use Azure DevOps REST API -> Get /_apis/projects -> Get pipeline_id for latest project for each build -> Get the latest build for each project -> see if it has the task name

Is there a recommended way to do this?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Anderson
  • 404
  • 1
  • 7
  • 16
  • 2
    If you're trying to enforce usage of a specific task, use pipeline decorators. https://learn.microsoft.com/en-us/azure/devops/extend/develop/add-pipeline-decorator?view=azure-devops – Daniel Mann Dec 17 '22 at 06:34
  • If the answer helps, just a remind of [accept an answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235). Thanks for your kindness :-) – Evelyn Chen-MSFT Dec 21 '22 at 08:00

1 Answers1

1

Currently we do not have any built-in method to monitor whether a pipeline task is being used by every pipeline.

The only way is manual check. Here're some methods that may help.

You can use the following API to get the yaml definition you are using, set the logId to 1:

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/logs/{logId}?api-version=6.0

You can check this ticket for more information: https://stackoverflow.com/a/73242365/18846798.

But it only works when you are using yaml pipeline and if you are using classic pipeline, it won't work.

For classic pipelines, you may try this extension: Build Task Explorer.

For your reference, you can check this ticket: https://stackoverflow.com/a/71262581/18846798 for more details.