我是 Azure DevOps 的新手,正在学习并希望将文件从构建工件目录推送到 git 存储库。我正在使用此内联 PowerShell 脚本来执行此操作:
Write-Host "Hello World"
write-host " Staging directory "$(build.artifactstagingdirectory)
git config --global user.email <useremail>
git config --global user.name <username>
git status
$CurrentPath = Get-Location
write-host "current path" $CurrentPath
$PackagePath =new-item -type directory $(get-date -f MM-dd-yyyy_HH_mm_ss)
$PackageZipPath = "$(build.artifactstagingdirectory)\<artifact to be copied>"
Copy-Item $PackageZipPath -Destination $PackagePath
git add .
git commit -m "Adding file"
git push origin master
git status
write-host "Package Uploaded to GitHub"
但是我收到此错误并且无法在 repo 中推送文件:
fatal: could not read Password for 'https://<username>@dev.azure.com': terminal prompts disabled
我错过了明显的吗?我应该如何使用 PAT/密码进行身份验证?
不建议在 Git 中存储工件!
但是如果你必须这样做并且你想要它push
会起作用,那么git push
在行中输入用户名和密码:
git push https://username:[email protected]/repo.git master
在azure-devops.com/repo.git
放入 repo url(它替换origin
)。
您还可以通过这种方式使用 PAT(而不是用户名和密码):
git push https://Personal%20Access%20Token:{TokenHere}@azure-devops.com/repo.git master
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句