In an effort to try and automate as much as possible, I decided to try and automate releasing our legacy multi-module project using bash. This has several benefits: create a release faster, done consistently each time, turn-key solution anyone on the team can run that doesn't require stale documentation on how to do it.
It took my several hours to essentially duplicate the maven release plugin process. Thanks to our new intern Scott Rogers and linux master Ron Alleva, I was eventually able to get it finished. It's my first "official" bash script so pardon the mess. If you've never attempted to automate your release project, first consider reading my article on How to effectively use SNAPSHOT.
Here is the script available as a gist on github: project-release.sh. Here is what it does:
- Copies the current working branch (i.e. trunk) into another branch. It uses the pom.xml
value to get the current working branch. - Updates all the pom.xml version sections of the current working branch
- Commits the pom.xml changes
- Checks out the release branch
- Updates all the pom.xml version sections of the release branch (basically stripping off -SNAPSHOT)
- Commits the pom.xml changes
A few notes about the script:
- The base branch URL is hardcoded but could easily be passed in as another parameter or placed and read from some external file.
- It uses the cmd xpath to extract out the pom version, project name, and scm url. I'm on ubuntu 9.10 and according to synaptic I have libxml-xpath-perl version 1.13-6 installed.
- It doesn't run any maven commands like mvn deploy. Other jobs in CI can accomplish that or you can easily add them into the script.
- To run from Hudson:
- Create a New Job
- In the Build section Add a Execute Shell Step
- Update the Command text with: $WORKSPACE/trunk/project-release.sh 2 false