Created
May 1, 2021 13:38
-
-
Save vikrantyadav11/d66a5cf60d4b03cdd2ee97c592dffbe2 to your computer and use it in GitHub Desktop.
Create new jira issue using script runner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.atlassian.jira.component.ComponentAccessor | |
| def issueService = ComponentAccessor.issueService | |
| def projectManager = ComponentAccessor.projectManager | |
| def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() | |
| def requestTypeValue = "Submit Form 1362" //replace it with the one you want - see note below | |
| def constantsManager = ComponentAccessor.getConstantsManager() | |
| def issueType = constantsManager.getAllIssueTypeObjects().find {it.name.equalsIgnoreCase("New Project Request")} | |
| def issueInputParameters = issueService.newIssueInputParameters() | |
| def customFiledmanager = ComponentAccessor.getCustomFieldManager() | |
| def cf = customFiledmanager.getCustomFieldObjectByName("CA Ticket#") | |
| issueInputParameters.with { | |
| projectId = projectManager.getProjectObjByKey("CJS").id | |
| summary = "Issue created from script" | |
| issueTypeId = issueType.getId() | |
| reporterId = "vikrant-yadav2" | |
| assigneeId = "vikrant-yadav2" | |
| } | |
| issueInputParameters.addCustomFieldValue(cf.idAsLong, requestTypeValue) | |
| def validationResult = issueService.validateCreate(user, issueInputParameters) | |
| assert !validationResult.errorCollection.hasAnyErrors() | |
| def issueResult = issueService.create(user, validationResult) | |
| assert !issueResult.errorCollection.hasAnyErrors() | |
| return "Issue created: ${issueResult.issue}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment