I tried below code but getting below errors:
import com.atlassian.jira.bc.project.ProjectService
import com.atlassian.jira.bc.project.ProjectService.CreateProjectValidationResult
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.ProjectInputParameters
// Services and managers
def projectService = ComponentAccessor.getComponent(ProjectService)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Define project details
def projectKey = "SAMP" // Must be unique
def projectName = "Sample Project"
def projectLead = "jiraadmin" // Username of the project lead
def projectTypeKey = "software" // e.g., software, business, service_desk
def projectTemplateKey = "com.pyxis.greenhopper.jira:basic-software-development-template"
// Create input parameters
ProjectInputParameters params = projectService.newProjectInputParameters()
params
.setKey(projectKey)
.setName(projectName)
.setLead(projectLead)
.setProjectTypeKey(projectTypeKey)
.setDescription("This project was created by ScriptRunner automation.")
.setAssigneeType(ProjectInputParameters.AssigneeType.PROJECT_LEAD)
// Validate
CreateProjectValidationResult validationResult = projectService.validateCreateProject(user, params)
if (validationResult.isValid()) {
def result = projectService.createProject(validationResult)
if (result.isValid()) {
return "✅ Project created successfully: ${result.project.key}"
} else {
return "❌ Failed: " + result.errorCollection
}
} else {
return "❌ Validation failed: " + validationResult.errorCollection
}
Errors are :The script could not be compiled: <pre>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script57.groovy: 4: unable to resolve class com.atlassian.jira.project.ProjectInputParameters @ line 4, column 1. import com.atlassian.jira.project.ProjectInputParameters ^ 1 error </pre>.
Tried another script but still getting same error :
No signature of method: com.atlassian.jira.bc.project.DefaultProjectService.newProjectInputParameters() is applicable for argument types: () values: []
Welcome to the community.
Check this article from the scriptrunner documentation https://www.scriptrunnerhq.com/help/example-scripts/basics-create-project-onPrem
Otherwise reach out to their support for further input and help.
Other solution is to use the API, see https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/project-createProject
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.