0

I created a pipeline in azure devops, added three tasks in order listed below:
1) Command line task
2) Powershell task
3) Command line task

task 1)

git config --global user.email "[email protected]"
git config --global user.name "xxxx"
cd $(Build.SourcesDirectory)
git init

task 2) Powershell task

task 3)

git add filename.csv
git commit -m "csv file update"
git remote rm origin
git remote add origin  https://[email protected]/OrgName/ProjectName/_git/RepoName
git push -u origin HEAD:master

I used this solution in a different subscription and there was no problem. I moved solution to second subscription and I am still facing issue: fatal: could not read Password for https://[email protected]/OrgName/ProjectName/_git/RepoName: terminal prompts disabled[error]Cmd.exe exited with code 128

I have configured the repo using this MS documentation Something is wrong with task 3). tasks 1) and task 2) completed successfully.

5
  • I moved solution to second subscription are you saying you put these pipeline tasks in a pipeline under a different organization? Commented Dec 4, 2019 at 17:22
  • Hi, Yes, put these pipeline tasks in a pipeline under a different organization, in previous organization there was no problem, after migration I am facing mentioned issues. Commented Dec 5, 2019 at 8:05
  • In the next organization, did you want it push the file to another organization? Does the org you want this git push to same with the current pipeline located? Commented Dec 6, 2019 at 10:30
  • Hi @Merlin Liang, I want to push file into repo located in the same organization. the same pipeline. Commented Dec 6, 2019 at 10:55
  • @tester81, That's odd to prompt this error message. Does below format could help for solve the error? Since the error said could not read password, I think attack the token in the command may meet the password requirement. Commented Dec 6, 2019 at 11:34

1 Answer 1

1

Please try with below push script, which attached the PAT token in the git command to authorized the operation:

git push https://{PAT}@dev.azure.com/{org name}/{project name}/_git/{repos name} master

Use this command and replace the original git remote add origin and git push.

UPDATE:

To make you more clear about how to apply it into the task, I reproduced it on my side.

Note: No changes are required to the original first Command line task and Powershell task, the below changes are only in the second Command line task:

git checkout $(Build.SourceBranchName)
git add .
git commit -m "aaaa"
git push https://{token}@dev.azure.com/{org name}/{project name}/_git/{repos} master

When we apply the token in the git command, the whole script need to be changed. Please replace above script all in the second Command line task.

Sign up to request clarification or add additional context in comments.

13 Comments

I updated the git code: git add filename.csv git commit -m "csv file update" git remote rm origin git remote add origin https://[email protected]/OrgName/ProjectName/_git/RepoName git push -u origin HEAD:master and I got error like: The following project does not exist: ProjectName. Verify that the name of the project is correct and that the project exists on the specified Azure DevOps Server. fatal: repository '[email protected]/OrgName/ProjectName/_git/RepoName' not found, I used this link and was able to open my repository.
@tester81, what's the result? Is any error prompt now?
As I mentioned, and I got error like: The following project does not exist: ProjectName. Verify that the name of the project is correct and that the project exists on the specified Azure DevOps Server. fatal: repository '[email protected]/OrgName/ProjectName/_git/RepoName' not found, I used this link and was able to open my repository.
@tester81. I wrote a completed script to execute the git push command with token. Please have a try then let me know is it work for you.(It succeed on my side)
Still facing an error, message remote: TFxxxx: The following project does not exist: ProjectName. Verify that the name of the project is correct and that the project exists on the specified Azure DevOps Server. I think something is wrong with the project name, My project name contains two words and a space between them, like "Word1 Word2", and in this line git push https://{token}@dev.azure.com/{org name}/{project name}/_git/{repos} master I am using projectname like "Word1%20Word2", and I can open the link in my browser, but GIT cant handle this I suppose.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.