Create a JDBC export hook
You can also create JDBC export hooks that let you insert information about releases into a SQL database; for example, for reporting purposes. JDBC export hooks give you access to the
You can do this using the community-supported XLR-SQL Export hook that can be found on GitHub.
This topic describes how to create a JDBC Export Hook from scratch.
Add a new synthetic type to
conf/synthetic.xml. For example:
<type type="acme.MysqlReportingExportHook" extends="xlrelease.JdbcExportHook" />
url as a property of this synthetic type. This allows you to change the value in the user interface and use it in the Jython script. You can also add more properties, such as a username or password. For more information about synthetic types, refer to Create custom configuration types in Release.
The Jython script defines actions that you want to perform with release. The scope contains following variables:
exportHook: An object of type ExportHook
release: An object of type Release
releaseJson: A string with serialized release
logger: An object of type
org.slf4j.Logger. See Javadoc
In the script, you can get the JDBC connection by calling
exportHook.getJdbcConnection(). You can see this in the example on GitHub.
Note: It is recommended that you use
logger instead of
Store scripts in the
ext directory, which is a part of the classpath. By default, the export hook tries to locate
prefix/TypeName.py on the classpath. In the case of this example, it will be
Alternatively, you can set a customized script path in the
scriptLocation property of each export hook:
<type type="acme.MysqlReportingExportHook" extends="xlrelease.JdbcExportHook"> <property name="scriptLocation" hidden="true" default="mypath/MyScript.py" /> </type>
Note: It is recommended that you use the default location of
In Release, go to Settings > Shared configuration and configure an instance of your export hook.
All export hooks are executed for all completed releases just before they are archived. The order of execution is not guaranteed.
Each export hook has only one attempt to perform actions on the release. If it fails, it is not retried.
To learn more about export hooks, download the sample export hook from GitHub and customize it as desired.