how do i push forward issues (e.g. bulk edit 10 issues to set start date one day later )

 

2 answers

1 accepted

I don't know of a way to do this through the interface. If I had to do this I'd write a simple groovy script and run it through the admin console of the Script Runner plugin by Jamie Echlin. 

 

The groovy code to do this is simple...I'll post an example when I'm back at my desktop

...much time passes, and 38 seconds later...

Ah...the joys of script runner, groovy and the Java Date.

enjoy. Thanks for the point.

/**
 * moveJQLIssuesForwardOneDay.groovy
 * Purpose: 
 *          example script written for Answers post
 *            takes a jql query and runs it looping over the results
 *                inside the loop each issue has it's create date incremented by X days
 *                log some debug noise about the issues being modified
 *            exit and go play bloodbourne
 *
 * Note: person running this script is responsible for what it does or does not do - nobody else
 * ALSO NOTE: This script leaves not history that it was run other than what appears in the log, and
 *                          even better it looks like you need to reindex the project/s that have the issues you are
 *                          modifying
 *
 * Shameless plug: wcrighton@capitalcityconsultants.com https://www.capitalcityconsultants.com
 * Author: wc
 * Created: 20150605T220533 - 10:05 PM on 05 Jun 2015
 */

// I don't think we need anywhere near all of these but this 'set' of imports is useful for most problems
// so I just keep with it
import com.atlassian.core.ofbiz.CoreFactory
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.search.SearchResults

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.*
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.issuetype.IssueType
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.project.version.VersionManager
import org.apache.log4j.Appender
import org.apache.log4j.Layout
import org.apache.log4j.Logger
import org.apache.log4j.PatternLayout
import org.codehaus.groovy.util.Finalizable
import org.ofbiz.core.entity.GenericValue
import java.sql.Timestamp;
import java.time.LocalDateTime;

// -- ------------------------------------------------------------------------ --
// -- NOTE: To actually witness any logging from this script you need to add
// --       the following Logger 'class' to the list of Default Loggers on
// --       page Admin/System/Logging & Profiling using the 'Configure logging
// --       level for another package' hyperlink. Just paste the string below
// --       (part inside the double quotes) in the 'Configure' dialog and set the
// --        log level to DEBUG
Logger log = Logger.getLogger ("ccc.groovy.IncrementCreatedOnIssuesReturnedByJQL");

// -- ---------------------------------------------------------- --
// -- Note: If the JQL query to pull your issues gives you trouble then just use the following:
// MutableIssue muteIssue = issueManager.getIssueObject("ONE-1");

// go and get a component manager
ComponentManager componentManager = ComponentManager.getInstance ( );
IssueManager issueManager = componentManager.getIssueManager();

// Get the current user
User currentUser = ComponentManager.getInstance ( ).getJiraAuthenticationContext ( ).getUser ( ).getDirectoryUser()

// Enter your issue keys into the following JQL search string - 
String jql = "issueKey in (ZP-1,ZP-2)";

// Search for Release Issue
MutableIssue releaseIssue = null;
SearchService searchService = componentManager.getSearchService ( )
SearchService.ParseResult parseResult = searchService.parseQuery (currentUser, jql == null ? "" : jql);

PagerFilter filter = PagerFilter.getUnlimitedFilter ( );
SearchResults searchResult = searchService.search (currentUser, parseResult.getQuery ( ), filter);
List<Issue> issues = searchResult.getIssues ( );
Integer issueCounter = 0;

if(issues != null) 
{
    log.debug("Count: " + issues.size() + " issues returned by query");
    for(Issue issueObject : issues)
    {
        Long issueId = issueObject.getId();
        MutableIssue mutableIssue = issueManager.getIssueObject (issueId);
        if (mutableIssue != null)
        {
            log.debug("Processing Issue: " + mutableIssue.getKey());
            
            Timestamp created = mutableIssue.getCreated();
            String msg = "  incrementing issue created date from: " + created.toString() + " to ";
            Calendar c = Calendar.getInstance();
            c.setTime(created);
            c.add(Calendar.DATE, 1);
            
            Timestamp newCreated = new Timestamp(c.getTime().getTime());
            
            log.debug(msg + newCreated.toString());
            mutableIssue.setCreated(newCreated);
            mutableIssue.store();
          }
    }
    log.debug("Exiting - processed: " + issueCounter + " issues this time");      
}
else
{
    log.error("...er....query returned no issues...sorry");
}

 

Please be sure to run it with a single issue jql query - and as always to be safe do a XML export first at a minimum.

-wc

 

Thank you so much!

Looking forward for the example!!!

you get a chance to try that groovy script out yet?

Dear William thank you so much for your help! I am looking for something customisable, a script in which i can pass a set of issues (selected from Jira) which are assigned to a user (selected from Jira). Ideally, it would be like a button on the Bulk Edit Screen (e.g. "Shift Planned start date").

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

100 views 0 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you