X

Step Up to Modern Cloud Development

Code Merge as part of a Build Pipeline in Oracle Developer Cloud

Abhinav Shroff
Principal Product Manager

This blog will help you understand how to use code merge as part of a build pipeline in Oracle Developer Cloud. You’ll use out-of-the-box build job functionality only. This information should also help you see how useful this feature can be for developers in their day-to-day development work.

Creating a New Git Repository

Click Project Home in the navigation bar. In the Project page, select a project to use (I chose DemoProject), and then click the + Create Repository button to create a new repository. I’ll use this repository for the code merge in this blog.

In the New Repository dialog box, enter a name for the repository. I used MyMergeRepo, but you can use whatever name you want. Then, select the Initialize repository with README file option and click the Create button.

Creating the New Branch

Click Git in the navigation bar. In the Refs view of the Git page, from the Repositories drop-down list, select MyMergeRepo.git. Click on the + New Branch button to create a new branch.

In the New Branch dialog, enter a unique branch name. I used change, but you can use any name you want. Select the appropriate Base branch from the drop-down list. For this repository, master branch is the only option we have. Click the Create button to create the new branch.

 

Creating the Build Job Configuration

In the navigation bar, click Builds. In the Jobs tab, click on the + Create Job button to create a new build job.

 

In the New Job dialog, enter a unique name for the job name. I’ll use MergeCode but you can enter any name you want. Select the Use for Merge Request checkbox, the Create New option, and then select any Software Template from the drop-down list. You don’t need a specific software bundle to execute a merge. The required software bundle, which by default is part of any software template you create, is sufficient. Finally, click the Create Job button.

Note: If you are new to creating Build VM templates and Build VMs, see Set Up the Build System.

 

When you create a build job with the Use for Merge Request checkbox selected, the Merge Request Parameters get placed in the Repository and Branch fields of the Source Control tab. You can go ahead and select the Automatically perform build on SCM commit checkbox.

In the Build Parameters tab, you’ll notice that Merge Request parameters like GIT_REPO_URL, GIT_REPO_BRANCH, and MERGE_REQ_ID were added automatically. After reviewing it, click on the Save button.

 

Creating the Merge Request

In the navigation bar, click Merge Requests.  Then click on the + Create Merge Request button.

In the New Merge Request wizard, select the Git repository (MyMergeRepo), the target branch (master), and the review branch (change). You won’t see any commits because we haven’t done any yet. Click the Next button to advance to the second page.

On the Details page, select MergeCode for Linked Builds and select a reviewer. If you created an issue that needs to be linked to the merge request, link it with Linked Issues. Click the Next button to advance to the last page.

You can change the description for the merge request or just use the default one. Then click the Create button to create the merge request.

In the Linked Builds tab, you should see the MergeCode build job as the linked build job.

 

Changing a File and Committing the Change to the Git Repository

In the Git page, select the MyMergeRepo.git repository from the repository drop-down list and the change branch in the branches drop-down list. Then click the README.md file link.

Click the pencil icon to edit the file.

Add some text (any text will do), and then click the Commit button.

 

The code commit triggers the MergeCode build.

 

When a build of a linked job runs, a comment is automatically added to the Conversation tab. When the MergeCode build completes successfully, it auto-approves the merge request and adds itself to the Approve section of the Review Status list, waiting for an approval from the reviewer assigned to the merge request.

Once the reviewer approves the merge request, the review branch code is ready to be merged into the target branch. To merge the code, click the Merge button.

Note: For this merge request, Alex Admin, the user who is logged in, is the reviewer.

 

By including Merge Request Parameters as part of a build job, you can be sure that every commit will be auto-validated to be free of conflicts and approved. This comes in handy when multiple commits are linked to a merge request by linking the build job enabled for merge requests. The merge request will still wait for the assigned reviewer(s) to do the code review, approve the changes, and then merge the code in the target branch.

This feature helps developers collaborate efficiently with their team members in their day-to day-development activities.

Happy Coding!

 **The views expressed in this post are my own and do not necessarily reflect the views of Oracle

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services