Skip to end of metadata
Go to start of metadata

What does it do?

What are the pre-requisites?

You will need to have VisualScript and ScriptRunner Apps installed on your instance of JIRA with administrative access.

How do I get started?

High Level Steps

  1. Ensure you have installed VisualScript for Jira and ScriptRunner for Jira
  2. Create a ScriptRunner REST Endpoint
  3. Copy the REST Endpoint URL you are trying to use
  4. Add a Visual Script Gadget
  5. Paste the REST Endpoint URL as the gadget parameter
  6. Click Set VisualScript URL

Detailed Steps

Step 1:

  • Navigate to the Add-ons administration page using the cog in the top right corner
  • Find the ScriptRunner section in the left-hand panel and select REST Endpoints
  • Click the Add New Item button and select Custom endpoint
  • Choose from the 2 examples at the bottom of this document, expand the example, copy and paste the code into the in-line script
  • Click Add


Step 2:

  • In the list of REST Endpoints, find your newly added endpoint. This will show up as the name of the method of the endpoint. For example if you chose the Org chart example then it will be called getOrgChart
  • Right click on the hyperlink of your endpoint and select Copy Link Address
  • Using the Dashboard dropdown in the banner menu Navigate back to your main dashboard where you want your Visual Script to be added. You will need to have your own Dashboard, it cannot be the System Dashboard
  • If you don't have a Dashboard : Go to Manage Dashboards → Create New Dashboard → Name it and Add it

Step 3:

  • Click Add Gadget button in the top right of the Dashboard

  • Find the VisualScript Dashboard Gadget for Atlassian JIRA gadget and add it

    You may need to view all Gadgets in order to find it.

  • Paste the url that you copied of your endpoint into the VisualScript Source URL input.  If you have chosen an example that requires a parameter then add your parameter to the url.
  • Click Set VisualScript URL


Step 4: Example end result

Examples

Example 1:

This is an example REST endpoint for an Org Chart. Example URL - https://<YOURBASEURL>/rest/scriptrunner/latest/custom/getFlowChart?startingLabel=hello

Org Chart
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonSlurper
import groovy.transform.BaseScript
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
@BaseScript CustomEndpointDelegate delegate

getOrgChart(httpMethod: "GET"){ MultivaluedMap queryParams ->

    return Response.ok(getOrgChartSdon()).build()
}

static String getOrgChartSdon() {
    def slurper = /
{
    "DiagramType":"Orgchart",
    "RootShape":[{
        "Label":"Top Dog",
        "ShapeList":
        [{
            "Direction":"Right",
            "Shapes":     [
                   {"Label":"Ivanka"},
                   {"Label":"Jared"},
                   {"Label":"Donald Jr","ShapeList":[{"Shapes":[{"Label":"Donald III"}]}]},
                   {"Label":"Melania"},
                   {"Label":"Baron","ShapeList":[{"Shapes":[{"Label":"Flopsy"},{"Label":"Mopsy"}]}]
                   }]
        }]
        }]
    }
/
}



Example 2:

This is an example REST endpoint for an Flow Chart. This example takes in a parameter named 'startingLabel', you will need to supply this in the url when adding it to the gadget. For example https://<YOURBASEURL>/rest/scriptrunner/latest/custom/getFlowChart?startingLabel=hello

Flow Chart
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import groovy.transform.BaseScript

import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
@BaseScript CustomEndpointDelegate delegate

getFlowChart(httpMethod: "GET"){ MultivaluedMap queryParams ->

    def startingLabel = queryParams.get("startingLabel")?.first()
    return Response.ok(getFlowChartSdon(startingLabel)).build()
}

static String getFlowChartSdon(def startingLabel) {
    def slurper = /
{
  "DiagramType": "Flowchart",
  "RootShape": [
    {
      "ID": "1",
      "Label": "${startingLabel}",
      "ShapeList": [
        {
          "Shapes": [
            {
              "ID": "2",
              "Label": "Step 1"
            },
            {
              "ID": "3",
              "Label": "Step 2"
            },
            {
              "ID": "4",
              "Label": "Step 3",
              "ShapeList": [
                {
                  "Direction": "Down",
                  "Shapes": [
                    {
                      "ID": "5",
                      "Label": "Decision A"
                    }
                  ]
                }
              ]
            },
            {
              "ID": "6",
              "Label": "Step 4"
            },
            {
              "ID": "7",
              "Label": "Step 5"
            }
          ]
        }
      ]
    }
  ],
  "Returns": [
    {
      "StartID": "5",
      "EndID": "3"
    },
    {
      "StartID": "7",
      "EndId": "2"
    }
  ]
}
/
}








  • No labels