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

How can we "MOVE" an issue to another project programmatically in jira version 6.0

David Lemon June 5, 2013

How to "move" issues by the listener plugin at run-time to another project and also doing changes in the history?

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
Answer accepted
David Lemon June 9, 2013

Hello Folks,

Now moving of the issue using your plugin sdk is possible! I have made a plug by which you can change your issues project and that too securely.

The method is you use Ofbiz class ! and change the db Entry. This is what the inbuilt managers use to do. But Please keep in mind if your are working with DB which is a critical job, You have to take care of all the supporting things. eg: Issue Reindexing and also the rest!... What so ever you do With jira DB, Maintain the jira Harmoney otherwise you can be in a trouble.

thanks And regards!

~Sohil

Kateryna June 10, 2013
Hi, Sohil! You can provide me the sample code? I can not solve the same problem, I will be grateful for your help.
HermannS June 16, 2013

Hello Sohil,

I tried to figure out what you mean by "use Ofbiz class ! and change the db Entry", but without success. Can you please show us some pseudo- or real code and/or tell us which classes you are talking about?

Greetings

Hermann

David Lemon June 16, 2013

The code is here impliment the ofbiz functions.

https://github.com/rdumitriu/jira-qanda

Try updating the database and do reindex after words. you may directly contact the person who have uploaded this code. the email is in there in the code header.

hope this is help ful

-----thanks and regards...

HermannS June 23, 2013

Hello Sohil,

sorry but I still don't know how you are doing it. That jira-qanda plugin you are pointing to is not in the "business" of moving an issue, is it? Can you give some more details on the code you are using to achieve the task of moving an issue?

In the meantime I was able to programmatically move an issue using a webwork plugin to add a corresponding action to the issue view (see https://answers.atlassian.com/questions/150179/how-to-move-an-issue-programatically-to-a-different-project/183233 ). But I would still like to do this in a post-function or a listener...

Greetings

Hermann

David Lemon June 23, 2013

can you let me know what exactly you want to achive? Moving an issue but for what reason? its already available in the UI... still what makes you to impliment this function programatically?

HermannS June 23, 2013

Hello Sohil,

I think it's funny you are asking this. Wasn't it you who wanted to know about how to move an issue programmatically? :-)

But seriously: The move-operation as it is in the UI is for us most of the time overly complicated. What I want to achieve is e.g.:

  • Move an issue to a special project if a certain workflow step is done (e.g. to "SPAM")
  • Provide a special one step move UI for simply moving an issue to another project that has exactly the same settings as the original project.

Greetings

Hermann

David Lemon June 23, 2013

thats fine,

Well I cant provide your with the actual Moving Issue code I created. But I can guied you to do it.

1. Configure your jira with mysql.

2. Actually move the Issue from one project to another from the UI.

3. Now check in the mysql and look for the change in the database. you will notice there are new values in changegroup, changeitem, and updation of the issue value in the jiraissue table. Actually jira addes the history record in the changegroup and changeitem tables and simply updates the jiraissue table. see what what changes jira does to move the issue.

4. now using the jira-quanda's OfBiz implimentation example try to do it programmatically.

5. and finally reindex the issue there is indexmanager.reindex(issue) function.

thats what is the recipe for the IssueMover. I have implimented the above logic over an issue update event as a listener.

Cheers

~Sohil

Like Deleted user likes this
HermannS July 3, 2013

Hello Sohil,

sorry for asking again. I am still not able to get this working.

I am using this code: https://gist.github.com/hermannschwaerzler/ecc1883bda7bc06b6e34

Do you have time to have a look at it? I am doing the update of jiraissue using the ofbiz-classes but the changelog I am doing using the ChangeLogUtils. I end up with an issue that has a changelog that indicates it has been moved but it's still in the same queue and has the original key. When I add some logging I see that the updatedIssueGV contains the changed values for project id and issue key but somehow these changes are not stored!.

What am I doing wrong?

Greetings

Hermann

David Lemon August 6, 2013
Sorry Hermann! discontinued Atlassian for a while. will look at the issue once i get time to watch your attempt!
Lauri Vasko June 1, 2014

@Hermanndid you reindex your JIRA after moving issues programmatically?

It sounds like you either didn't reindex the JIRA OR you didn't save changes to issue table and only created history log for your issues.

HermannS June 1, 2014

In the meantime I found the problem: in the version of JIRA I am using you have to store the moved issue in a sepate thread. In essence I am doing this (after some prepartion and saving a corresponding change-group):

int rowsAffected
def th = Thread.start {
   sleep 50 
   rowsAffected = delegator.store(updatedIssueGV)
   indexManager.reIndex(updatedIssueGV)
   ...
}

This works as expected.

3 votes
HermannS June 6, 2013

Unfortunately there is no (documented or simple) API for doing this. Your may read the comments and answers of https://answers.atlassian.com/questions/150179/how-to-move-an-issue-programatically-to-a-different-project to get an idea of what's the problem.

I tried the code Jamie Echlin was pointing to in his anwer at Mar 21 at 10:42 AM but until now with no success. What I get is an issue that stays where it was but has an entry in its history that looks like it got moved. Strange...

But the code may not work as is with JIRA 6 anyway as the constructors of those MoveIssue* classes has probably changed.

Please keep us informed...

Greetings

Hermann

David Lemon June 6, 2013

Thanks Hermann To show interest! Well i am also Working on this since long past 4 months to find some solution. will keep you updated if i find some or the other solution.

0 votes
Mark Bednarski May 29, 2014

Hi guys,

thanks for the discussion. I was about to start to look into a new listener to write. We want that once a certain status is met and the issue is of a certain type, the issue gets moved from project A to project B.

Well given that this seems not really possible via a script listener I'll not look into this now, which saves me some time ;-)

Thanks
Mark

HermannS May 29, 2014

Hi Mark,

in fact I managed to get this working using a listener in groovy-scriptrunner in JIRA 4.4. I did so by looking a lot at the JIRA source so I am quite sure I cannot release the code publicly. But I think I can send it to you by private message. If you are interested: my email address ends in "uibk.ac.at" and starts with "hermann.schwaerzler" with the usually at-sign between those two parts. :-)

Greetings

Hermann

TAGS
AUG Leaders

Atlassian Community Events