Editing a workflow scheme without spending hours manually migrating projects

Max Cantor July 19, 2011

Due to https://jira.atlassian.com/browse/JRA-15964, I cannot perform a necessary edit to a draft workflow.

I have over 40 projects pointed at the workflow scheme containing this workflow.

How can I make the change to this workflow and propagate the change to all of my projects without having to manually click on every single one, individually, and manually migrate to the new workflow scheme for every single one, individually?

6 answers

4 votes
Markus Lepper
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 26, 2011

Hello Max,

unfortunately we did not find any solution, too.

In these scenarios I have to invest quite some time (and a new mouse) until this is done.

A "Bulk change Workflow scheme" would be very helpful.

BR, Markus

1 vote
Thomas Fuchs April 12, 2013

There is a solution from Catworkx..

https://marketplace.atlassian.com/plugins/com.catworkx.plugins.BulkWorkflowSchemeSwitcher

it works fine for me

Cheers
Thomas

1 vote
Deleted user February 27, 2013

I fully understand your frustation. I have to update more than 1300 projects and it takes us a couple of hours. This week I was again facing th problem and yesterday I decided to create an automated way to change the workflow scheme of projects. I'm mostly confronted with this problem when I want to introduce a new issue type with a dedicated workflow, which is not the default one. So I assumed in my solution that the workflow change doesn't affect existing issues, or in other words no statuses have to mapped between the workflows. It might be that you can extend the solution that is also remaps the statuses, but I haven't looked into it.

How does it work?
Selenium is capable of executing test scripts in a Firefox. A test script will simulate user clicks in the browser and I've written a piece of C# code that will generate the necessary test scripts which will simulate the necessary clicks for changing the workflow scheme for all the required projects. The scripts works with the project name and link (and doesn't assume a certain position in the browser), so projects that you don't want to convert will remain unchanged.

What do you need?

  1. Firefox
  2. Selenium IDE plugin for firefox
  3. Visual Studio Express C# (free edition)
  4. Jira 4.1 The solution was developed and tested on Jira 4.1. Solution might work on higher versions as long as the admin URLs in Jira remain unchanged compared to Jira 4.1



How to run the automation?

  1. Install Firefox
  2. Install Selenium IDE in Firefox
  3. Install Visual Studio Express for C#
  4. Make a text file containing per line the projects that you want to change
  5. ProjectA
  6. ProjectB
  7. ProjectC
  8. Make a visual studio console project and copy paste the attached code in Program.cs
  9. Adapt the first variable in the code public static string server = "http://myjira.mydomain.com/"; with the servername of your Jira instance
  10. Open the project properties and edit the debug properties. The command line argument property should contain the path to your text file with projects
  11. Run the program
  12. The test scripts will be generated in the same directory as your project text file.
  13. Open firefox
  14. Go to Jira and log in as administrator
  15. Go to the workflow scheme page
  16. In the Firefox Tool menu, select Selenium IDE
  17. In Selenium,in the File menu select Open test suite...
  18. Look for the 'Test suite.html' file and open it
  19. Press on play and enjoy!


The test script can fail when the project name contains special characters. On 1300 project I had only 8 faillures so I didn't adapt the code to deal with it.

If the solution doesn't fully work then I at least hope that it will help you in developing your own solution.

The piece of code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        //Fill in the name of your server
        public static string server = "http://myjira.mydomain.com/";

        public static string BeginTestcase = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"><head profile=\"http://selenium-ide.openqa.org/profiles/test-case\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />" +
                                                "<link rel=\"selenium.base\" href=\"" + server + "\" /><title>template script</title></head><body><table cellpadding=\"1\" cellspacing=\"1\" border=\"1\"><thead><tr><td rowspan=\"1\" colspan=\"3\">template script</td></tr>" +
                                                "</thead><tbody><tr><td>open</td><td>/secure/admin/ViewWorkflowSchemes.jspa</td><td></td></tr><tr><td>clickAndWait</td><td>link=";

        public static string EndTestcase = "</td><td></td></tr><tr><td>clickAndWait</td><td>id=select_workflow_scheme</td><td></td></tr><tr><td>select</td><td>id=schemeId_select</td><td>label=Barco Standard Workflow Scheme V3</td>" +
                                            "</tr><tr><td>clickAndWait</td><td>id=associate_submit</td><td></td></tr><tr><td>clickAndWait</td><td>id=associate_submit</td><td></td></tr></tbody></table></body></html>";


        public static string BeginTestSuite = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"><head><meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\" />" +
                                                    "  <title>Test Suite</title></head><body><table id=\"suiteTable\" cellpadding=\"1\" cellspacing=\"1\" border=\"1\" class=\"selenium\"><tbody>" +
                                                    "<tr><td><b>Test Suite</b></td></tr>";

        public static string EndTestSuite = "</tbody></table></body></html>";

        static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                string filepath = args[0];
                if (File.Exists(filepath) == true)
                {
                    string path = Path.GetDirectoryName(filepath);
                    StreamReader projects = new StreamReader(filepath);
                    StreamWriter testsuite = new StreamWriter(path+"\\"+"testsuite.html");
                    testsuite.Write(BeginTestSuite);

                    string project = projects.ReadLine();                  
                    while (!String.IsNullOrEmpty(project))
                    {
                        //Remove illegal characters to get a correct file name
                        string testcasePath = createValidFilePath(path, project);
                        //Create a new test case for the project
                        StreamWriter testcaseFile = new StreamWriter(testcasePath);                        
                        testcaseFile.Write(BeginTestcase);
                        testcaseFile.Write(project);
                        testcaseFile.Write(EndTestcase);
                        testcaseFile.Close();
                        //Add the new test case to the test suite file
                        string newtestcase = "<tr><td><a href=\"" + Path.GetFileName(testcasePath) + "\">" + project + "</a>/td></tr>";
                        testsuite.WriteLine(newtestcase);                        

                        //Read the next project
                        project = projects.ReadLine();  
                    }
                    testsuite.Write(EndTestSuite);
                    testsuite.Close();
                }
                else
                {
                    Console.WriteLine("File not found:" + args[0]);
                }
            }
        }

        static string createValidFilePath(string path, string project)
        {           
            string regexSearch = new string(Path.GetInvalidFileNameChars());
            Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
            string validProject = r.Replace(project, "-");
            return path + "\\" + validProject + ".html";
        }

    }
}

1 vote
Alejandro Conde Carrillo
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 10, 2013

There is a feature request for this: JRA-5254, but it is still not implemented.

0 votes
Thomas Fuchs March 21, 2013

There is a solution from CatWorkX (http://plugins.extern.catworkx.de) and it's called BulkWorkflowSchemeSwitcher - Plugin.

I've used it for my Jira and it works great!

cheers

0 votes
Charles Swartz September 27, 2012

Great question, I have the same issue. Workflow management in Jira is one of the most cumbersome and poorly designed processes I have used. I hope one day they come up with a more user friendly way to edit and apply workflows.

Suggest an answer

Log in or Sign up to answer