The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automated project creation

Rajiv Cj
August 9, 2018

Hello,

We are trying to automate the process of creating a jira project. We are able to create the project using REST APIs. But we have a requirement to change the default workflow name and its workflow scheme.

We have found success with some Java APIs, we are able to clone the workflow associated to the project and we have successfully renames it to what we need.

The issue is with updating the workflow scheme. We have also successfully copied the workflow scheme using similar Java APIs.  Now we are trying to associate the copied workflow to the copied workflow scheme.

Please let me explain in detail.

 

1) Creation of project

========================

 def jiraProjectCreationOutput=rch.postRequest(jiraApiBaseUrl,"project",
    [
      "key":CF_key,
      "name": CF_name,
      "projectTypeKey": "software",
      "projectTemplateKey":"com.pyxis.greenhopper.jira:gh-scrum-template",
      "description": "scrum-template",
      "lead": arh.getRequesterUsername(),
      "assigneeType": "PROJECT_LEAD"
      ]
      ,jiraUserName,jiraPassword)
      log.error("jiraProjectCreationOutput:"+jiraProjectCreationOutput);
      log.error("ProjectId:"+jiraProjectCreationOutput.data.id)
      def projectId=jiraProjectCreationOutput.data.id;

==========================

2) Copy workflow

==========================

def workflow= ComponentAccessor.workflowManager.getWorkflowClone("Software Simplified Workflow for Project "+CF_key)
def workflows= ComponentAccessor.workflowManager.copyWorkflow("admin","["+CF_key+"]-Software Simplified Workflow for Project","des",workflow)

==========================

3) Copy workflow schem

==========================

def scheme=ComponentAccessor.workflowSchemeManager.getSchemesForWorkflow(workflow);
def copiedSchme=ComponentAccessor.workflowSchemeManager.copyScheme(scheme);
def copiedSchemeId=copiedSchme.id;

==========================

4) update workflow scheme

==========================

 def renameWorkflowoutput=rch.putRequest(jiraApiBaseUrl,path,
[   "name": workflowSchemeName,
    "defaultWorkflow":workFlowName ,
    "updateDraftIfNeeded": false

],jiraUserName,jiraPassword)

=========================

 

Questions:

1) In step 3, we are able to copy the scheme and then there is the REST call to update the scheme with the copied workflow. But the REST call throws an error saying "The workflow scheme does not exist."  This call to the REST API happen right after step3. So we are assuming the Java API runs asynchronously and the REST api in step 4 is triggered before copy task (step3) is complete. So is there a way to use the java api with "promise" so that we can use the call back to trigger step 4?

2) It would be great if you could help us with some suggestion on this

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Anton Chemlev - Toolstrek -
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 10, 2018

Hi,

I experienced such a behaviour dealing with ChangeItems in event listeners. Sometimes it worked fine, sometimes i was given an error. Reason - JVM thread management.

You can do a dirty hack - sleep and check in cycle. And then call REST.

Or maybe CompletableFuture can help you, but i haven't explored it yet.

TAGS
AUG Leaders

Atlassian Community Events