├── .idea
├── .gitignore
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── ScriptRunner-Scripts.iml
├── bamboo_server
└── README.md
├── bitbucket_server
└── README.md
├── confluence_server
└── README.md
├── jira_cloud
├── #createProject.groovy#
├── addWorklog.groovy
├── commentOnLinkedIssues.groovy
├── createIssue.groovy
├── createIssueLink.groovy
├── createLinkedIssue.groovy
├── createProject.groovy
├── deleteIssuesBulk.groovy
├── getIssue.groovy
├── getIssueLinks.groovy
├── getIssueTypes.groovy
├── getProjectList.groovy
├── lastComment.groovy
├── parseJqlResults.groovy
└── searchJQL.groovy
└── jira_server
├── #createIssue.groovy#
├── activateDeactivateUser.groovy
├── addUserToGroup.groovy
├── baseurl.groovy
├── behaviour-mandatory-issue-links.groovy
├── behaviour-set-original-estimate-based-on-priority.groovy
├── behaviourCommentRequiredTransitionScreen.groovy
├── cascadeReadOnly.groovy
├── concatenateIssueSummaryAndCreatedDate.groovy
├── copyCommentsLinkedIssues.groovy
├── countCustomFieldValues.groovy
├── createCommentLinkedIssues.groovy
├── createGroup.groovy
├── createIssue.groovy
├── createIssueType.groovy
├── createProject.groovy
├── createProjectComponent.groovy
├── createSubTask.groovy
├── createVersion.groovy
├── deleteIssue.groovy
├── deleteProjects.groovy
├── divideNumbersWSJF.groovy
├── dynamicFormsUserPicker.groovy
├── getAllChangeItems.groovy
├── getAllIssueTypeSchemes.groovy
├── getAllProjectPermissions.groovy
├── getArchivedProjects.groovy
├── getAssignToFirstAssignee.groovy
├── getChangeItemsForField.groovy
├── getCustomFieldObjectByName.groovy
├── getCustomFieldObjectsByName_userPicker.groovy
├── getFieldsOnScreens.groovy
├── getIssue.groovy
├── getIssueLinks.groovy
├── getMultiSelectCustomFieldValue.groovy
├── getPrioritySchemes.groovy
├── getProjects.groovy
├── getProjectsFromIssueTypes.groovy
├── getProjectsFromProjectCategory
├── getSprintState.groovy
├── getSubTaskObjects.groovy
├── getTimeSpent.groovy
├── getVoters.groovy
├── getWatchers.groovy
├── getWorkflowDetails.groovy
├── getWorkflows.groovy
├── hasAssociatedIssues.groovy
├── hideCustomFieldBasedOnCascadeSelectList.groovy
├── jqlParser.groovy
├── lastComment.groovy
├── listAllProjects.groovy
├── numberOfComments.groovy
├── postFunctionConditionSelectListMultipleChoice.groovy
├── postFunctionModifySummaryOnCreate.groovy
├── postFunctionUpdateMessageField.groovy
├── postFunctionUpdateProjectRoleFromUserPickerField.groovy
├── postFunction_addWatcher.groovy
├── projectRename.groovy
├── readCSVFile.groovy
├── removeAllChangeItems.groovy
├── removeUser.groovy
├── removeUserFromGroup.groovy
├── runSQL.groovy
├── runSelectQueryDatabase.groovy
├── sendEmail.groovy
├── setSecurityLevel.groovy
├── systemCommands.groovy
├── transitionIssue.groovy
├── updateSingleSelectList.groovy
├── updateValue.groovy
├── userList.groovy
└── workflowCondition_checkSelectListValue.groovy
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Introduction
2 | This is a repository of some useful groovy scripts to make your life easier. There would be script on all applications supported by ScriptRunner. Of course you need ScriptRunner.
3 |
4 | The ScriptRunner for Jira video tutorials can be found here: https://go.ravi.pro/ScriptRunnerJira
5 |
6 | Enjoy and no need to say thanks :)
7 |
8 | ## Social
9 | 1. Blog: https://www.ravisagar.in
10 | 2. Linkedin: https://www.linkedin.com/in/ravisagar/
11 | 3. Twitter: https://www.twitter.com/ravisagar
12 | 4. Instagram: https://www.instagram.com/ravisagar.in
13 |
14 | ## Sponsor
15 | [Sparxsys Solutions](https://www.sparxsys.com)
16 | An Atlassian and Drupal Consultancy company in London and Delhi. They provide [ScriptRunner for Jira services](https://www.sparxsys.com/services/atlassian-consultancy/scriptrunner-jira)
17 |
--------------------------------------------------------------------------------
/ScriptRunner-Scripts.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/bamboo_server/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sparxsys/ScriptRunner-Scripts/d20d640d461f66ef2ea2a5df6557792527c071e0/bamboo_server/README.md
--------------------------------------------------------------------------------
/bitbucket_server/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sparxsys/ScriptRunner-Scripts/d20d640d461f66ef2ea2a5df6557792527c071e0/bitbucket_server/README.md
--------------------------------------------------------------------------------
/confluence_server/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sparxsys/ScriptRunner-Scripts/d20d640d461f66ef2ea2a5df6557792527c071e0/confluence_server/README.md
--------------------------------------------------------------------------------
/jira_cloud/#createProject.groovy#:
--------------------------------------------------------------------------------
1 | def resp = post('/rest/api/3/project')
2 | .header('Content-Type', 'application/json')
3 | .body(
4 | [
5 | key: "PROJXYZZ",
6 | name: "PROJXYZZ",
7 | projectTypeKey: "business",
8 | projectTemplateKey: "com.atlassian.jira-core-project-templates:jira-core-project-management",
9 | description: "Rest demo project",
10 | leadAccountId: "557058:f2a3043a-ebcb-4815-9277-e0e14c4d9776",
11 | url: "http://www.ravisagar.in",
12 | assigneeType: "PROJECT_LEAD",
13 | avatarId: 10200,
14 | notificationScheme: 10007
15 | ]
16 |
17 |
18 | )
19 | .asString().body
20 |
21 | return resp
22 |
23 |
--------------------------------------------------------------------------------
/jira_cloud/addWorklog.groovy:
--------------------------------------------------------------------------------
1 | post('/rest/api/3/issue/bt-2/worklog')
2 | .header('Content-Type', 'application/json')
3 | .body(
4 | [
5 | timeSpent: "20m",
6 | comment: [
7 | type: "doc",
8 | version: 1,
9 | content: [
10 | [
11 | type: "paragraph",
12 | content: [
13 | [
14 | text: "This is from SR4J on Cloud.",
15 | type: "text"
16 | ]
17 | ]
18 | ]
19 | ]
20 | ]
21 |
22 | ])
23 | .asString().body
24 |
--------------------------------------------------------------------------------
/jira_cloud/commentOnLinkedIssues.groovy:
--------------------------------------------------------------------------------
1 | def issueKey = issue.key
2 |
3 | def response = get('/rest/api/3/issue/'+issueKey)
4 | .header('Content-Type', 'application/json')
5 | .asObject(Map)
6 |
7 | logger.info("Issue id: " + response.body.id)
8 | logger.info("Priority name: "+ response.body.fields.priority.name)
9 | logger.info("Inward issue links: "+ response.body.fields.issuelinks*.inwardIssue.key)
10 | logger.info("Outward issue links: "+ response.body.fields.issuelinks*.outwardIssue.key)
11 |
12 | response.body.fields.issuelinks.each { it->
13 |
14 | if(it.inwardIssue) {
15 | logger.info("Inward issue: "+ it.inwardIssue.key)
16 | //add a comment
17 | addComment(issueKey, it.inwardIssue.key)
18 | } else if (it.outwardIssue) {
19 | logger.info("Outward issue: "+ it.outwardIssue.key)
20 | //add a comment
21 | }
22 |
23 | }
24 |
25 | def addComment(orginalIssue, linkedIssue) {
26 |
27 |
28 | def comment = orginalIssue + ' issue moved to on Hold'
29 |
30 | def result = post("/rest/api/2/issue/${linkedIssue}/comment")
31 | .header('Content-Type', 'application/json')
32 | .body([
33 | body: comment
34 | ])
35 | .asString()
36 |
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/jira_cloud/createIssue.groovy:
--------------------------------------------------------------------------------
1 | //ScriptRunner for Jira on Cloud - Create an Issue
2 | def resp = post("/rest/api/3/issue")
3 | .header("Content-Type", "application/json")
4 | .body(
5 | fields: [
6 | summary: "New issue from SR4J on cloud :)",
7 | issuetype: [
8 | id: 10001
9 | ],
10 | project: [
11 | id: 10024
12 | ]
13 | ])
14 | .asObject(Map)
15 |
16 |
17 | // If the task created successfully return a success message along with its key
18 | if (resp.status == 201) {
19 | return 'Success - Created with the key of ' + resp.body.key.toString()
20 | } else {
21 | return "${resp.status}: ${resp.body}"
22 | }
--------------------------------------------------------------------------------
/jira_cloud/createIssueLink.groovy:
--------------------------------------------------------------------------------
1 | //Bt-5 blocks Bt-2 >> Outward link
2 | //Bt-2 blocked by Bt-5 >> Inward link
3 |
4 | post('/rest/api/3/issueLink')
5 | .header('Content-Type', 'application/json')
6 | .body(
7 |
8 | [
9 | outwardIssue: [
10 | key: "bt-2"
11 | ],
12 |
13 | inwardIssue: [
14 | key: "bt-5"
15 | ],
16 | type: [
17 | name: "Blocks"
18 | ]
19 | ]
20 |
21 |
22 | )
23 | .asString().body
24 |
25 |
26 |
--------------------------------------------------------------------------------
/jira_cloud/createLinkedIssue.groovy:
--------------------------------------------------------------------------------
1 | //ScriptRunner for Jira on Cloud - Create an Issue
2 | def resp = post("/rest/api/3/issue")
3 | .header("Content-Type", "application/json")
4 | .body(
5 | fields: [
6 | summary: "Issue created from On Hold transition post function",
7 | issuetype: [
8 | id: 10009
9 | ],
10 | project: [
11 | id: 10037
12 | ]
13 | ])
14 | .asObject(Map)
15 |
16 |
17 | // If the task created successfully return a success message along with its key
18 | if (resp.status == 201) {
19 | logger.info( "Success - Created with the key of " + resp.body.key.toString() )
20 |
21 | createIssueLink(issue.key, resp.body.key.toString())
22 |
23 | } else {
24 | logger.info( "${resp.status}: ${resp.body}" )
25 | }
26 |
27 |
28 | def createIssueLink(outwardIssueKey, inwardIssueKey) {
29 |
30 | post('/rest/api/3/issueLink')
31 | .header('Content-Type', 'application/json')
32 | .body(
33 |
34 | [
35 | outwardIssue: [
36 | key: outwardIssueKey
37 | ],
38 |
39 | inwardIssue: [
40 | key: inwardIssueKey
41 | ],
42 | type: [
43 | name: "Blocks"
44 | ]
45 | ]
46 |
47 |
48 | )
49 | .asString().body
50 |
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/jira_cloud/createProject.groovy:
--------------------------------------------------------------------------------
1 | def resp = post('/rest/api/3/project')
2 | .header('Content-Type', 'application/json')
3 | .body(
4 | [
5 | key: "PROJXYZZ",
6 | name: "PROJXYZZ",
7 | projectTypeKey: "business",
8 | projectTemplateKey: "com.atlassian.jira-core-project-templates:jira-core-project-management",
9 | description: "Rest demo project",
10 | leadAccountId: "557058:f2a3043a-ebcb-4815-9277-e0e14c4d9776",
11 | url: "http://www.ravisagar.in",
12 | assigneeType: "PROJECT_LEAD",
13 | avatarId: 10200,
14 | notificationScheme: 10007
15 | ]
16 |
17 |
18 | )
19 | .asString().body
20 |
21 | return resp
22 |
--------------------------------------------------------------------------------
/jira_cloud/deleteIssuesBulk.groovy:
--------------------------------------------------------------------------------
1 | def response = get('/rest/api/2/search?jql=filter=10047')
2 | .header('Content-Type', 'application/json')
3 | .asObject(Map)
4 |
5 | response.body.issues.each { it ->
6 |
7 | getIssueDetails(it)
8 |
9 | }
10 |
11 | def getIssueDetails(issue) {
12 |
13 | logger.info("Issue Key: " + issue.key +", "+ issue.fields.priority.name + ", " + issue.fields.status.name)
14 |
15 | //Delete the issues with a specific status
16 | if (issue.fields.status.name == "To Do" ) {
17 | deleteIssue(issue.key)
18 | }
19 | }
20 |
21 |
22 | def deleteIssue(issueKey) {
23 |
24 | logger.info("Issue to be deleted: " + issueKey)
25 |
26 | def responseDelete = delete('/rest/api/3/issue/'+issueKey+'?deleteSubtasks=true')
27 | .header('Content-Type', 'application/json')
28 | .asObject(Map)
29 |
30 | if(responseDelete.status==403) {
31 |
32 | logger.info("Error: " + responseDelete.body.errorMessages)
33 |
34 | }
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/jira_cloud/getIssue.groovy:
--------------------------------------------------------------------------------
1 | def response = get('/rest/api/3/issue/cts-12')
2 | .header('Content-Type', 'application/json')
3 | .asObject(Map)
4 |
5 | logger.info("Issue id: " + response.body.id)
6 | logger.info("Priority name: "+ response.body.fields.priority.name)
7 |
8 | return response.body
9 |
--------------------------------------------------------------------------------
/jira_cloud/getIssueLinks.groovy:
--------------------------------------------------------------------------------
1 | def response = get('/rest/api/3/issue/AN-4')
2 | .header('Content-Type', 'application/json')
3 | .asObject(Map)
4 |
5 | logger.info("Issue id: " + response.body.id)
6 | logger.info("Priority name: "+ response.body.fields.priority.name)
7 | logger.info("Inward issue links: "+ response.body.fields.issuelinks*.inwardIssue.key)
8 | logger.info("Outward issue links: "+ response.body.fields.issuelinks*.outwardIssue.key)
9 |
10 | return response.body
11 |
--------------------------------------------------------------------------------
/jira_cloud/getIssueTypes.groovy:
--------------------------------------------------------------------------------
1 | def responseIssueTypes = get("/rest/api/3/issuetype").asObject(List)
2 |
3 | def issueTypes = responseIssueTypes.body as List