使用powershell的Azure DevOps git签出

使用powershell的Azure DevOps git签出,azure,azure-devops,azure-pipelines,azure-pipelines-build-task,Azure,Azure Devops,Azure Pipelines,Azure Pipelines Build Task,我正在尝试从使用Azure管道(yaml)的powershell脚本中使用git进行签出。 当我在构建过程中运行以下命令时,我的构建将挂起 - task: PowerShell@2 # ------------------------------------------------------ displayName: Update readme.txt # ------------------------------------------------------

我正在尝试从使用Azure管道(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)
编辑
抑制模式(如建议的)不起作用,我最好使用SYSTEM_ACCESSTOKEN进行身份验证。

使用此(内联)脚本进行测试,并使其工作:

$url = "$(Build.Repository.Uri)".Replace("https://", "")
$url = "https://$env:SYSTEM_ACCESSTOKEN@$url"

Write-Host "Checking out $branch from $url for $gitRequestedFor ($gitRequestedForEmail)."

git fetch $url
git checkout develop
git log --oneline

不确定,但我想您可能有一个来自Git凭证管理器的模式对话框提示。通过添加:
git config--global credential.modalPrompt false
可以通过添加
set git_TERMINAL_PROMPT=0
禁用git中的所有交互提示。为什么在对生成进行排队时不能在YAML或参数中指定分支?尝试将用户名和密码放入
fetch
命令:
git fetchhttps://username:password@mygithost.com/my/repository
谢谢,我明天会试试,看看有什么效果。。我需要结帐,更新变更日志,并推到公关来源分支机构和发展。你能提供你的完整YAML吗?我正在努力使用内联脚本您可以使用
powershell:
进行内联脚本,
$url = "$(Build.Repository.Uri)".Replace("https://", "")
$url = "https://$env:SYSTEM_ACCESSTOKEN@$url"

Write-Host "Checking out $branch from $url for $gitRequestedFor ($gitRequestedForEmail)."

git fetch $url
git checkout develop
git log --oneline