Versions Compared

Key

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

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.

...

Expand
titleGet a Shared script GET <jira-base-url>/rest/jmwe/1/shared-scripts/<name>

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

Status
colourGreen
titleSTATUS 200
- application/json Returned if the shared script is found.

Status
colourRed
titleSTATUS 401
- Unauthorized

Status
colourRed
titleSTATUS 404
- Not found

EXAMPLE

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

Response

Code Block
{
    "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
}
Expand
titleGet all shared scripts GET <jira-base-url>/rest/jmwe/1/shared-scripts

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

Status
colourGreen
titleSTATUS 200
- application/json Returned if the shared scripts are found.

Status
colourRed
titleSTATUS 401
- Unauthorized

Status
colourRed
titleSTATUS 404
- Not found

EXAMPLE

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

Response:

Code Block
[
    {
        "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
    }
]

Expand
titleDelete a shared script DELETE <jira-base-url>/rest/jmwe/1/shared-scripts/<name>

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

Status
colourGreen
titleSTATUS 200
- application/json Returned if the shared scripts is deleted.

EXAMPLE

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

Expand
titleCreate a new shared script POST <jira-base-url>/rest/jmwe/1/shared-scripts

Creates a new shared script

Request

URL PARAMETERS

parameter

description

jira-base-url

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

Body

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

Responses

Status
colourGreen
titleSTATUS 201
- application/json Returned if the shared script is created.

EXAMPLE

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

Body

Code Block
{
    "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

Code Block
{
    "id": "getReporter",
    "key": "getReporter",
    "code": "class DEF{\r\n  String getreporter(){\r\n    return issue.reporter.name\r\n  }\r\n}",
    "description": "Get Reporter"
}
Expand
titleUpdate a shared script PUT <jira-base-url>/rest/jmwe/1/shared-scripts/<name>

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

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

Responses

Status
colourGreen
titleSTATUS 200
- application/json Returned if the shared script is successfully updated.

EXAMPLE

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

Body

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

Response

Code Block
{
    "id": "getReporter",
    "key": "getReporter",
    "code": "issue.get('reporter').displayName",
    "description": "Return Reporter Display Name",
    "modified": 1585278345351
}
Expand
titleImport scripts POST <jira-base-url>/rest/jmwe/1/shared-scripts/import

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

By default, existing scripts will only be replaced if the imported script is newer. To 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

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

Responses

Status
colourGreen
titleSTATUS 200
- application/json Returned if the shared scripts are successfully created.

EXAMPLE 1

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

Body

Code Block
[
   {
        "id": "Functions",
        "key": "Functions",
        "code": "issue.reporter.name?:issue.assignee.name",
        "description": "testingtesting1"
 },   },
    {
        "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 description"testing1"
    }
]

Response

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

Example using replaceNewer parameterEXAMPLE 2

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

Body:

Code Block
[
	{
		    {
        "id": "ViewIssueClient",
		"key": "ViewIssueClient",
		"code": "import com.atlassian.jira.component.ComponentAccessor;\r\nstatic callingName(issue){\r\nreturn issue.get(\"summary\");\r\n}",
		"description": "Test",
		"modified": 1576652611759
	},
	{
		"id": "accessCustomfield",
		"key": "accessCustomfield",
		"code": "Accessing a custom field",
		"description": "Accessing a custom field",
		"modified": 1585132207989
	},
	{
		"id": "accessJMCFField",
		Functions",
        "key": "accessJMCFFieldFunctions",
		
        "code": "issue.reporter.displayName?:issue.assignee.get(\"customfield_11303\")",
		displayName",
        "description": "Access JMCF custom field",
		"modified": 1585119864204
	},
	testing"
    },
    {
        "id": "MyClass2GreetMe",
        "key": "MyClass2GreetMe",
        "code": "class TextCompareGreetMe{\r\n  String getText(){\r\n    return \"TestingaString = \"Hello\"\r\n  }\r\n}\r\n\r\nstatic String compareTsayIt() {\r\n  return new TextCompare().getText() aString;\r\n\t} \r\n}",
        "description": "testing"Verify
the Text Field value and apply run the code (description update by force overriding)"
    }
]

Response

code
}
]

Response

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