Housekeeping or continuous cleanup of the Agile activity artifacts

Hi awesome community! 

 

So automated housekeeping is good. If you want you can checkout (Cleanup-Jira-Part-1, Cleanup-Jira-2,)

Today, I would like to share use cases related to the cleanup Agile boards related stuff.

So to make the continuous cleanup I just use the groovy code, which is can be run on any app with support groovy like Scriptrunner, myGroovy, Grooviouli. 

Let’s start it.

Use case #1: Users are experimenting with Agile boards, own private boards, sometime you do migration. Then once your sprint reports shows incorrectly, where filters shows interesting things. Please, see below screenshot:

Action: Let’s remove Future Sprint data in Closed issues.

image.png

String jqlSearch = 'Sprint  in futureSprints() and status in (Closed, Done)  '


SearchService.ParseResult parseResult = searchService.parseQuery(loggedInUser, jqlSearch)
if (parseResult.isValid()) {
def searchResult = searchService.search(loggedInUser, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
def issues = searchResult.issues.collect { issueManager.getIssueObject(it.id) }

for (issue in issues) {
def customFieldsSprints = sprintField.getValue(issue)
log.debug customFieldsSprints
def newSprintValues = []
def changed = false
for (sprint in customFieldsSprints){
if (sprint.state == Sprint.State.FUTURE && !sprint.active){
changed = true
continue;
}
newSprintValues.add(sprint)
}
if (newSprintValues.size == 0) { newSprintValues = null; changed = true; }

sb.append("Removing future sprint for ${issue.key} <br />\n")
if ( changed && !isPreview ){
sprintField.updateValue(null, issue, new ModifiedValue(null, newSprintValues), new DefaultIssueChangeHolder())
boolean wasIndexing = ImportUtils.isIndexIssues()
ImportUtils.setIndexIssues(true);
log.debug("Reindex issue ${issue.key}")
issueIndexingService.reIndex(issue)
ImportUtils.setIndexIssues(wasIndexing)
}
}
}

return sb.toString()

Full reference: in git

Conclusion: Time to time automated activities is efficient.

 

Use case #2: Once you do search using  JQL, like sprint = 12332, and total issues is 0. So You made reindexing, after you start to think, is this just some scrum master create Sprints and forgot to put issues. After investigation, you can find a lot of Sprints. As result, of that, most users are confused by searching by sprints. 

Action: Let’s remove unused sprints from our Jira instance.

sprintManager.getAllSprints().value.findAll {
!it.closed
}.findAll { Sprint sprint ->
def query = jqlQueryParser.parseQuery("sprint = $sprint.id")
def hasNoIssues = !searchService.searchCount(user, query)
if (hasNoIssues) {
log.warn("Found sprint '${sprint.name}' with no issues.")
sb.append("Found sprint '${sprint.name}' with no issues.<br />\n")
}
hasNoIssues
}.each { Sprint sprint ->
if (!isPreview) {
sb.append("Removing sprint ${sprint.name} <br />\n")
log.warn("Removing sprint ${sprint.name}")
sprintManager.deleteSprint(sprint)
}
}

return sb.toString()

Full reference in git: 

Conclusion: Good to have copy/paste solution :)

 

 

Use case #3: Users are working frequently with filters, like add, edit, remove. (Of course, after that feature in our company filter stoped growing like exist situation https://confluence.atlassian.com/adminjiraserver0713/managing-shared-filters-964984171.html). Time to time, you can find unaccessible agile boards, which is lost long time ago a filters and users are already create a new one, because they just removed filters, instead of  remove first referenced agile board, dashboards and then filter.

 

Action: Let’s remove Agile boards without core filters.

sb.append("<b>Board id</b> - Name - <b> Owner </b><br />\n")
rapidViewManager.getAll(new NoCheck()).value.each { b ->
if (srm.getSearchRequestById(b.savedFilterId) == null) {
if (!isPreview) {
def res = rapidViewManager.delete(b)
}
sb.append("${b.id} - ${b.name} - ${b.owner}<br />\n")
}
}

return sb.toString()

Full reference in git 

 

I hope it helps for you. ( all info you checkout here https://github.com/gonchik/cleanup-scripts/tree/master/groovy/agile)

Have a good cleaning.

 

Cheers,

Gonchik Tsymzhitov





4 comments

Max Malygin
Contributor
March 24, 2020

Thanks!

It’s great to see the evolution of regular cleaning procedures for Jira.

Like Gonchik Tsymzhitov likes this
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 24, 2020

Hope it helps for you. 

Also, I will be if you provide some use cases of cleaning the Jira

Taranjeet Singh
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 2, 2020

Thanks, this is useful information!

Like Gonchik Tsymzhitov likes this
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 26, 2020

@Taranjeet Singh My pleasure!

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events