Azure / azure-devops-cli-extension

Azure DevOps Extension for Azure CLI
https://docs.microsoft.com/en-us/cli/azure/ext/azure-devops/?view=azure-cli-latest
MIT License
634 stars 242 forks source link

No option to pass or configure the source import repo user PAT token or password and or use SSH key #1050

Open vairakkumaar-svs-hf opened 4 years ago

vairakkumaar-svs-hf commented 4 years ago

No option to pass or configure the source import repo user PAT token or password and or use SSH key https://github.com/Azure/azure-devops-cli-extension/blame/master/tests/test_reposImportTest.py

To Reproduce Azure Cli Version: 2.11.1 Use az --version Look for something like- azure-cli (2.0.70)

Azure-Devops extension version: 0.18.0 Use az --version Look for something like- Extensions: azure-devops (0.18.0)

Steps to reproduce the behavior:

  1. login using az login

  2. set subscription to which devops org is created from

  3. az repos import create --git-source-url <url>  --org https://dev.azure.com/orgname/  --project projname --repository  reponame --requires-authorization --user-name username
  4. prompted to enter PAT twice

  5. See error

TF401019: The Git repository with name or identifier reponame does not exist or you do not have permissions for the operation you are attempting.

Expected behavior Importing and successfully imported

  1. az repos import create --git-source-url <url>  --org https://dev.azure.com/orgname/  --project projname --repository  reponame --requires-authorization --user-name username:PATtoken
  2. See Git password /PAT:

Expected behavior Importing and successfully imported

syedadeel2 commented 3 years ago

@vairakkumar-vairaperumal you can set the environment variable AZURE_DEVOPS_EXT_GIT_SOURCE_PASSWORD_OR_PAT and it will work. I was facing the same issue, but after a lot of research, I found that setting env var called AZURE_DEVOPS_EXT_GIT_SOURCE_PASSWORD_OR_PAT it will work without any prompt.

I wrote the script in PowerShell to import from bitbucket to azure, and for every repo, it prompts me for a password so above helped me a lot now my script runs smoothly with no password prompting because I have stored my password to Env variable.

I hope that helps you, But I agree AZ CLI should have the option to take the password as input.

erradimourad commented 3 years ago

If we need to import a code from the other GIT Repos, you will need to create the target repos first with az repos create, after that use the az repos import create to inport your repos to the newly created repo .

az repos create --name $ReposName az repos import create --project $targetProjectName --git-source-url $Primary_ReposUrl --repository $ReposName

jubr commented 6 months ago

Perhaps someone with sufficient 🐮 powers can add AZURE_DEVOPS_EXT_GIT_SOURCE_PASSWORD_OR_PAT to the docs for az repos import create?

I just "got lucky" in stumbling upon this issue... tnx!