DevOps Automation

DevOps Automation

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Creating an Automation Plugin for DevOps Deploy

By Shabaz Kowthalam posted Mon November 25, 2024 05:15 AM

  

Before we dive into the steps for creating a plugin, we recommend reading this blog post for some useful tips and recommendations: UrbanCode 10 Minute Tip: Can I write my own UCD Plug-ins?

DevOps Deploy plugins consist of two types of plugins. They are:

  1. Source Configuration Plugins
    • Integrate with external systems to import artifacts and create component versions.
  2. Automation Plugins
    • Provide steps to manipulate components, typically for deployment.

To view the list of plugins installed in your DevOps Deploy application:

  1. Navigate to the Settings page.
  2. Under the Automation section, you will find two options:
    • Automation Plugins
    • Source Configuration Plugins

This blog covers how to create an automation plugin using the Sample Automation Plugin Template

Use Case

Let’s create a plugin where users can register for an event providing special requirements, and confirm agreement with policies with the following inputs.

Text box: Enter your full name

Text area: Mention dietary restrictions or additional requests

Checkbox: I agree to the event’s rules and regulations

Drop-down: Select your role at the event (Speaker/Attendee/Volunteer).

Creating a repository using GitHub template

To create a new GitHub repository for our new plugin, navigate to the Sample Automation Plugin Template.

Click on the drop-down Use this template Create a new repository:


Let’s name our plugin repository ucd-demo-event-plugin and create the repository:

Clone the plugin repository in your local system and open the project in your favourite editor or IDE.

Overview of Files and Directories

.gitignore and .gitattributes: Configuration files for Git.
 
.github/workflows/: Contains GitHub Actions workflows for building and releasing the plugin.
 
Gradle files and directories: Related to the Gradle build tool.
 
README.md: Provides project-related information.
 
src/: Contains the program files and plugin configurations.

Designing the UI for Plugin Steps

To design the plugin step UI open file src/main/zip/plugin.xml in the editor

Update the Plugin Header

Modify the header in the plugin XML highlighted below.

id: Give a unique identity for your plugin.

[Tip: Use domain name in the id]

version: We will keep it to ‘1’ as it is an initial version.

name: Give a name for your plugin in a few words.

description: A short and crisp description to tell what the plugin does.


tag: Where users can find the plugin step. For example, in the step palette the Event Registration step is found under Utilities/Demo Event.

Define the Plugin Steps

Let’s create a plugin step with name Event Registration with the inputs discussed in the Use Case section like below.

Each property contains following attributes:

name: Used by the java program to get a value for the property.

required: True if it’s a mandatory input otherwise false.

label: Label name to be shown in the UI for the input.

default-value: Default value for the input.

type: Type of UI Element.


The properties above generate the following UI form in DevOps Deploy: 

Update the Tool Description in the Info XML File

In src/main/zip/info.xml file, update the tool description like the following:

<tool-description>

        This is a Demo Event Plugin for UCD

 </tool-description>

Creating a Java Class for Processing

Now let’s add our Java Packages and classes to src/main/java directory as below:


The EventRegistration class takes the user inputs, processes them and generates the required output or output properties.

In plugin.xml, change the command tag to invoke the program EventRegistration as below:


Building the Plugin

Java version 11 or higher is required to build the plugin.

Update the project name in the settings.gradle file like below

rootProject.name = "ucd-demo-event-plugin"

To build the plugin go to the project directory and run the Gradle Wrapper Script.


After successful completion of the Gradle build process, the plugin zip will be available under the build/distributions directory.

Applying the Plugin on DevOps Deploy

Login to DevOps Deploy and Navigate to Settings Automation Plugins Upload Plugin. Select your plugin zip file present in the build/distributions directory.

After successfully uploading the plugin, we will see an entry with plugin name in Automation Plugins page like below


Our new plugin is ready to be used in a process.

References

UCD Sample Automation Plugin

Pull Request with changes involved for developing a new plugin

UCD Demo Event Plugin

Official IBM documentation on plugins

UrbanCode 10 Minute Tip: Can I write my own UCD Plug-ins?

2 comments
25 views

Permalink

Comments

Fri December 06, 2024 07:21 AM

Files and Directories section is fixed now.

Fri November 29, 2024 03:32 AM

Hello Shabaz,

In the Files and Directories section some characters of the text are missing (left side) and it looks like they were "moved out" of the canvas. Could you please have a look at it?