Describe the bug
When running az cli devops commands from an ADO git folder the az cli devops defaults are ignored.
To Reproduce
Azure Cli Version:
2.0.73
Azure-Devops extension version:
0.13.0
Steps to reproduce the behaviour:
az devops loginand provide a token (my token has all the scopes)az devops configure --defaults organization=https://dev.azure.com/contoso project=ContosoWebAppaz pipelines pool listERROR:
The requested resource requires user authentication: https://@dev.azure.com//azure%20platform%20team/_git/azure%20platform%20team/vsts/info
Note: the * is just to keep my stuff private.
Expected behavior
The normal run of the command
Additional context
@olandese This is the expected behavior today. You can use the detect flag to set avoid this behavior by setting it to false.
--detect false
Reason: In most cases when a user is running a command from within a git repo the intention is that commands are targeted at the same organization and project to which this repo belongs.
The defaults work anywhere when the command is invoked from outside a ADO git repo.
This has been in place since the initial release itself. In most cases these two things help users who are using the CLI for interactive purposes.
For automation use cases it is always suggested to explicitly use --organization -- project parameters to have consistent behavior of automation scripts.
So the order of detection is -
Please let know if that helps. I will be closing the issue.
@olandese This is the expected behavior today. You can use the detect flag to set avoid this behavior by setting it to false.
--detect falseReason: In most cases when a user is running a command from within a git repo the intention is that commands are targeted at the same organization and project to which this repo belongs.
The defaults work anywhere when the command is invoked from outside a ADO git repo.This has been in place since the initial release itself. In most cases these two things help users who are using the CLI for interactive purposes.
For automation use cases it is always suggested to explicitly use --organization -- project parameters to have consistent behavior of automation scripts.
So the order of detection is -
- Explicit params --org --project
- Detect from local repo (if --detect is on, which is by default)
- Use defaults
Please let know if that helps. I will be closing the issue.
Thank you for the good explanation!
I think this flow order should be better documented :)
@geverghe Please see if some documentation change is needed.
Hey @olandese - thank you for raising the documentation concern. To ensure we meet your expectation and prioritize accordingly, could you tell me how you learnt about the command functioning? From docs.microsoft.com or from the command help text?
I learned from both.
But I would expect the flow described above by @atbagga somewhere in the Getting started documentation ( https://docs.microsoft.com/en-us/azure/devops/cli/get-started?view=azure-devops )
Got it - thanks for the confirmation. 馃憤
Hey @olandese - I have included the documentation here - https://docs.microsoft.com/en-us/azure/devops/cli/auto-detect-and-git-aliases?view=azure-devops#parameter-hierarchy. This is the portion where we explain about auto detect concept and thought it would be the best place to include the details pertaining to parameter priority as well. I am closing this issue.
Great work! thank you for listening :)
@geverghe could you also add the note to the Getting Started Guide. This was where I first learned about setting default config
@geverghe I ran into the same issue and also used the Getting started guide @mydiemho did, so I second their suggestion.