问题描述
我在 azure 构建管道中配置了 powershell 任务,以将来自 dev 的更改合并到我的 github 公共存储库的 master 中,并将更改推送到 master.我得到了
I have powershell task configured in azure build pipelines to merge changes from dev into master of my github public repo and push changes to master. I am getting
致命:无法读取https://github.com"的用户名:终端提示已禁用
注意:
- 我已经用我的用户名和 emailid 配置了我的 gitconfig.
- 当我对文件进行修改并进行提交和推送时,git push 工作正常,但是当我进行合并和推送时,它会抛出此错误
- 我有足够的权限推送分支
对此的任何帮助将不胜感激.如果需要更多信息,请在此线程中发表评论.
Any help on this would be much appreciated. In case of more information needed, comment in this thread.
这是实际的片段.
$branchName = $env:BRANCH_NAME;
Write-Host "Getting SHA for last commit in the latest release" -ForegroundColor Blue;
$latestReleaseCommitSHA = git rev-list --tags --max-count=1;
if([string]::IsNullOrEmpty($latestReleaseCommitSHA)) {
Write-Host "Unable to get the SHA for last commit in latest release" -ForegroundColor Red;
EXIT 1;
}
Write-Host "SHA for last commit in the latest release is '$($latestReleaseCommitSHA)'" -ForegroundColor Green;
Write-Host "Merging Changes till '$($latestReleaseCommitSHA)'" -ForegroundColor Blue;
git merge $latestReleaseCommitSHA
Write-Host "Checking Conflicted Files";
$conflictedFiles = git diff --name-only --diff-filter=U
if (-Not [string]::IsNullOrEmpty($conflictedFiles)) {
Write-Host "Unable to Merge" -ForegroundColor Red;
Write-Host "There are conflicts in below files:" -ForegroundColor Cyan;
Write-Host -Object $conflictedFiles -ForegroundColor Cyan;
EXIT 1;
}
Write-Host "Merged changes to '$($branchName)'" -ForegroundColor Green;
Write-Host "Pushing changes." -ForegroundColor Blue;
git push origin HEAD:$branchName
Write-Host "Pushed the changes to the $($branchName) branch." -ForegroundColor Green;
推荐答案
我不知道为什么但是当你在 merge
之后尝试 push
git 想要用户名 &密码.
I don't why but when you try push
after merge
git want the username & password.
默认情况下,Azure DevOps 会禁用输入凭据的提示,您会收到错误消息.
Azure DevOps by default disable the prompt to enter the credentials and you got the error.
您可以通过将环境变量 GIT_TERMINAL_PROMPT
设置为 1
来启用提示,但在构建期间您无法输入值,构建将挂起.
You can enable the prompt by set the environment variable GIT_TERMINAL_PROMPT
to 1
but during the build you can't enter the values and the build will hang.
要修复错误,只需添加用户名 &git push
命令中的密码或个人访问令牌 (PAT):
To fix the error, just add the username & password or the Personal Access Token (PAT) in the git push
command:
git push https://username:password(or PAT)@github.com/username/reponame.git
https://...
替换 origin
.
这篇关于Azure Pipelines:我要命了:无法读取“https://github.com"的用户名:终端提示已禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!