Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge into a temporary branch before Jenkins build

I have the following Gitlab + Jenkins setup:

  1. I have a branch called "Develop"
  2. I have feature branches "F1", and "F2", and so forth.
  3. When the author of "F1" creates a merge request, Gitlab will trigger a Jenkins build, which currently checks out and builds F1.

I want Jenkins to do the following:

  1. Clone develop to a local branch named "Temp"
  2. Merge F1 to Temp
  3. Build my solution in Temp and Run the Tests
  4. Report the build result back to Gitlab

Is something like this possible in Jenkins? I know Git plugin has an option called "Checkout to a Specific local Branch", but I am not entirely sure if this does what I want.

Any help/input regarding this issue would be highly appreciated. Thanks and Cheers :)

like image 230
Vin Shahrdar Avatar asked Dec 14 '18 22:12

Vin Shahrdar


People also ask

How do I merge to a specific branch?

To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.

How do I merge a branch in github using Jenkins?

Go to source code management->Additional Behaviours->Merge before build.

How do I merge a developer into a feature branch?

Once the feature is complete, the branch can be merged back into the main code branch. First we run git checkout master to change the active branch back to the master branch. Then we run the command git merge new-branch to merge the new feature into the master branch.


1 Answers

There is a "merge before build" action in the Git plugin. It only merges on the build machine — it doesn't push the merge back to the origin repository.

"Merge before build" parameters

like image 193
Ted Percival Avatar answered Oct 19 '22 03:10

Ted Percival