Working with large instances of Jira is one of the problems; it’s a lot of different things. One of them is rapid boards. Unfortunately, Jira has no tools to find the orphaned boards and remove them. In the previous post https://community.atlassian.com/t5/Enterprise/Get-orphaned-rapid-boards/gpm-p/1087619, I tried to find part of the orphan boards. In the current post I am trying to remove them from Jira.
I use GEB to remove them through the user interface.
Yes, this is an easy way, but there are some drawbacks:
For balance I write drawbacks of the my scripts:
Look at the method in more detail:
public static void delBoards(fName){
We check the file 'fName' and extract list boards from them.
Open 'manage boards':
browser.go url + "/secure/ManageRapidViews.jspa"
The first problem is the pages on the board. Looks like we can go through all the pages to create a list of boards. Then simply remove the board from the desired page. No, unfortunately, after removing boards, the number of pages may decrease, and the position of boards has changed. This means that we have to check page after page and start again after deletion. (It may be better to start from the page where the last board has been deleted, but, I'm afraid, Jira may re-sort boards)
Well, check, we have many pages:
if (browser.$("li", class:"aui-nav-next").displayed)
Scan the current page and get all the current boards:
browser.$("tbody").$("tr").each
Check each current board to remove:
currentBoards.each {
More details about:
if (!removed||!hasPage){
So if we delete one board, we will start again, because Jira has reloaded the page and GEB has lost the item. We need to re-scan, but if we only have one page, we don’t have to start over, because GEB has not lost the elements.
If we find the current board in the file, we need to delete them:
if (boards.find {it == curB}){
The next problem we will discover is that Djira has no direct link to remove the board. It mean we need 'click' a few button for delete board. Write new method 'delBoard' for this, we use only board id:
if (this.delBoard(it)){
This method just click on button with ID '...' -> 'Delete' -> 'Delete'.
If the board has been removed and we have many pages, we start again.
public static boolean delBoard(bId)
If we didn’t find any boards to delete on the current page, we need to click on the next page.
if (!removed&&hasPage){
Finally, if we stay on the last page and cannot find a board for removal, it means that we checked all the boards.
if (lastPage&&!removed){
Flowchart of the method delBoards:
Use groovy and geckodriver http://www.gebish.org/ . Run in CMD 'grooby JiraGebAuto.groovy delBoards list.txt' File 'list.txt' should exist at the same dir where 'JiraGebAuto.groovy' Script run browser and write deleted id in file 'deletedBoards.txt'. list.txt should have only id of the boards separate with new lines.
Code
https://bitbucket.org/AndrewDvizhok/scriptrunner-useful/src/master/geb/
Warning! Please be very careful. The script has a method for deleting projects, I recommend commenting on these methods and using only if You know groovy. Check everything twice.
I hope this post was helpful.
B.R.