Hi
I have done the following script to set the component of an issue, which works because i check components at the end of the script and its right, however the script does not seem to persist or store the changed values of my MutableIssue, see below:
<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >
<jira:Login username="user.survey" password="$uRv3y">
<core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>
<core:invoke on="${componentManager}" method="getIssueManager" var="issueManager"/>
<!-- Get an instance of IssueObject -->
<core:invoke on="${issueManager}" method="getIssueObject" var="issueKey">
<core:arg type="java.lang.String" value="SUP-27096"/>
</core:invoke>
<core:invoke on="${componentManager}" method="getProjectComponentManager" var="projectComponentManager"/>
<core:invoke on="${projectComponentManager}" method="findByComponentName" var="projectComponent" >
<core:arg type="java.lang.Long" value="${issueKey.project.id}"/>
<core:arg type="java.lang.String" value="OPS"/>
</core:invoke>
<core:invoke on="${projectComponentManager}" method="convertToGenericValue" var="projectComponentGeneric" >
<core:arg type="com.atlassian.jira.bc.project.component.ProjectComponent" value="${projectComponent}"/>
</core:invoke>
<core:invoke on="${issueKey}" method="getComponents" var="components" />
<core:invoke on="${components}" method="add" var="flag">
<core:arg type="org.ofbiz.core.entity.GenericValue" value="${projectComponentGeneric}" />
</core:invoke>
<jira:AddComment comment="components ${components}" issue-key="SUP-27096"/>
<core:invoke on="${issueKey}" method="setComponents">
<core:arg type="java.util.Collection" value="${components}" />
</core:invoke>
</jira:Login>
</JiraJelly>
How do i persist this change?
Thanks in advance
Try this, Justin. I've run it on my development machine, and it did update the component of my sample issue.
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log"> <jira:LoadManager var="issueManager" manager="IssueManager"/> <jira:LoadManager var="projectManager" manager="ProjectManager"/> <core:invoke on="${issueManager}" method="getIssueObject" var="issue"> <core:arg type="java.lang.String" value="ABC-1"/> </core:invoke> <core:invoke on="${projectManager}" method="getComponent" var="projectComponent"> <core:arg type="java.lang.Long" value="10000"/> </core:invoke> <core:invoke on="${issue}" method="getComponents" var="components" /> <core:invoke on="${components}" method="add"> <core:arg type="org.ofbiz.core.entity.GenericValue" value="${projectComponent}" /> </core:invoke> <core:invoke on="${issue}" method="setComponents"> <core:arg type="java.util.Collection" value="${components}" /> </core:invoke> <core:invoke on="${issue}" method="store" /> <core:getStatic className="com.atlassian.jira.event.type.EventDispatchOption" field="DO_NOT_DISPATCH" var="dispatchOption" /> <core:invoke on="${issueManager}" method="updateIssue"> <core:arg type="com.atlassian.crowd.embedded.api.User" value="${jira.user}" /> <core:arg type="com.atlassian.jira.issue.MutableIssue" value="${issue}" /> <core:arg type="com.atlassian.jira.event.type.EventDispatchOption" value="${dispatchOption}" /> <core:arg type="boolean" value="false" /> </core:invoke> </JiraJelly>
Note that I've used the component id as an argument to ProjectManager.getComponent. You can find the id of a component by clicking on the component and looking at the URL; for example: the URL for the OPS component that I defined was http://localhost:2990/jira/browse/ABC/component/10000, so the component id is 10000.
I didn't do the login thing, but you should be able to add that in just fine.
You need to call the store() method on the MutableIssue (MutableIssue inherits the store method from OfBizValueWrapper).
Note that, as of JIRA 5.0, the store() method is deprecated. The alternative is to use the IssueManager's updateIssue(...) method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome thanks David, I did try the store method however it didnt work:
<core:invoke on="${issueKey}" method="store"/>
and the updateissue expects a parameter which i am not sure how to get access to: com.atlassian.crowd.embedded.api.User user
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry I figured out the User but now I cant seem to figure out the EventDispatchOption eventDispatchOption
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok I figured out how to get the user, but my problem now is specifing the primitive boolean arg, it needs the primitive and not java.lang.Boolean?
<core:invoke on="${issueManager}" method="updateIssue">
<core:arg type="com.atlassian.crowd.embedded.api.User" value="${user}"/>
<core:arg type="com.atlassian.jira.issue.MutableIssue" value="${issueKey}"/>
<core:arg type="java.lang.Boolean" value="false"/>
</core:invoke>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The only way i can think of doing it is :
<core:arg type="com.atlassian.jira.event.type.EventDispatchOption" value="${EventDispatchOption.DO_NOT_DISPATCH}"/>
but this wont work, keeps giving a null value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.