Let's talk about OBIEE concurrent development!
Enabling concurrent development for OBIEE RPD is a recurring theme in OBIEE blogs. Full support for RPD development with Gitflow has long since been part of the Rittman Mead's BI Developer Toolkit and is described in great detail in Minesh's blog post. What you are currently reading is a follow-up to Minesh's post, but taking it one step further: instead of calling Python scripts to perform Gitflow steps, we want to perform all those steps directly from our Git client (including the ones performing a merge, like
feature finish), be it command line or a visual application like Sourcetree.
RPD versioning directly in Git - do we need that?
How is versioning directly in a Git client better than calling Python scripts? First of all, it is the convenience of using the same approach, the same tool for all content your need to version control. A Python script will have to come with instructions for its use, whereas every developer knows how to use Git. Last but not least, a 3-way merge, which is used for Gitflow's
release finish and
hotfix finish commands, requires three repositories that need to be passed to the script in the right order. Doing merges in your Git client would be quicker and less error prone.
What is a Git merge?
Before we proceed with discussing our options for merging OBIEE RPDs, let us quickly recap on how Git merges work.
There are two types of Git merges: Fast-forward Merges and 3-way Merges. Strictly speaking, Fast-forward Merges are no merges at all. If the base branch has not seen any changes whilst you worked on your feature branch, merging the feature back into the base simply means 'fast-forwarding' the base branch tip to your feature branch tip, i.e. your feature becomes the new base. That is allowed because the two branches have not diverged - the histories of the base and the feature branches form a single history line.
When the two branches have diverged, i.e. when the base has been modified by the time we want to merge our feature, a 3-way merge is the only option.
In the above diagram, feature 1 can be fast-forward merged whereas feature 2 must be 3-way merged into the develop branch.
Note that because a Fast-forward Merge is not an actual merge but rather a replacement, it is not relevant what content is being merged. The 3-way Merge however, depending on the content being merged, can be quite challenging or even impossible. And can result in merge conflicts that require manual resolution.
So... can Git 3-way merge RPDs?
OBIEE RPD can be saved in two formats: a single binary .rpd file or one or many .xml files (depending on what rpd-to-xml conversion method you use). The choice here seems obvious - it is common knowledge that Git cannot reliably 3-way merge binary files. So XML format it is. Or is it?
Like any other text file, Git certainly can merge XML files. But will it produce an XML that is still recognised as a consistent OBIEE RPD? Well, there are some OBIEE developer teams that have reported success with this approach. My own experience even with the most trivial of RPD changes shows that somewhere during the .xml to .rpd conversion, then introducing changes in the .rpd and in the end converting it back to .xml, the XML tags get reshuffled and sometimes their identifiers can change as well. (Equalising RPD objects is supposed to help with the latter.) I found no standard Git merge algorithm that would reliably and consistently perform RPD merge for XML format produced this way, be it a single large XML file or a collection of small XML files.
Fortunately, there is a better (and less risky) way.
Creating a Git custom merge driver
It is possible to create custom Git merge drivers and then assign them to specific file extensions (like .rpd) in the .gitattributes file - as described in Git documentation. According to the guide, defining a custom merge driver in Git is really straight forward: just add a new entry to the
[merge "filfre"] name = feel-free merge driver driver = filfre %O %A %B %L %P recursive = binary
filfre is the code name of the custom merge driver,
feel-free merge driver is the descriptive name of it (hardly used anywhere) and the
driver value is where we define the driver itself. It is a shell command for your operating system. Typically it would call a shell script or a binary executable. It can be a
java -jar execution or a
python my-python-script.py call. The latter is what we want - we have already got a 3-way merge script for OBIEE RPD in the Rittman Mead's BI Developer Toolkit, as blogged by Minesh.
For the script to know about the content to be merged, it receives the following command line arguments:
%O %A %B %L %P. These are the values that Git passes to the custom merge driver:
%O- this is the Base or the Original for the 3-way merge. If we are using Git Flow, this is the
developbranch's version, from which our
feature branchwas created;
%A- this is the Current version for the 3-way merge. If we are using Git Flow, this is the
feature branchthat we want to merge back into
%B- this is the Other or the Modified version of the 3-way merge. If we are using Git Flow, this is the
developbranch as it is currently (diverged from the original Base), when we want to merge our
feature branchback into it.
There are two more values, which we do not need and will ignore:
%L is Conflict marker size, e.g. 7 for '>>>>>>>'. This is irrelevant for us, because we are handling binary files.
%P is the full path name where the merge result will be stored - again irrelevant for us, because Python is capable of getting full paths for the files it is handling, in case it needs it.
Creating a Git custom merge driver for OBIEE .rpd binary files
What we need here is a Python script that performs a 3-way RPD merge by calling OBIEE commands
patchrpd from command line. Please note that OBIEE creates a 4th file as the output of the merge, whereas a git merge driver is expected to overwrite the Current (
%A) input with the merge result. In Python, that is quite doable.
Another important thing to note is that the script must return exit code 0 in case of a success and exit code 1 in case there were merge conflicts and automatic merge could not be performed. Git determines the success of the merge solely based on the exit code.
Once we have the Python script ready and have tested it standalone, we open our local Git repository folder where our OBIEE .rpd files will be versioned and open the file
<repo root>/.git/config for editing and add the following lines to it:
[merge "rpdbin"] name = binary RPD file merge driver driver = python C:/Developer/bi_developer_toolkit/git-rpd-merge-driver.py %O %A %B
Our Python script expects 3 command line arguments - names of .rpd files: Base (
%O), Current (
%A) and Modified (
%B). Those will be temporary files, created by Git in run time.
Once the config file is modified, create a new file
<repo root>/.gitattributes and add the following line to it:
This assumes that your binary RPD files will always have the extension
.rpd. If with a different extension, the custom merge driver will not be applied to them.
And that is it - we are done!
Note: if you see that the custom merge driver works from the Git command line tool but does not work in Sourcetree, you may need to run Sourcetree as Administrator.
Trying it out
We will use Sourcetree as our Git/Gitflow client - it is really good at visualising the versioning flow and shows the currently available Gitflow commands for the currently checked out branch.
We will use the RPD from Oracle Sample Application v602 for OBIEE 12c 220.127.116.11.0. for our testing.
After initialising Gitflow in our Git repository, we add the out-of-the-box Sample Apps RPD to our repository's develop branch - that will be our Base.
Then we create two copies of it and modify each copy to introduce changes we would like to see merged. In the screenshots below, you can see Business Models and Databases renamed. But I did also change the content of those Business Models.
Now we create a new feature branch and overwrite the Base rpd it contains with our Repo 1 rpd.
As the next step, we check out the develop branch again and replace the Base rpd there with Repo 2 rpd.
Note that we need to make sure the develop branch is different from the original Base when we finish our feature. If the develop branch will be the same as the original Base when we finish the feature, a fast-forward merge will be done instead and our custom merge driver will not be applied.
The result should look like this in Sourcetree. You can see a fork, indicating that the develop and the feature8 branches have diverged:
We are ready to test our custom 3-way merge driver. In Sourcetree, from the Gitflow menu, select
Confirm your intention to merge the feature back into develop.
If all goes as planned, Git will call your custom merge driver. In Sourcetree, click the Show Full Output checkbox to see the output from your script. In my script, I tagged all output with a [Git RPD Merge Driver] prefix (except the output coming from external functions). This is what my output looks like:
Now let us check the result: make sure the develop branch is checked out, then open the merged RPD in the Admin tool.
We can see that it worked - we can now do full Gitflow lifecycle for OBIEE .rpd files directly in Git.
But what if the merge fails?
If the merge fails, the feature branch will not be deleted and you will have to merge the .rpd files manually in the OBIEE Admin tool. Note that you can get the Current, the Modified and the Base .rpd files from Git. Once you are happy with your manual merge result, check out the develop branch and add it there.