【发布时间】:2019-01-28 14:08:09
【问题描述】:
我正在尝试通过使用 Azure Pipelines (yaml) 的 powershell 脚本中的 git 进行结帐。
当我在构建期间运行以下命令时,我的构建挂起..
- task: PowerShell@2
# ------------------------------------------------------
displayName: Update readme.txt
# ------------------------------------------------------
inputs:
targetType: filePath
filePath: '$(System.DefaultWorkingDirectory)\${{ parameters.devOpsArtifactName }}\update-changelog.ps1'
workingDirectory: '$(System.DefaultWorkingDirectory)\${{ parameters.devOpsArtifactName }}'
arguments: '-WorkingDirectory "$(System.DefaultWorkingDirectory)" -Version "$(buildNumber)" -BranchesToPush "develop" -GitRequestedForEmail "$(Build.QueuedById)" -GitRequestedFor "$(Build.QueuedBy)" -UpdateRepo'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
function Checkout([String]$branch, [String]$gitRequestedForEmail, [String]$gitRequestedFor)
{
Write-Host "Checking out $branch for $gitRequestedFor ($gitRequestedForEmail)."
git config --global credential.modalPrompt false
git config --global user.email $gitRequestedForEmail
git config --global user.name $gitRequestedFor
git fetch
git checkout $branch
}
编辑
抑制模式(如建议的那样)不起作用,最好我想使用 SYSTEM_ACCESSTOKEN 进行身份验证。
【问题讨论】:
-
不确定,但我想您可能有来自 Git 凭据管理器的模式对话框提示。您可以通过添加来抑制它:
git config --global credential.modalPrompt false -
可选地通过添加
set GIT_TERMINAL_PROMPT=0禁用Git中的所有交互式提示 -
排队构建时为什么不能在YAML或者参数中指定分支?
-
尝试在
fetch命令中输入用户名和密码:git fetch https://username:password@mygithost.com/my/repository -
谢谢,我明天试试,看看效果如何。我需要检查、更新变更日志并推送到 PR 源分支并进行开发。
标签: azure azure-devops azure-pipelines azure-pipelines-build-task