Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 19 Current »

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

 Get 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 200 - application/json Returned if the shared script is found.

STATUS 401 - Unauthorized

STATUS 404 - 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
}
 Get 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 200 - application/json Returned if the shared scripts are found.

STATUS 401 - Unauthorized

STATUS 404 - 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
    }
]

 Delete 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 200 - application/json Returned if the shared scripts is deleted.

EXAMPLE

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

 Create 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

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

Responses

STATUS 201 - 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"
}
 Update 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

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

Responses

STATUS 200 - 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 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 force override existing scripts even if the imported script is older or doesn't have a modified data, pass the value true.

Body

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

Responses

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

EXAMPLE

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

Body

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

Response

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

Example using replaceNewer parameter

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

Body

[
	{
		"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",
		"key": "accessJMCFField",
		"code": "issue.get(\"customfield_11303\")",
		"description": "Access JMCF custom field",
		"modified": 1585119864204
	},
	{
        "id": "MyClass2",
        "key": "MyClass2",
        "code": "class TextCompare{\r\n  String getText(){\r\n    return \"Testing\"\r\n  }\r\n}\r\n\r\nstatic String compareT(){\r\n  return new TextCompare().getText()\r\n}",
        "description": "Verify the Text Field value and apply run the code (description update by force overriding)"
    }
]

Response

 
  • No labels