【问题标题】:Pushing to Protected Github Branch from Azure DevOps pipeline从 Azure DevOps 管道推送到受保护的 Github 分支
【发布时间】:2020-09-23 21:57:31
【问题描述】:

我有一个 DevOps 管道,其任务是更新文件并将其提交回 Github 中的受保护分支。从回购中签出工作正常。我以为我设置了正确的权限,但它不起作用。

我已在此处允许 azure-pipelines 权限:

我已指定以下内容以保留原始结帐的身份验证:

steps:
- checkout: self
  persistCredentials: true  

- task: Bash@3
  inputs:
    targetType: inline
    script: |
      git checkout integration

然后在我做出更改之后,我想像这样推回集成分支:

- task: Bash@3
  inputs:
    targetType: inline
    script: |
      cd ./Test/Test.UWP
      git config --global user.email "test@test.com"
      git status
      cd ../..
      git add .
      git commit -m "Release $(versionNumber)"
      git push origin integration

这会返回以下输出,但不会将其推回integration 分支:

remote: error: GH006: Protected branch update failed for refs/heads/integration.        
remote: error: At least 1 approving review is required by reviewers with write access.        
To https://github.com/test/test-app
 ! [remote rejected] integration -> integration (protected branch hook declined)
error: failed to push some refs to 'https://github.com/test/test-app'

【问题讨论】:

标签: git github azure-devops devops


【解决方案1】:

解决方案是创建另一个帐户并从中生成具有管理员访问权限的 PAT。

然后我将应用程序克隆到代理上的单独目录中。修改了我需要的内容,并且能够使用 git bash 创建我的标签和所有内容。

【讨论】:

    【解决方案2】:

    您可以查看这种情况下的解决方案:Cannot push on github suddently

    您可以授予管理员对 azure-pipelines 的访问权限,或者转到设置 --> 分支以勾选 Allow force pushes (Permit force pushes for all users with push access) 以强制推送。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-04
      • 2020-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-27
      • 2021-11-23
      • 1970-01-01
      相关资源
      最近更新 更多