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

Associate workflow schema to project using Jelly Script

Khalid El Koundi April 11, 2012

I'm trying to create projects using Jelly and i need to associate these projects with a particular workflow Scheme.

I need help for using ComponentManager to make the association.

Thanks a lot

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Dieter
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 Leaders.
April 11, 2012
This shows how to get the WorkflowSchememManager using ComponentManager:: http://forums.atlassian.com/thread.jspa?threadID=19220
Khalid El Koundi April 12, 2012

Thanks for the answer but it's not helping

I need how to make a link between a project and the Scheme

When i use <core:invoke on="${workflowSchemeManager}" method="addSchemeToProject">

i get : No such accessible method: addSchemeToProject() on object: com.atlassian.jira.workflow.DefaultWorkflowSchemeManager

any idea ?

Dieter
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 Leaders.
April 12, 2012
Dieter
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 Leaders.
April 12, 2012
You still need to add the arguments project and scheme. This was left out in the original answer in thevold forum. The project object can be retrieved using projectManager.getProjectByKey (string argument project key) and the scheme object by workflowSchemeManager.getSchemeObject(string argument scheme name). The projectManager can be retrieved using the ComponentManager like the WorkflowSchemeManager
Dieter
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 Leaders.
April 12, 2012
Here is a working Jelly script that assigns workflow scheme myScheme to project with key MYPROJECT
&lt;JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log"&gt;

  &lt;!-- Grab managers. Do it using ComponentAccessor now which gives better compatibility in Jira 5! r --&gt;
  &lt;core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getWorkflowSchemeManager" var="workflowSchemeManager"/&gt;
  &lt;core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getProjectManager" var="projectManager"/&gt;


  &lt;!-- Get the project with key "MYPROJECT" using ProjectManager --&gt;
  &lt;core:invoke on="${projectManager}" method="getProjectObjByKey" var="project"&gt;
    &lt;core:arg type="java.lang.String" value="MYPROJECT"/&gt;
  &lt;/core:invoke&gt;
&lt;log:warn&gt;Project ${project} found&lt;/log:warn&gt;

  &lt;!-- Get the workflow scheme "myScheme" --&gt;
  &lt;core:invoke on="${workflowSchemeManager}" method="getSchemeObject" var="scheme"&gt;
    &lt;core:arg type="java.lang.String" value="myScheme"/&gt;
  &lt;/core:invoke&gt;
&lt;log:warn&gt;Scheme ${scheme} found&lt;/log:warn&gt;

  &lt;!-- Assign scheme to project --&gt;
  &lt;core:invoke on="${workflowSchemeManager}" method="addSchemeToProject" &gt;
    &lt;core:arg  value="${project}"/&gt;
    &lt;core:arg  value="${scheme}" /&gt;
  &lt;/core:invoke&gt;


&lt;/JiraJelly&gt;

Khalid El Koundi April 12, 2012

Thanks a lot

looks like i was using the wrong accessors. Its's working fine

0 votes
Bruno Pirrotta June 5, 2014

You're project key has to be UPERCASE, if not, the Project object will not be found, and the Method addSchemeToProject works only with a project object valid !!

0 votes
Stefan Niedermann November 26, 2013

I tried like in the first answer, but i only get an exception.

we are using jira 5.1.8

&lt;!--
Erstellt Projektpools

@author stnieder
--&gt;
&lt;JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:sql="jelly:sql" xmlns:core="jelly:core" xmlns:log="jelly:log"&gt;
	&lt;log:info&gt;START :: SEP_JIRA_CreateProject-unit-jelly.xml | $Rev$ | $Author$ | $Date$&lt;/log:info&gt;
	
	&lt;core:set var="jiraUser"                 value="xxxx" /&gt;
	&lt;core:set var="jiraPassword"             value="xxxx" /&gt;
	
	&lt;core:set var="projectKey"               value="Test" /&gt;
	&lt;core:set var="projectName"              value="Test Pool von Jellys erstellt" /&gt;
	&lt;core:set var="projectLeader"            value="stnieder" /&gt;
	
	&lt;core:set var="projectWorkflowScheme"    value="15200" /&gt;

	&lt;jira:Login username="${jiraUser}" password="${jiraPassword}"&gt;
	
		&lt;!-- Projektpool erstellen
		&lt;jira:CreateProject key="${projectKey}" name="${projectName}" lead="${projectLeader}"&gt;
		
		&lt;/jira:CreateProject&gt; --&gt;
		
		&lt;!-- Workflow-Schema zuweisen --&gt;
		 &lt;!-- Grab managers. Do it using ComponentAccessor now which gives better compatibility in Jira 5! r --&gt;
		&lt;core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getWorkflowSchemeManager" var="workflowSchemeManager"/&gt;
		&lt;core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getProjectManager" var="projectManager"/&gt;


		&lt;!-- Get the project with key "MYPROJECT" using ProjectManager --&gt;
		&lt;core:invoke on="${projectManager}" method="getProjectObjByKey" var="project"&gt;
			&lt;core:arg type="java.lang.String" value="${projectKey}"/&gt;
		&lt;/core:invoke&gt;
		Project ${project} found

		&lt;!-- Get the workflow scheme "myScheme" --&gt;
		&lt;core:invoke on="${workflowSchemeManager}" method="getSchemeObject" var="scheme"&gt;
			&lt;core:arg type="java.lang.String" value="15200"/&gt;
		&lt;/core:invoke&gt;
		Scheme ${scheme} found

		&lt;!-- Assign scheme to project --&gt;
		&lt;core:invoke on="${workflowSchemeManager}" method="addSchemeToProject" &gt;
			&lt;core:arg value="${project}"/&gt;
			&lt;core:arg value="${scheme}" /&gt;
		&lt;/core:invoke&gt;
		
	&lt;/jira:Login&gt;
	
	&lt;log:info&gt;STOP :: SEP_JIRA_CreateProject-unit-jelly.xml&lt;/log:info&gt;
&lt;/JiraJelly&gt;

Skript konnte nicht ausgeführt werden.

Extra Information: [hide]

Error: <JiraJelly xmlns:sql="jelly:sql" xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log"> Project found Scheme found
Exception: org.apache.commons.jelly.JellyTagException: null:44:0: No such accessible method: addSchemeToProject() on object: com.atlassian.jira.workflow.DefaultWorkflowSchemeManager
java.io.PrintWriter@41787bbc

TAGS
AUG Leaders

Atlassian Community Events