Azure Devops-如何验证组织中是否存在团队(Azure CLI 或 Azure Bash) [英] Azure Devops-How to verify whether team has exists in an organization (Azure CLI or Azure Bash)

查看:17
本文介绍了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 

如果组织项目中存在@迭代,则完美如果@迭代不存在,则打印出项目中不存在此迭代

If @ iteration exists in the organization project , then perfect if @ iteration does not exist, print out this iteration does not exist in the project

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

如果@team存在于组织项目中,则完美如果@team不存在,打印出项目中不存在这个团队

If @ team exists in the organization project , then perfect if @ team does not exist,print out this team does not exist in the project

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

So how do I know whether the team or Iteration already existed in Azure Devops Organization?

推荐答案

判断一个团队是否存在,可以使用

To determine if a team exists, you can use

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,否则不会.

if the team exists, $team will have JSON in it, otherwise not.

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

To determine if an iteration exists, you can use

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,否则不存在.

Look at your project iteration structure for how to structure the query to the path. My iteration tree is 4 levels deep. Yours may not be. If the iteration exists, $iteration will have JSON in it, otherwise not.

当迭代或团队不存在时,2>/dev/null 会抑制来自 CLI 的 stderr 输出.--only-show-errors 不会抑制这一点.

The 2>/dev/null suppresses the stderr output from the CLI when the iteration or team does not exist. --only-show-errors does not suppress this.

if 语句可能因外壳而异(我使用 zsh),因此如果这不起作用,您可能需要查看您的外壳的文档重新使用.

The if statements may vary from shell to shell (I use zsh), so if this does not work you may need to look at documentation for the shell you're using.

这篇关于Azure Devops-如何验证组织中是否存在团队(Azure CLI 或 Azure Bash)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆