Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Copy Project Template with Java API

Hi! 

I have created a Groovy Script to copy a project template in Jira Software Server with a Scriptrunner Postfunction. When I execute this script in Script Console everything works fine but when using it in the Postfunction it often happens that no permission scheme is assigned to the newly created project. Because of that lots a further issues occur. 

The only thing in the Log what I can find is this here:

2020-04-16 09:42:28,380 WARN [permission.DefaultPermissionSchemeManager]: No permission scheme is associated with project 'ABCD 1234'

 

This is the script what I have written to copy the project:

// Get Project Template
jiraAuthenticationContext.setLoggedInUser(adminUser)
def projectManager = ComponentAccessor.getProjectManager()
def projectTemplate = projectManager.getProjectObjByKey(tplKeyJira)

writeLog.info("Key: " + prjKey + ", Name: " + prjName + ", Template Jira: " + tplKeyJira + ", Template Wiki: " + tplKeyWiki)


// Create new Jira Project
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def projectService = ComponentAccessor.getComponent(ProjectService)

// Copy Project Template
Builder newProjectCreationDataBuilder = new Builder()
newProjectCreationDataBuilder.withKey(prjKey)
newProjectCreationDataBuilder.withName(prjName)
newProjectCreationDataBuilder.withLead(projectManagerValue)
newProjectCreationDataBuilder.build()
def newProjectCreationData = newProjectCreationDataBuilder.build()

Builder templateProjectCreationDataBuilder = new Builder()
templateProjectCreationDataBuilder.fromExistingProject(projectTemplate, newProjectCreationData)
def templateProjectCreationData = templateProjectCreationDataBuilder.build()

def projectValidateCreateResult = projectService.validateCreateProjectBasedOnExistingProject(adminUser, projectTemplate.getId(), templateProjectCreationData)
log.info("Create Project Validation - User: ${projectValidateCreateResult.getUser()}, Is Valid: ${projectValidateCreateResult.isValid()}")
log.warn("Warnings: ${projectValidateCreateResult.getWarningCollection().getWarnings()}")
log.error("Errors: ${projectValidateCreateResult.getErrorCollection()..getErrors()}")


Project createdProject
if (projectValidateCreateResult.isValid()){
createdProject = projectService.createProject(projectValidateCreateResult)
} else {
log.error(projectValidateCreateResult.errorCollection.getErrors())
throw new Exception(projectValidateCreateResult.errorCollection.getErrors().toString())
}

 

Does anybody has an idea why the permission scheme sometimes cannot be assigned? For me it would be logically if it would always does the same and not just sometimes...

 

Thanks and best regards

Andreas

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Bitbucket Smart Commits vs. Genius Commits - What's the difference?

If you already heard about Smart Commits in Bitbucket, know that you just stumbled upon something even better (and smarter!): Genius Commits by Better DevOps Automation for Jira Data Center (+ Server...

106 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you