我是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"
但是我收到此错误,无法在回购中推送文件:
fatal: could not read Password for 'https://<username>@dev.azure.com': terminal prompts disabled
我想念明显的东西吗?我应该如何使用PAT /密码进行身份验证?
答案 0 :(得分:-1)
不建议将工件存储在Git中!
但是如果您必须这样做并且希望push
可以工作,那么请在git push
行中输入用户名和密码:
git push https://username:password@azure-devops.com/repo.git master
在azure-devops.com/repo.git
中放入仓库网址(代替origin
)。
您还可以通过以下方式使用PAT(而不是用户名和密码):
git push https://Personal%20Access%20Token:{TokenHere}@azure-devops.com/repo.git master