This document details the Shared Groovy Scripts REST API of JMWE using which you can import and export shared Groovy scripts within or across Jira instances.

Resources

Returns the JSON of the shared script by the script name.

Request

URL PARAMETERS

parameter

description

name

Name of the Shared Groovy script

jira-base-url

Jira base URL. For example http://localhost:8080

Responses

- application/json Returned if the shared script is found.

- Unauthorized

- Not found

EXAMPLE

GET http://localhost:8080/rest/jmwe/1/shared-scripts/GreetMe

Response

{
    "id": "GreetMe",
    "key": "GreetMe",
    "code": "class GreetMe{\r\n String aString = \"Hello\"\r\n  String sayIt() {\r\n  return aString;\r\n\t} \r\n}",
    "description": "",
    "modified": 1575641794486
}

Returns the JSON of all the shared scripts in the instance

Request

URL PARAMETERS

parameter

description

jira-base-url

Jira base URL. For example http://localhost:8080

Responses

- application/json Returned if the shared scripts are found.

- Unauthorized

- Not found

EXAMPLE

GET https://localhost:8080/rest/jmwe/1/shared-scripts

Response:

[
    {
        "id": "Functions",
        "key": "Functions",
        "code": "issue.reporter.name?:issue.assignee.name ",
        "description": "",
        "modified": 1587603663296
    },
    {
        "id": "GreetMe",
        "key": "GreetMe",
        "code": "class GreetMe{\r\n String aString = \"Hello\"\r\n  String sayIt() {\r\n  return aString;\r\n\t} \r\n}",
        "description": "",
        "modified": 1575641794486
    },
    {
        "id": "ViewIssueClient",
        "key": "ViewIssueClient",
        "code": "import com.atlassian.jira.component.ComponentAccessor;\r\nstatic callingName(issue){\r\nreturn issue.get(\"summary\");\r\n}",
        "description": "",
        "modified": 1576652611759
    },
    {
        "id": "reportername1",
        "key": "reportername1",
        "code": "issue.get('reporter').displayName",
        "description": "Reporter Name",
        "modified": 1585278345351
    },
    {
        "id": "reportername4",
        "key": "reportername4",
        "code": "issue.get('reporter').displayName",
        "description": "Reporter Name",
        "modified": 1585278639464
    },
    {
        "id": "getReporter",
        "key": "getReporter",
        "code": "class DEF{\r\n  String getreporter(){\r\n    return issue.reporter.name\r\n  }\r\n}",
        "description": "Get Reporter",
        "modified": 1588918528088
    }
]

Deletes the specified shared script

Request

URL PARAMETERS

parameter

description

name

Name of the Shared Groovy script

jira-base-url

Jira base URL. For example http://localhost:8080

Responses

- application/json Returned if the shared scripts is deleted.

EXAMPLE

DELETE http://localhost:8080/rest/jmwe/1/shared-scripts/Functions

Creates a new shared script

Request

URL PARAMETERS

parameter

description

jira-base-url

Jira base URL. For example http://localhost:8080

Body

{
    "id": String,
    "key": String,
    "code": String,
    "description": String
}

Responses

- application/json Returned if the shared script is created.

EXAMPLE

POST http://192.168.5.102:8080/rest/jmwe/1/shared-scripts/

Body

{
    "id": "getReporter",
    "key": "getReporter",
    "code": "class DEF{\r\n  String getreporter(){\r\n    return issue.reporter.name\r\n  }\r\n}",
    "description": "Get Reporter"
}

Response

{
    "id": "getReporter",
    "key": "getReporter",
    "code": "class DEF{\r\n  String getreporter(){\r\n    return issue.reporter.name\r\n  }\r\n}",
    "description": "Get Reporter"
}

Updates the specified shared script

Request

URL PARAMETERS

parameter

description

name

Name of the Shared Groovy script

jira-base-url

Jira base URL. For example http://localhost:8080

Body

{
    "id": String,
    "key": String,
    "code": String,
    "description": String,
    "modified": Long
}

Responses

- application/json Returned if the shared script is successfully updated.

EXAMPLE

https://jira8-jira8-rvijji.media.innovalog.com/rest/jmwe/1/shared-scripts/getReporter

Body

{
   "id": "getReporter",
   "key": "getReporter",
   "code": "issue.get('reporter').displayName",
   "description": "Return Reporter Display Name",
   "modified": 1585278345351
}

Response

{
    "id": "getReporter",
    "key": "getReporter",
    "code": "issue.get('reporter').displayName",
    "description": "Return Reporter Display Name",
    "modified": 1585278345351
}

Import shared Groovy scripts.

Request

URL PARAMETERS

parameter

description

jira-base-url

Jira base URL. For example http://localhost:8080

QUERY PARAMETERS

parameter

type

description

replaceNewer

Boolean

To force override existing scripts even if the imported script is older or doesn't have a modified data, pass the value true. By default, existing scripts will only be replaced if the imported script is newer.

Body

[
  {
    "id": String,
    "key": String,
    "code": String,
    "description": String
  },
  {
   "id": String,
   "key": String,
   "code": String,
   "description": String
  }
]

Responses

- application/json Returned if the shared scripts are successfully created.

EXAMPLE 1

POST http://localhost:8080/rest/jmwe/1/shared-scripts/import

Body

[
   {
        "id": "Functions",
        "key": "Functions",
        "code": "issue.reporter.name?:issue.assignee.name",
        "description": "testing1"
    },
    {
        "id": "GreetMe",
        "key": "GreetMe",
        "code": "class GreetMe{\r\n String aString = \"Hello\"\r\n  String sayIt() {\r\n  return aString;\r\n\t} \r\n}",
        "description": "testing1"
    }
]

Response

{
    "GreetMe": "added",
    "Functions": "added"
}

EXAMPLE 2

POST http://localhost:8080/rest/jmwe/1/shared-scripts/import?replaceNewer=true

Body:

[
    {
        "id": "Functions",
        "key": "Functions",
        "code": "issue.reporter.displayName?:issue.assignee.displayName",
        "description": "testing"
    },
    {
        "id": "GreetMe",
        "key": "GreetMe",
        "code": "class GreetMe{\r\n String aString = \"Hello\"\r\n  String sayIt() {\r\n  return aString;\r\n\t} \r\n}",
        "description": "testing"
    }
]

Response

{
    "GreetMe": "replaced",
    "Functions": "replaced"
}