Monday, February 06, 2012

Jasper Reports Release and Deployment

SDLC requires processes that are agile for development and ideally agile as well for releasing and deploying.

There is no silver bullet though so a strict release and deployment cycle will not hurt. Ultimately if you achieve extreme agility in these areas it should be completely automated but hey you must start from something: Outlining what a safe release and deployment is.

A project might consist of different packages and technologies which at the same time have different release/deployment cycles.

Here is what I mean when it comes to Jasper Reports.

Respecting separation of concerns there is a section of the team that is responsible for developing Jasper Reports. They are agile as they can develop a new report or change an existing and drop the changes in the server, they can see the end result of the work the have done. Even others can see the result as well of course.

However the fact that the code there in that environment you probably called test/integration is not ready for production. Why? It has not been released.

A release carries a version number and dependencies on other released artifacts. It is common to have sub-reports, images and in general dependencies all across the project.

In those cases where you have thousands of reports you will need to start thinking about how to define dependencies but I will not get that deep this time. Most of the projects out there could be releasing the whole Jasper Code with a simple bash command.

How can we release Jasper then?
  1. Compile jrxml files into jasper
  2. Find current version number for the to-be-released artifact from to the artifacts repository (Jenkins for example)
  3. Pack all resources in a zip file using the next version number
  4. Upload the zip versioned file to the artifacts repository

Of course all this must be scripted. Here is a proposal on how to address the Jasper Compilation. This ant script accepts a folder to look for jasper files and a destination zip file path where to store the packed folder.



 Jasper Reports Builder
 
 
  
   
  
  
 
 
  
 
 
  
  
   
   
  
  
 
 
  
   
  
  
 


Now you could call this script to have a versioned zip file that you can push into an artifact repository:
$ ant -f /opt/jasper-reports-build/jasper-reports-builder.xml clean compile -Dsrcdir=/Users/nestor/jasperreports -Ddestfile=/Users/nestor/jasperreports-1.0.0.zip

If you want to try this yourself here is a Plain Old Bash (POB) recipe to properly install the above script:
echo "--- Setting up the Jasper Reports Build script ---"

set -e

mkdir -p /opt/jasper-reports-build/lib
cd /opt/jasper-reports-build/lib
curl -O http://mirrors.ibiblio.org/pub/mirrors/maven2/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar
curl -O http://mirrors.ibiblio.org/pub/mirrors/maven2/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
curl -O http://mirrors.ibiblio.org/pub/mirrors/maven2/commons-digester/commons-digester/2.1/commons-digester-2.1.jar
curl -O http://mirrors.ibiblio.org/pub/mirrors/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
curl -O http://mirrors.ibiblio.org/pub/mirrors/maven2/org/codehaus/groovy/groovy-all/1.7.5/groovy-all-1.7.5.jar
curl -O http://mirrors.ibiblio.org/pub/mirrors/maven2/net/sf/jasperreports/jasperreports/4.1.3/jasperreports-4.1.3.jar
cd ..
curl -O http://nestorurquiza.googlecode.com/svn/trunk/jasper-reports/jasper-reports-builder.xml

1 comment:

antoniocarro said...

If you use JasperReports Server, I think the best way to deploy or publish a report is using the jdeploy tool on https://sourceforge.net/projects/jaspertools/?source=directory

it allows deal with the datasources problems on the diferent environments, dev, preproduction and production, and deploy a Zip archive of reports, subreports, images and resources that can be versioned.

Followers