Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Webhooks summary

Excerpt

Starting with version 4.5.0 we support Webhooks.

...


Note
titleURL Change

The application URL for Power Scripts for Jira Cloud is changing from pscloud.cprime.com to pscloud.anova.appfire.app on May 20th, 2023. In order to prevent any disruption of your existing webhooks you should update to the new URL. The old URL will be temporarily redirected to the new URL for some period of time. However, this change requires a brief down-time and there is no guarantee how long the redirect will remain in place. To ensure there is no disruption in your services the URL should be updated on, or closely after May 20th. Thank you for your understanding.


Warning

Looking for the documentation on the newest versions of SIL Engine and the Simple Issue Language for Jira 8 for Server/Data Center? Click here !


Info
titleAvailability

This feature is available starting with v4.5.0.


Webhooks summary

Excerpt

Webhooks give you the possibility to run existing SIL scripts

...

from outside of the Jira / Confluence instance, by using a REST/HTTP client

...

and retrieve the results of the run script

...

.


In order for this to be possible, we you need 2 the following things:

  1. Create a SIL script.
  2. Configure a webhook to run that SIL script.

Creating a SIL script

Almost You can use almost any SIL script can be used, but the two Webhooks specific SIL routines getWebhookPayload and appendToWebhookResponse are the ones that make this feature powerfulespecially powerful with this feature.

Example 1 - Getting the Webhooks payload from the calling client and returning custom results and HTTP response code

...

Code Block
languagecpp
themeConfluence
//getting the REST/HTTP call input parameters:
WebhookPayload httpRequestPayload = getWebhookPayload();

//getting the used HTTP method:
string httpMethod = httpRequestPayload.httpMethod;//This can be something like "GET", "POST", "PUT" etc.

//getting the http request payload (body):
string httpPayload = httpRequestPayload.payload;

//getting the http query parameters:
WebhookParam[] httpQueryParams = httpRequestPayload.queryParams;
string firstQueryParamName = httpQueryParams[0].name;
string firstQueryParamValue = httpQueryParams[0].values[0];

//sending the response back to the caller:
appendToWebhookResponse("http method:");
appendToWebhookResponse(httpMethod);
appendToWebhookResponse("payload:");
appendToWebhookResponse(httpPayload);
appendToWebhookResponse("firstQueryParamName:");
appendToWebhookResponse(firstQueryParamName);
appendToWebhookResponse("firstQueryParamValue:");
appendToWebhookResponse(firstQueryParamValue);

//returning a custom HTTP status code:
return true, 1234200;


The format for the return line, if . If used, it should be return <true|false>[, <Custom HTTP <HTTP status code>];
The first argument can only have the values 'true' or 'false' values. 'True' means that the script was run was correctly, and 'false' means that the script encountered a problem when it was run.

...

Note
titleNOTE

It is highly recommended that you use valid HTTP status codes.


Webhooks configuration

To define what URI and HTTP method(s) will be used to invoke a specific SIL script, use the SIL Webhooks Configuration should be used. The page is located under configuration.

  1. Log in to your Jira as Admin.
  2. Go to your Administration > Add-ons

...

  1. > CPRIME PLUGINS CONFIGURATION > SIL Webhooks Configuration.
  2. To create a Webhook entry, click the the

...

  1. Add webhook

...

  1. button.
    A screen like the following will appear:

...


  1. Image Added

  2. Fill in the

...

  1. parameters in the form:
    • Name - the name of the webhook. This will be used as an

...

    • identifier for the webhook configuration.
    • Methods - the HTTP method (or methods) to bind the webhook to.

...

    • Script -

...

    • SIL

...

    •  script that will run when calling this webhook.
    • Synchronized - the sync/async configuration for the webhook.
    Note
    titleNOTE

    The difference between synchronous and asynchronous is that the asynchronous Webhook SIL call can't return any results or custom HTTP codes to the caller.

...

  1. This happens because the SIL script run task is added to a list of future tasks to be run, and the HTTP call ends.

    With the synchronous option, the call will block until the SIL script run is completed, and the results will be returned to the caller.


  2. Save the configuration.
    After

...

  1. you save  the configuration, a new entry like the following one will show up:

...


  1. Image Added

...


  1. The URI column in the table will help you run your newly created

...

  1. webhook. For example if your Jira installation instance is located at http://localhost, you can run the webhook using the

...

  1.  http://localhost/rest/keplerrominfo/refapp/latest/webhooks/mysilwebhook/run

...

  1.  address with the selected HTTP method(s).


The You can access the webhook configured in the this example image can be accessed using the HTTP methods GET and POST.

Changes are visible immediately and the webhook is ready immediately.

If you configured the Webhook to be available for the GET HTTP method, you can test the webhook in the browser, giving it custom query parameters, and the result could look something like this (the above SIL script was used):

Image Added

Note
titleNOTE

 In Power Scripts for Cloud, the prefix for the above link should be the add-on URL (https://pscloud.cprime.com/refapp). Also, the JWT query parameter will be needed, and will be accessible from the SIL webhook script.

Webhooks Authentication

...

More details about how the JWT works are here.

If you can't find out how to generate one by yourself, the easiest way to get one is to open one of our pages from the SIL Manager's Quick Links menu (for example, the SIL Webhooks Configuration) in a new tab and copy it from that URL directly.
Note that you'll have to consider this parameter in your SIL script as well.

WARNING: The JWT will not appear in the URL when opening a page from the Jira Admin side bar menu, only when opening from the quick links.

Example:
https://pscloud.cprime.com/refapp/rest/keplerrominfo/refapp/latest/webhooks/test/run?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJjb20ua2VwbGVycm9taW5mby5qaXJhLnBsdWdpbnMuamp1cGluIiwiY2xpZW50S2V5IjoiZTAxMjEwMDAtYWViNC0zMDcwLWE3YjUtNzYyODAxZGE3NzlkIiwiaXNzIjoiY29tLmtlcGxlcnJvbWluZm8uamlyYS5wbHVnaW5zLmpqdXBpbiIsImV4cCI6MTU5MTg4NDYwOSwiaWF0IjoxNTkxODgzNzA5fQ.pO-0EK_-WfczydvCrjBZ7iZjO5tV5e1zj0199xQUxVk

Webhooks authentication

For the REST/HTTP client to be able to make any Webhooks calls, it needs to be authenticated into the Jira / Confluence instance.

Please see refer to the official Atlassian Security pages for information on the authentication:

  1. https://developer.atlassian.com/server/jira/platform/basic-authentication/
  2. https://developer.atlassian.com/cloud/confluence/basic-auth-for-rest-apis/

...