git - 在 Azure .yml 管道中使用 git 命令自动 merge

标签 git azure azure-devops azure-pipelines automerge

我需要在部署完成后通过 azure 管道自动 merge 。
例如:我有一个分支 - 'release/1.0.0' 用于部署,部署后该分支需要自动 merge 到主分支中,无需任何 pull 请求。

我正在使用 bash 任务来执行 git 命令,如下所示:

- ${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/release/') }}:
  - task: Bash@3
    displayName: "Auto merge release"
    name: "Auto_merge"
    inputs:
      targetType: "inline"
      script: |
        git config --global user.name "AzureDevOps Agent"
        git config --global user.email "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84fdebf1c4e1fce5e9f4e8e1aae7ebe9" rel="noreferrer noopener nofollow">[email protected]</a>" 
        git checkout origin/main
        git fetch
        git merge --ff $(Build.SourceBranchName)
        git push origin

这是 azure 管道中的错误:

error in azure pipeline

你能帮我解决这个问题吗?

注意:我不想创建任何 pull 请求来处理自动 merge ,只是不想让 ADO 中的 pull 请求变得困惑。
我想通过 git merge 来实现这一点,而不需要任何 pull 请求

最佳答案

关于 git merge,有一个option --ff ,但不是 -ff

With --ff, when possible resolve the merge as a fast-forward (only update the branch pointer to match the merged branch; do not create a merge commit). When not possible (when the merged-in history is not a descendant of the current history), create a merge commit.

确保使用正确的语法。

关于git - 在 Azure .yml 管道中使用 git 命令自动 merge ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74697562/

相关文章:

git - 获取访问控制的分支 ID

git - 从远程 git 仓库中获取特定的提交

c# - Azure消息队列中的消息将直接进入Poison消息队列

azure - 阻止 Spark HiveContext 连接到 Hive

Azure Devops Bash 显示错误的文件路径,但脚本 'ls' 显示它是正确的

azure - 向市场添加了新的 VSTS 扩展,能够安装该扩展但未显示在 azure pipeline 任务中

ruby-on-rails - 我应该在Heroku上部署Ruby on Rails应用程序吗

c# - 如何使用 LibGit2Sharp 库检查远程存储库上的凭据是否有效

azure - 我们可以在 Azure 数据资源管理器中使用相同的数据连接将数据提取到不同的表中吗?

ios - 检查 secret 文件是否存在