One aspect of implementation of JasperReports® Server that needs to be considered is that of version control. This Wiki article reviews possible approaches to accomplishing this.
Requirements
There are several ways to produce Jaspersoft content. Jaspersoft Studio is the primary tool to create pixel perfect, complex reports. Artifacts can also be created using JasperReports Server itself.
Inside JasperReports Server there are multiple resources that may need to be versioned.
- Pixel perfect reports. These can be jrxml files or JasperReports Server report packages.
- Ad hoc reports
- Data sources
- Domains
- Topics
- Other resources
- Input controls
- Queries
- Images
Report developers create, modify, test and deploy to JasperReports Server from Jaspersoft Studio via JasperReports Server REST services.
The JasperReports Server REST API can be used to update:
- Repository contents: report units, data sources domains
- Users
- Roles
- Permissions
- Audit
- etc
The JasperReports/Studio and JasperReports Server changes within the JasperReports Server repository are to be version controlled.
Reports and other artifacts need to deployed into different JasperReports Server environments:
- Development to test to production
- A hotfix in production needs to pushed back into other versions and environments
The deployment process to JasperReports Server environments is to be automated and leverage version control.
There are environment specific settings within the repository and in the JasperReports Server that need to be updated during deployments.
There are also processes like upgrades and hotfixes that change the JasperReports Server repository and server.
Design
Base idea for this approach is to have the JasperReports Server repository structure in a Git repo. Resources only should be maintained.
Developer creates a branch for themselves
Repeatedly
-
Developer updates the JasperReports Server repository in their local environment.
-
js-export changes to the branch
-
Always export their full repository to the file system of the JasperReports Server repository
-
Repeated exports of the same resources will show only files that have changed
-
Use of universal encryption key
-
-
Commit
Get from Git into JasperReports Server repository
-
Get branch
-
js-import into JasperReports Server repository
- Everything from Branch
-
Selectively
- Create a working repository and import branch into it
- Create exports of individual objects
- Import the individual object exports into the target JasperReports Server repository
Secured values need to be maintained separately for each JasperReports Server repository
-
Exported separately from resources
-
Loaded after import from version control
-
Use server settings
-
Or saved exports
-
Need encryption keys specific to each JasperReports Server repository
Pull requests and merges
-
Dev -> Test -> Prod
-
Hotfix back into development
Can revert changes in Git, then re-import.
Jaspersoft command line functions
Export
js-export --uris /public --output-dir /path/to/cloned/repo --keyalias deprecatedImportExportEncSecret
Secured values change on every export.
Import
js-import --update --keyalias deprecatedImportExportEncSecret --input-dir "/path/to/cloned/repo"
Import using the universal encryption key
Update the secured values separately with environment specific values ie. passwords
Processes
Push the initial JasperReports Server repository to Git
Have an existing JasperReports Server repository database available with the resources you want to save into Git.
Set up a central Git repository for the JasperReports Server resources.
Set a branch or leave as master.
Clone the Git repository to a directory in the local environment. Say “/path/to/cloned/repo”
Work at the command line in a JasperReports Server buildomatic directory.
js-export --uris /public --output-dir /path/to/cloned/repo --keyalias deprecatedImportExportEncSecret
Commit the updates to the central Git repository from /path/to/cloned/repo
New repository database set up from Git
Work at the command line in a JasperReports Server buildomatic directory.
Update default_master.properties with the repository database connection details.
A new encryption key and a new keystore are about to be created. Any previously created key and keystore will become invalid and the corresponding passwords unusable. If you think this JasperReports Server instance already has a keystore configured by another OS user, stop this process and configure the path in keystore.init.properties file, then run this command again. See the JasperReports Server Security Guide for details. Do you want to continue? (y/N) Y js-ant create-js-db js-ant init-js-db-pro js-ant import-minimal-pro
Clone the central Git repo locally and set the branch.
js-import --update --keyalias deprecatedImportExportEncSecret --input-dir "/path/to/cloned/repo"
Ensure configuration to use an existing repository
Before starting, ensure the keystores files relevant for the particular repository are available in the local environment.
If you have to deploy from a fresh machine, follow this process to configure the keystore files for the existing repository: https://community.jaspersoft.com/wiki/encryption-jasperreports-server-75#Updating_Keystore_files
Delete keystore.init.properties
Update default_master.properties with the repository database connection details.
js-ant clean-config js-ant gen-config
Clone the central Git repo locally and set the branch.
js-import --update --keyalias deprecatedImportExportEncSecret --input-dir "/path/to/cloned/repo"
Developer/admin updates the repository and Git
Edit/publish to the repository via JRS processes.
js-export --uris /public --output-dir /path/to/cloned/repo --keyalias deprecatedImportExportEncSecret
Always export the full repository!
Commit the updates to the central Git repository from /path/to/cloned/repo
Developer/admin gets updates from Git into a repository
Get latest updates of the central Git repository or clone.
Use branches.
js-import --update --keyalias deprecatedImportExportEncSecret --input-dir "/path/to/cloned/repo"
Saving Server level Attributes
With attributes set, they can be exported to a zip file and then imported into target JasperReports Server environments.
As the superuser, go to Server Settings > Export.
Note the attributes and server settings check boxes below.
These export zip files can only be imported into environments that have the same keystore as the original environment.
Saving Organization level Attributes
Superuser selects Manage Organizations > select an Organization
Right click > Export
A tenant administrator can do export for their organization.
Maintaining Environment specific resources
There are resources in the repository that contain values specific to an environment.
The best method to preserve these values is to use the server, organization and user attributes which are maintained separately from the repository resources.
- https://community.jaspersoft.com/documentation/tibco-jasperreports-server-administrator-guide/v750/attributes-data-source-definitions
- https://community.jaspersoft.com/wiki/built-parameters-logged-user
There could also be environment specific resources which would be updated via the Git to repository import process. These will have to be exported separately and then imported after an update from Git has occurred.
Dev/Test/Prod, Hot fixes
Developers work in a branch.
Use merges and pull requests to move resource versions between different branches.
Deploy to different environments using branches.
Repository changes related to a hotfix are committed to the production branch and then merged or pull requested into other branches.
Conflicts
Conflicts can happen.
Given the nature of the repository resources, it will be difficult in many cases to selectively merge the contents of individual resources with Git and then have a working repository.
Exports into Git must be of the same complete areas of the repository, because of dependencies and the fact that the export machinery will not do an export of an object or folder, say, into Git will not respect the greater repository structure and disable the ability to import from Git. If a subset of the repository is exported to Git, that commit will have to be reverted for subsequent imports from Git to work.
Current examples of version control with Jaspersoft
Jaspersoft Studio
Jaspersoft Studio defines projects containing JRXMLs and other resources that can integrate automatically with version control through the file system. In recent versions of Jaspersoft Studio, Git integration is installed by default.
When you create a project in Jaspersoft Studio you can pull it from a variety of version control providers (CVS, SVN, Git)
Version control of exports
Export artifacts from the repository into zip files.
Version control the exports.
Import the exports into target environments.
Use of command line tools:js-export/import
Or REST services
- Export
- Import
Maintenance with REST services
Use of JasperReports Server REST APIs
-
resources
- organizations
Coding and scripting.
Targeted versioning
Versioning raw resources and jrxml ...pulling it...building an export file from scratch and then importing it
BASH scripts
Use BASH scripts to pull stuff from GIT and push to Jaspersoft via REST to automate.
Other Information
Various clients have implemented version controls in a number of ways. Contact us for more details / references.
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now