简体   繁体   中英

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:

branch_names to build: 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)

在此处输入图像描述

Create two string values one with Source and Destination to pass it from parameters

在此处输入图像描述

Configure SCM git plugin with required credentials and add Branches to build section as shown (pass values as per parameter key values)

在此处输入图像描述

Use post Build option

在此处输入图像描述

Above configurations works for me.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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