gpt4 book ai didi

bash - Azure Devops-如何验证组织中是否存在团队(Azure CLI 或 Azure Bash)

转载 作者:行者123 更新时间:2023-12-03 02:20:09 25 4
gpt4 key购买 nike

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

read-r-p "Enter name of iteration" iteration
echo @ iterationname

如果@iteration存在于组织项目中,那么完美如果@iteration不存在,则打印出本次迭代在项目中不存在

read-r-p "Enter name of team in the organization that you want to link in the iteration " team
echo @ team

如果@team存在于组织项目中,那就完美了如果@team不存在,则打印出该团队在项目中不存在

那么我如何知道 Azure DevOps 组织中是否已存在团队或迭代?

最佳答案

要确定团队是否存在,您可以使用

team=`az devops team show --team myTeamName 2>/dev/null`

if [ "$team" = "" ]; then
echo "Team does not exist"
else
echo "Team exists"
fi

如果团队存在,$team 中将包含 JSON,否则不会。

要确定迭代是否存在,您可以使用

iteration=`az boards iteration project list --path "\\ProjectRoot\\Path\\To\\Your\\Iteration" 2>/dev/null`

if [ "$iteration" = "" ]; then
echo "Iteration does not exist"
else
echo "Iteration exists"
fi

查看您的项目迭代结构,了解如何构建路径查询。我的迭代树有 4 层深。你的可能不是。如果迭代存在,$iteration 将包含 JSON,否则不包含。

当迭代或团队不存在时,2>/dev/null 会抑制 CLI 的 stderr 输出。 --only-show-errors 不会抑制此操作。

if 语句可能因 shell 不同而有所不同(我使用 zsh),因此如果这不起作用,您可能需要查看您所使用的 shell 的文档正在使用。

关于bash - Azure Devops-如何验证组织中是否存在团队(Azure CLI 或 Azure Bash),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69383647/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com