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
If @ team exists in the organization project , then perfect if @ team does not exist,print out this team does not exist in the project
So how do I know whether the team or Iteration already existed in Azure Devops Organization?
CodePudding user response:
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
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
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.
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.
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.