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:
In this article we will concentrate on developing our own routine.
I already wrote an article about it, explaining how it works here:
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
A 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:
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:
You 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.
Alexey Matveev
software developer
MagicButtonLabs
Philippines
1,574 accepted answers
3 comments