簡體   English   中英

Azure Devops-如何驗證組織中是否存在團隊(Azure CLI或Azure Bash)

[英]Azure Devops-How to verify whether team has exists in an organization (Azure CLI or 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 

如果@iteration在組織項目中存在,那么perfect if@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不存在,打印出這個team在項目中不存在

那么如何知道Azure Devops組織中是否已經存在該團隊或Iteration呢?

要確定一個團隊是否存在,您可以使用

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 output。 --only-show-errors不會抑制這一點。

if語句可能從 shell 到 shell 不等(我使用zsh ),所以如果這不起作用,您可能需要查看您正在使用的 shell 的文檔。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM