Home > Software engineering >  Jenkins- How to merge two git branch and then build the merged branch
Jenkins- How to merge two git branch and then build the merged branch

Time:01-30

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

CodePudding user response:

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>

CodePudding user response:

Use Jenkins Plugins- git and merge and create job as parameterized job(Two parameters)

enter image description here

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

enter image description here

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

enter image description here

Use post Build option

enter image description here

Above configurations works for me.

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

  • Related