It is never been easier to create your own SIL routine! Part1

Hello!

In this article I would like to talk on how to create your own routine in the SIL engine. 

Intro

SIL is a programming language, created by cPrime, to extend Jira and Confluence functionality. The main advantage of SIL is that SIL contains easy to use routines, which perform certain actions in Jira. For example, you want to write a program to search for issues. In Java API or groovy plugins, you would need to write about ten lines, which would make you go through Jira API and find your way on how to write these lines. Also you would need to provide compatibility of your code for Jira 7 and Jira 8. But in SIL you just call the selectIssues("your jql query"). That is all! This code will work for any Jira, which you have.

But, suppose, you want to do something in Jira and SIL language does not have a routine for it. In this case you have the following options:

  • Use SIL Groovy Connector - this plugin will let you execute Java API code within the SIL engine
  • Develop you own routine for the SIL engine.

In this article we will concentrate on developing our own routine.

I already wrote an article about it, explaining how it works here:

https://community.atlassian.com/t5/Agile-articles/Extend-the-Power-Scripts-add-on-for-Jira-Server-with-your-own/ba-p/987267

But as you can see, you need to do many changes to the out of the box Jira plugin, though all you need is just to add your own routine. In this article I will show you how to create a plugin with all needed environment in a couple of minutes.

Install SIL extension maven archetype

To create a plugin you need to have Atlassian SDK and git on your PC. First of all, you need to get the SIL extension archetype:

git clone https://alex1mmm@bitbucket.org/alex1mmm/sil-extension-archetype.git --branch v1 --single-branch

Screenshot 2020-03-13 at 14.53.34.pngA sil-extenstion-archetype folder will be created. Move to this folder:

cd sil-extension-archetype

Then install this archetype into your local maven repository:

atlas-mvn install

Create a plugin

Now you can create your plugin using this archetype. Move out of the sil-extension-archetype folder :

cd ..

Execute the following command:

atlas-mvn archetype:generate -DarchetypeCatalog=local

 You will be asked to choose an archetype to create a project:

Choose archetype:

1: local -> com.cprime.jira.sil.extension:sil-extension-archetype (This is the com.cprime.jira.sil.extension:sil-extension plugin for Atlassian JIRA.)

Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): :

Enter 1 and you will be requested to provide properties for you project. Here are my values for the properties. You can provide your own values:

Define value for property 'groupId': ru.matveev.alexey.sil.extension

Define value for property 'artifactId': sil-extension

Define value for property 'version' 1.0-SNAPSHOT: :

Define value for property 'package' ru.matveev.alexey.sil.extension: :

Confirm properties configuration:

groupId: ru.matveev.alexey.sil.extension

artifactId: sil-extension

version: 1.0-SNAPSHOT

package: ru.matveev.alexey.sil.extension

Y: : Y

 and the plugin will be created. In my case a sil-extension folder will be created.

Test the plugin

You can go to the sil-extension folder and run Jira:

cd sil-extension

atlas-run

Open Jira in your browser:

http://localhost:2990/jira/plugins/servlet/silmanager?autoSelectTree=sil.scripts

 You will see the SIL Manager screen. Choose the New File option:

Screenshot 2020-03-13 at 15.09.34.png

And create a file called test.sil with the following contents:

runnerLog(SayHello("Alexey"));

string[] res = SayHello2("Alexey", "Matveev");
runnerLog(res[0]);
runnerLog(res[1]);
res = SayHello3("Alexey", "Matveev");
runnerLog(res["param1"]);
runnerLog(res["param2"]);

You screen will look like this:

Screenshot 2020-03-13 at 15.13.41.pngYou plugin added three routines: SayHello, SayHello2, SayHello3. In this script we check that these functions work. You can push the run button. The output in the Console tab will be:

Hello Alexey

Hello Alexey

Hello Matveev

Hello Alexey

Hello Matveev

Done.

Congratulations! You added 3 new routines to the SIL engine.

In Part 2 of this article I will tell you more on internals of the created plugin.

3 comments

Zoryana Bohutska _SaaSJet_
Atlassian Partner
March 13, 2020

Thank you for so useful article!

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2020

You are most welcome!

Taranjeet Singh
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 13, 2020

That's a nice start on SIL related articles @Alexey Matveev ! Looking forward to next part.

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events