"az extension add" hangs in azure devops CI pipelines when the PAT token for a pip source is revoked.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Describe the bug**
**Scenario:**
We are building extensions for azure cli.
We install the extension in our CI pipeline for testing.
To install some internal packages, we use a **pip connection** with a PAT token to enable extra index urls.
**Problem:**
When the PAT token of the pip connection is revoked (it could be auto revoked at some time.) The "az extension add" command will hang when running the pip install command.
See the log:
> DEBUG: cli.azure.cli.core.extension.operations: Running: ['C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI2\\python.exe', '-m', 'pip', 'install', '--target', 'C:\\Program Files\\Common Files\\AzureCliExtensionDirectory\\xxx', 'C:\\Users\\VSSADM~1\\AppData\\Local\\Temp\\tmph4df1miu\\xxx-py3-none-any.whl', '--extra-index-url', 'https://xxxx', '-vv', '--disable-pip-version-check', '--no-cache-dir']
##[error]The operation was canceled.
While if I directly use "pip install" to install the same thing, only a warning "Credentials not correct for https://xxx" is printed, the installation still works.
**To Reproduce**
1. Create a pip feed in devops, see [this reference](https://docs.microsoft.com/en-us/azure/devops/artifacts/quickstarts/python-packages?view=azure-devops)
2. Create a pip connection in the devops project with a PAT token;
3. Add a pipeline to the devops project with a pip authentication step and an az extension add step;
```yaml
steps:
- task: PipAuthenticate@1
inputs:
pythonDownloadServiceConnections: xxxx
onlyAddExtraIndex: True
- task: AzureCLI@2
inputs:
azureSubscription: xxxx
scriptLocation: inlineScript
scriptType: pscore
inlineScript: |
cd $(Build.SourcesDirectory)
az extension add xxxxx
workingDirectory: $(DIRECTORY)
```
4. Revoke the PAT token;
5. Trigger the pipeline;
**Expected behavior**
No hanging, either failing fast or ignoring the unauthorized index are acceptable.
**Environment summary**
AzureCLI@2 task in azure pipelines
Contributor guide
Assessment
This issue has not been assessed yet.