Scheduled plug-ins are one of the ways of extending the functionality of Elvis. They are used for automating server tasks and are always entirely hosted in the Elvis plug-in folder — in contrast to for example Action plug-ins which can also be hosted on an external server..
This article contains tips and tricks to get you started.
Manually running a Scheduled plug-in
To manually run a Scheduled plug-in, do the following;
Step 1. Access the Management console.
Do one of the following:
- Access the following URL and log in using system administrator credentials (a 'Super user' account):
<Elvis Server URL>/console
- Access the Elvis Pro client by accessing the following URL, log in using system administrator credentials, and choose Management Console from the Avatar menu.
<Elvis Server URL>/app
Step 2. From the menu, choose Plugins, followed by Scheduled plugins.
Step 3. Expand the plug-in that you want to execute and click Execute plugin.
Figure: The Version Cleanup plug-in expanded on the Scheduled plug-ins page.
The base technology used for schedule plug-ins is Apache ANT, a task language which allows us to automate a wide variety of processes.
ANT provides hundreds of tasks like:
- copy, delete, rename files and folders.
- create or extract ZIP files.
- perform FTP operations
- send emails.
- perform XSL transformations.
- perform SOAP webservice requests.
Some extra tasks, like if and for-each, are available via ant-contrib.
Extra Elvis tasks
Elvis provides some extra tasks as well. Usage scenarios can be found in the existing plug-ins. These tasks are:
- saxon-xslt - performs XSLT 2.0 transformations.
- xpath - extract information from an XML file using XPath.
- soap - performs SOAP calls to webservices.
- xmlFileList - list the contents of a directory to an XML file so it can be processed using an XSL.
- tableData2Xml - convert a CSV or Excel file to an XML file for further processing with XSL.
- xml2TableData - convert an XHTML table to a CSV or Excel file.
Sample plug-ins and code samples
The easiest way of getting insight in how plug-ins work is to review some of the sample action plug-ins we provide with the server. There are developer code samples and ready to use plug-ins available:
- Developer plug-in samples: <Config>/plugins/samples/code_samples/schedule_plugins
- Sample schedule plug-ins: <Config>/plugins/samples/schedule_plugins
You can see how they work and how they are configured. Feel free to use them as the starting point for your own plug-in.
There are a few simple and easy to understand samples like hello_world showing the basic possibilities of schedule plug-ins. There are also technically more advanced plug-ins like folder_import and metadata_import.
When the schedule triggers, the ANT build file is executed. This file must be available in the root of the plug-in folder and should be named ant.script.xml.
All plug-in specific properties in the plug-in configuration section - <config>...</config> are passed to the ANT build file as variables.
The Eclipse IDE is a suitable tool for ANT development as it supports auto-complete and error highlighting for ANT build files.
When you run your plug-in, output is written to a log file, the log files are in the Elvis logs folder, grouped per plug-in.