【问题标题】:Azure Devops -----Verify a team exists or not by querying the team name--Return true for existing, Return false for not existing (Bash, or AzureCLI) [duplicate]Azure Devops -----通过查询团队名称验证团队是否存在--存在返回true,不存在返回false(Bash,或AzureCLI) [重复]
【发布时间】:2021-09-30 04:29:09
【问题描述】:

Azure Devops -----有人可以写一个函数,通过查询团队名称来验证组织中的团队是否存在--存在返回true,不存在返回false(Bash,或AzureCLI)

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

Azure Devops -----有人也可以写一个函数,可以通过查询迭代名称或迭代路径来验证组织中的迭代是否存在--存在返回true,不存在返回false(Bash,或 AzureCLI)

【问题讨论】:

    标签: azure-devops azure-functions azure-cli


    【解决方案1】:

    编辑我现在看到这个问题是同一用户重复的。原题:Azure Devops-How to verify whether team has exists in an organization (Azure CLI or Azure Bash)

    验证是否存在团队

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

    验证是否存在迭代

    我不确定您是要检查整个 Azure DevOps 组织的迭代还是只检查团队项目,但这里有一个可用于团队项目的脚本。我将搜索的深度设置为 10,但您可以根据需要更改该值(这是迭代树结构中的深度)。您必须自己替换 ExampleProjectIterationNameIterationPath

    按名称搜索:

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

    按路径搜索:

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

    【讨论】:

    • (az board 迭代项目列表 --depth 10 --project "ExampleProject" --query "children[?name=='IterationName']").Count -gt 0 非常感谢 Fokko,这个会返回json文件吗?如何将此返回结果存储在一个变量中,以便我可以查看它是否存在打印输出,如果它返回其他内容,则打印 false。谢谢
    • 我试过了好像不行
    • 您引用的代码根据输入返回真或假,正如您在问题中所要求的那样。您可以像这样使用它来将它存储在一个变量中: $var = ((az board iteration project list --depth 10 --project "ExampleProject" --query "children[?name=='IterationName']").计数 -gt 0)。
    猜你喜欢
    • 2021-11-21
    • 2013-11-23
    • 1970-01-01
    • 2021-02-23
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    • 2020-07-10
    • 2020-10-16
    相关资源
    最近更新 更多