gpt4 book ai didi

git - 在成功构建 Jenkins 后,如何将更改从一个分支推送到另一个分支?

转载 作者:太空狗 更新时间:2023-10-29 14:38:16 24 4
gpt4 key购买 nike

在成功构建 Jenkins 后,如何将更改从一个分支推送到另一个分支?假设我有一个名为“beta”的分支,我要提交给另一个名为“master”的分支,我想包含对 beta 的所有成功提交。

最佳答案

来自底部链接中可用的 Jenkins 插件的高级功能部分:

Set up your Jenkins project, and leave the 'branch' field in the Git SCM blank. This will cause Jenkins to consider any change on any branch for building.

Next, pick a particular branch name as the integration target in the 'Advanced' section - (e.g. 'master', or 'stable'), and select 'Merge before build'.

Select 'Push GIT tags back to origin repository' from the post-build actions (this is required to update your centralised git repo with the results of the build).

Now, developers should never commit directly to your integration branch (the 'master' or 'stable'). Instead, they should either use feature branches, or create new remote branches on commit (e.g : "git push origin HEAD:refs/heads/myNewFeature"). You could also set up your GIT repository to only accept commits onto the integration branch from Jenkins.

You're done. Commits should now be automatically merged with the integration branch (they will fail if they do not merge cleanly), and built. If the build succeeds, the result of the merge will be pushed back to the remote git repository.

根据我对插件的经验做了一些阐述:

  1. 我选择在我的原始存储库中创建一个名为“beta”的分支。另外,我决定只在这个分支更新时构建,所以我将“Branches to build”字段设置为“*/beta”。

  2. 我不得不“添加一个额外的行为”,即“在构建之前 merge ”——它不仅仅是坐在那里供我选择。这部分我的存储库名称是“origin”,要 merge 到的分支是“master”。

  3. 我还选择了“Git Publisher”的构建后操作。为此,我选中了“仅在构建成功时推送”和“merge 结果”框。我还在 Branch to push box 中写了“master”,在目标远程名称中写了“origin”。

https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin

关于git - 在成功构建 Jenkins 后,如何将更改从一个分支推送到另一个分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25679691/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com