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
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.