Hi guys,
In Jira workflow how do link status/steps to a transition?
What i have now:
- created work flow
- I created the step
Workflow.createWorkflowStep("Awaiting Approval", steps_id);
- createtd the status
Workflow.createWorkflowStatus("Awaiting Approval", "status for awaiting approval", this.statusManager);
- create transition
Workflow.createWorkflowTransition("InProgress_to_awaiting_approval", transition_id);
So now how do you link the steps to each other using transition
E.g A -- > B --> C
Community moderators have prevented the ability to post new answers.
Hi Guys,
I found a much easier way to do the custom work flow for you plugin.
1. Create a workflow in jira
2. Save it as .jwb file
3. Copy it into your plugin
4. create .json script
5 And hook the .jwb file to your plugin
{ "issue-type-scheme": { "name": "my.project.template.issuetype.scheme.name", "description": "my.project.template.issuetype.scheme.description", "issue-types": [ { "key": "issueType1", "name": "issue type", "description": "A has been made, which has yet to be developed.", "icon": "/images/icons/newfeature.png", "workflow": "wf2" } ] }, "workflow-scheme": { "name": "my.project.template.workflow.scheme.name", "description": "Workflow scheme used by the Workflow", "default-workflow": "wf2", "workflows": [ { "key": "wf2", "name": "my.project.template.workflow.wf2.name", "workflow-bundle": "/wfb/Workflow.jwb" } ] } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
After converting xml to descriptor we get WorkflowDescriptor. Using below code I am able to add the status which solved the problem of creating workflow and associating statuses with this.
workflowDescriptor = WorkflowUtil.convertXMLtoWorkflowDescriptor(myWorkflow); List<StepDescriptor> stepDescriptor = workflowDescriptor.getSteps(); for(StepDescriptor sd: stepDescriptor) { Status status = statusManager.createStatus(sd.getName(), sd.getName(), "/images/icons/statuses/xyz.png"); Map newStatus = new HashMap(); newStatus.put("jira.status.id", status.getId()); sd.setMetaAttributes(newStatus); } Similarly we can add the screens as well. Thanks, Vikash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was trying to create workflows programatically, but then I found out, how complicated the structure is. So basically the easiest approach is to use already generated workflow and save it as XML, then using following code to import it. Jira-Core dependency is necessary.
WorkflowDescriptor wf = WorkflowUtil.convertXMLtoWorkflowDescriptor(xml); JiraWorkflow w = new ConfigurableJiraWorkflow("JRMP Default Workflow", wf, ComponentAccessor.getWorkflowManager()); ApplicationUser user = getJiraServiceContext().getLoggedInApplicationUser(); if(ComponentAccessor.getWorkflowManager().workflowExists(w.getName())){ ComponentAccessor.getWorkflowManager().updateWorkflow(user, w); }else{ ComponentAccessor.getWorkflowManager().createWorkflow(user, w); }
Otherwise you can use DescriptorFactory and try to fill the data yourself....
WorkflowDescriptor wf = DescriptorFactory.getFactory().createWorkflowDescriptor();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fhatu,
please take a look to WOrkflowManager API https://docs.atlassian.com/jira/6.2.1/com/atlassian/jira/workflow/WorkflowManager.html
All you need can be retrieved there.
Regards,
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fabio,
The API you are referring to doesn't have details on how to associate status/ transistion. Mostly the methods are getXXXX()
Do you know where we can we achieve the above?
Regards
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Im using the same API do edit the transition but it does not work
String workFlowName = newProject.getKey() + ": Quote Workflow"; JiraWorkflow quoteWorkFlow = ComponentAccessor.getWorkflowManager().getWorkflow(workFlowName); Collection<ActionDescriptor> allTransition = quoteWorkFlow.getAllActions(); String transitionName = "Awaiting Client Feedback"; String screenName = QuoteConstants.QUOTE_CLIENTFEEDBACK_SCREEN; for(ActionDescriptor transition : allTransition){ if(transitionName.equals(transition.getName())){ transition.setView(screenName); ComponentAccessor.getWorkflowManager().updateWorkflow(ComponentAccessor.getWorkflowManager().getWorkflow(workFlowName).getUpdateAuthor(), quoteWorkFlow); } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fhatu,
Thanks for the API. We will try and let you know if we have any success.
Regards
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please give more "complete" code example - what is this Workflow class ? Whare are you executing this code ? From a plugin ? or this is REST api ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Look at the com.opensymphony.workflow.loader.WorkflowDescriptor API
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.