Friday, September 5, 2014

JGit-Flow does the release job well

No matter what kind of software processes you employ, commit, branch, merge and release are always challenging for your organization. It is definitely not hard to do any of them well given a version control system, no matter it is Source Safe, CVS, ClearCase, Subversion, or distributed version control systems GIT and Mercury. The complexity grows exponentially when you have a team of developers, everybody could be smart but have different skills and preferences. In practice, we are also working on the ever-growing software systems, which makes matter worse. At Citysearch we literally have releases going out every week.

More or less you have a working best practice for version control within your team. There might be a problem here and there but you can always find a way out. Same applies in our team. With years of fooling around we came to a position where everybody in our team had to release stories ourselves. We did it okay with a well written release check list for most part of the year until we felt it was enough. Our project is built with Maven and subversion is our repository. It was a natural choice to use Maven Release Plugin that does the job well.

After configuring your pom following usage guideline you can release from your release branch easily.

mvn --batch-mode release:clean release:prepare release:perform
If you need system property for your build, you could run into troubles as I did. Note that the release plugin checks out code into a temporary work folder and invokes Maven deploy goal from there. Your system property is invisible during the packaging process unless you pass it as an argument to Maven Release Plugin.

   -Dtag=REL_${BUILD_ID} -Darguments=-Dtag=REL_${BUILD_ID}

Everybody can start a Jenkins release job without much training. That works great for us.

Moving onto the real treat. We are adopting GIT for future development, past experience with Maven Release Plugin drove me to look for alternatives and luckily I found JGit-Flow

After adding

            <plugin>
                <groupId>external.atlassian.jgitflow</groupId>
                <artifactId>jgitflow-maven-plugin</artifactId>
                <version>1.0-m4</version>
                <configuration>
                    <squash>true</squash>
                </configuration>

            </plugin>

into my pom.xml, all I need to do is issue command

mvn -U clean jgitflow:release-start jgitflow:release-finish -Dbuild.id=$BUILD_ID

There is no more ugly manipulation of system property since JGit-Flow does not package project in a temporary workspace folder. It also tags master branch and keeps  develop branch in sync with master,  which is missing in Maven Release Plugin.  As a bonus you would embrace Vincent Driessen's branching model.

No comments: