How to make simple plugin for SDA

0 Likes

 

Now you can archive this file into zip archive and upload as SDA plugin! It doesn't have any steps that will do any work, but it will be considered valid plugin, and will be visible in the plugins list.

What parts are important in the plugin.xml? These are:

  1. Plugin ID
    If you will change only ID - SDA will treat it as completely new plugin.
  2. Plugin name
    This is what you will see in UI.
  3. Plugin version
    It will be very important when you will have some major changes in your plugin and will need to make an update. It will be covered in other article.
  4. Description
    Another thing that you will see in UI.
  5. Tag
    Tag determines where plugin steps will be when you will need to use them in Process Designer:

    Example: Jenkins plugin has Tag "Integration/Jenkins"

 

Adding steps to your plugin

First - create groovy script named hello.groovy next to plugin.xml file. Write into it next text:

println 'Hello world'

Now you need to describe in the plugin.xml that this script should be executed as your plugin step. Do this add next xml after the <header> element:

<step-type name="Print 'Hello world'">
    <description>I will write 'Hello world' to the log!</description>
    <properties/>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        } else {
            properties.put("Status", "Success");
        }
    ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
        <arg file="hello.groovy"/>
        <arg file="${PLUGIN_INPUT_PROPS}"/>
        <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
</step-type>

What these xml means:

  1. step-type element describes new step, 'name' attribute sets step name
  2. step-type/description element sets description for your step
  3. step-type/properties contains list of step properties. Step properties will be covered in another article so now this element is empty
  4. step-type/post-processing contains groovy code that is invoked after step finished. By default it determines if step was successful. I have never any need to change this.
  5. step-type/command describes what script should be called to do the work and how it should be called.

It can look scary at first glance, but most often you will need only next parts:

  1. Step name - step-type@name
  2. Step description - step-type/description
  3. Groovy script file name - step-type/command/arg[1]@file (first arg element, has file=hello.groovy in the example)

Now select both files (plugin.xml and hello.groovy) make zip archive (name doesn't matter) and upload it to SDA!

 

That's it! Only two simple files and you have your own plugin.

In the next articles i`m going to cover:

  • How to add properties to your plugin, what property types are available.
  • How to use java libraries (packed as JAR-s) in your plugin.
  • How to upgrade your plugin that was already deployed.
  • How to automate dependencies management and build your plugin with maven.

Please write me if you have any questions.

Tags:

Labels:

How To-Best Practice
Comment List
Anonymous
Related Discussions
Recommended