bash - Azure Devops-如何验证组织中是否存在团队(Azure CLI 或 Azure Bash)
问题描述
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
如果组织项目中存在@迭代,则完美如果不存在@迭代,则打印出该迭代在项目中不存在
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
语句可能因外壳而异(我使用)zsh
,因此如果这不起作用,您可能需要查看您正在使用的外壳的文档。
推荐阅读
- git - Cloud Source Repositories - Git 将代码推送到默认分支或切换分支
- java - Java 列表 - IndexOutOfBounds 异常错误
- google-sheets - 与多个标准(和范围数字)的索引匹配
- javascript - 访问插入多个数组中的任何字符串类型元素
- tableau-api - 所有数据元素在画面中都不可见
- javascript - 将 Spartacus 与后端公共实例连接起来
- html - 由于路径太长,使用 Ruby-sass 进行编译太长而无法输入
- sql-server - 回滚然后从队列中接收相同的消息
- kubernetes - 如何通过命令行或脚本验证证书
- python - 我应该使用熊猫字典吗?如何?