简体   繁体   English

Jenkins-如何合并两个 git 分支,然后构建合并后的分支

[英]Jenkins- How to merge two git branch and then build the merged branch

In Jenkins how to merge two git branches as provided in the field:在 Jenkins 如何合并两个 git 分支,如字段中提供的:

branch_names to build: branch_name1, branch_name2要构建的 branch_names: branch_name1, branch_name2

image added图片已添加

and (if there was not conflict) then build the merged branch并且(如果没有冲突)然后构建合并的分支

I tried multibranch deployement but it does not meet my expectated usecase我尝试了多分支部署,但它不符合我预期的用例

Checkout the branch you want to merge into:检查要合并到的分支:

git checkout <branch_to_merge_into>

Merge the other branch into the current branch:将另一个分支合并到当前分支:

git merge <other_branch>

Resolve any conflicts that may arise during the merge process.解决合并过程中可能出现的任何冲突。 Commit the merge:提交合并:

git commit

Once the merge is complete, build the branch using your preferred build method.合并完成后,使用您首选的构建方法构建分支。

Push the merged branch to the remote repository:将合并后的分支推送到远程仓库:

git push origin <branch_to_merge_into>

Use Jenkins Plugins- git and merge and create job as parameterized job(Two parameters)使用 Jenkins Plugins- git 合并并创建作业作为参数化作业(两个参数)

在此处输入图像描述

Create two string values one with Source and Destination to pass it from parameters创建两个字符串值,其中一个具有 Source 和 Destination 以从参数传递它

在此处输入图像描述

Configure SCM git plugin with required credentials and add Branches to build section as shown (pass values as per parameter key values)使用所需的凭据配置 SCM git 插件,并将分支添加到构建部分,如图所示(根据参数键值传递值)

在此处输入图像描述

Use post Build option使用后期构建选项

在此处输入图像描述

Above configurations works for me.以上配置对我有用。

ref: https://plugins.jenkins.io/git/#plugin-content-publisher-push-merge-results参考: https://plugins.jenkins.io/git/#plugin-content-publisher-push-merge-results

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM