-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateProject.groovy
39 lines (31 loc) · 1.32 KB
/
createProject.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import com.atlassian.jira.bc.project.ProjectCreationData
import com.atlassian.jira.bc.project.ProjectService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.AssigneeTypes
import com.atlassian.jira.project.type.ProjectTypeKey
def projectKey = "HR"
def projectName = "Business Core HR"
def projectDescription = "Business Core Project"
def projectUrl = "https://www.ravisagar.in"
def projectService = ComponentAccessor.getComponent(ProjectService)
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def projectTypeKey = new ProjectTypeKey("business")
def projectCreationData = new ProjectCreationData.Builder().with {
withName(projectName)
withKey(projectKey)
withDescription(projectDescription)
withLead(loggedInUser)
withUrl(projectUrl)
withAssigneeType(AssigneeTypes.PROJECT_LEAD)
withType(projectTypeKey)
}.build()
ProjectService.CreateProjectValidationResult createProjectValidationResult =
projectService.validateCreateProject(
loggedInUser,
projectCreationData)
if(!createProjectValidationResult.getErrorCollection().errors)
{
projectService.createProject(createProjectValidationResult)
} else {
return ("Project cannot be created ${createProjectValidationResult.getErrorCollection().errors}" )
}