Jira (8.0 - 8.14)
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
// the key for the new project
final String projectKey = "AAA"
// the name of the new project
final String projectName = "A new Project"
// the description for the new project - optional
final String projectDescription = "project for testing"
def projectService = ComponentAccessor.getComponent(ProjectService)
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
// available project type keys: business | software | service_desk
def projectTypeKey = new ProjectTypeKey("business")
def creationData = new ProjectCreationData.Builder().with {
withName(projectName)
withKey(projectKey)
withDescription(projectDescription)
withLead(loggedInUser)
withUrl(null)
withAssigneeType(AssigneeTypes.PROJECT_LEAD)
withType(projectTypeKey)
}.build()
final ProjectService.CreateProjectValidationResult projectValidationResult = projectService.validateCreateProject(loggedInUser, creationData)
assert projectValidationResult.isValid() : projectValidationResult.errorCollection
projectService.createProject(projectValidationResult)