0

Azure Devops -----Can someone write a function that can Verify a team in the organization exists or not by querying the team name--Return true for existing, Return false for not existing (Bash, or AzureCLI)

AzureOrganization="https://dev.azure.com/ExampleOrganization"
AzureProject="ExampleProject"
az devops configure -d organization= $AzureOrganization project=$AzureProject

Azure Devops -----Can someone also write a function that can Verify an iteration in the organization exists or not by querying the iteration name or iteration path--Return true for existing, Return false for not existing (Bash, or AzureCLI)

kitten
  • 31
  • 5

1 Answers1

-1

Edit I now see this question is a duplicate by the same user. Original question: Azure Devops-How to verify whether team has exists in an organization (Azure CLI or Azure Bash)

Verify if a team exists

(az devops team list --project "ExampleProject" --query "[?name=='ExampleTeamName']").Count -gt 0

Verify if an iteration exists

I'm not sure if you want to check the entire Azure DevOps Organization for an Iteration or just a Team Project, but here is a script you can use for a Team Project. I set the depth of the search to 10, but it's up to you to alter the value according to your needs (it's the depth in the Iteration tree structure). You'll have to replace ExampleProject, IterationName and IterationPath by your own.

Search by name:

(az boards iteration project list --depth 10 --project "ExampleProject" --query "children[?name=='IterationName']").Count -gt 0

Search by path:

(az boards iteration project list --depth 10 --project "ExampleProject" --query "children[?path=='IterationPath']").Count -gt 0
Fokko
  • 188
  • 1
  • 14
  • (az boards iteration project list --depth 10 --project "ExampleProject" --query "children[?name=='IterationName']").Count -gt 0 Thanks so much Fokko, is this one will return json file? how can i store this return result in a variable so that I can see if it has something printout exist, if it returns somethingelse, print false. Thanks – kitten Sep 30 '21 at 23:14
  • I tried it seems not working – kitten Oct 01 '21 at 00:31
  • The code you quote returns true or false based on the input, just as you requested in your question. You can store it in a variable by using it like this: $var = ((az boards iteration project list --depth 10 --project "ExampleProject" --query "children[?name=='IterationName']").Count -gt 0). – Fokko Oct 01 '21 at 07:18