Automation Ideas for Project Configuration XML Import

Hi Team,

We are trying to Automate the Process of Uploading the Project Configuration XML.

But since the UI is available behind the JIRA Websudo, we are facing difficulties in doing so.

Any help in figuring out how to automate the Process of Configuration Upload would be helpfull.

Thanks,

Somnath

2 answers

Hello, In the page https://awnaba.atlassian.net/wiki/display/PCP/How+to+automate+export+and+load+of+project+configurationsyou can find how to export and load configurations from the command line. It includes some examples too. Cheers!

Thanks Jose !!!

I am hitting on an Issue over here :

When I am trying to Upload to :

<JIRA_URL>/secure/project-config-file-upload.jspa

JIRA is returning me a WebSudo Authentication page asking for Password, for my Logged in User.

I have attached all the Cookies which came along with the Login.

How to pass that ?

Could you attach a dump of your shell session, with the commands you have issued and the responses?

Hi Jose,

With JIRA WebSudo Authorization Turned OFF, the automation steps described works fine. But once thats ON, I am facing problem.

To get past the WebSudo Password Entry page, I am doing something like this, but I fail to get past the Password Entry page.

Please see the attached program.

if (redirect) {

// get redirect url from "location" header field
String newUrl = conn.getHeaderField("Location");

// get the cookie if need, for login
String cookies = conn.getHeaderField("Set-Cookie");

// open the new connnection again
conn = (HttpURLConnection) new URL(newUrl).openConnection();
conn.setRequestProperty("Cookie", cookies);
conn.addRequestProperty("Authorization", "Basic Y3NmYWRtaW46VGFqbWFoYWw2OA==");
conn.addRequestProperty("X-Atlassian-Token", "no-check");
conn.setRequestMethod("POST");

System.out.println("Redirect to URL : " + newUrl);

}

BufferedReader in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuffer html = new StringBuffer();

while ((inputLine = in.readLine()) != null) {
html.append(inputLine);
}
in.close();

System.out.println("URL Content... \n" + html.toString());
System.out.println("Done");

} catch (Exception e) {
e.printStackTrace();
}

}

}

if (redirect) {

                // get redirect url from "location" header field
                String newUrl = conn.getHeaderField("Location");

                // get the cookie if need, for login
                String cookies = conn.getHeaderField("Set-Cookie");

                // open the new connnection again
                conn = (HttpURLConnection) new URL(newUrl).openConnection();
                conn.setRequestProperty("Cookie", cookies);
                conn.addRequestProperty("Authorization", "Basic Y3NmYWRtaW46VGFqbWFoYWw2OA==");
                conn.addRequestProperty("X-Atlassian-Token", "no-check");
                conn.setRequestMethod("POST");

                System.out.println("Redirect to URL : " + newUrl);

            }

            BufferedReader in = new BufferedReader(
                    new InputStreamReader(conn.getInputStream()));
            String inputLine;
            StringBuffer html = new StringBuffer();

            while ((inputLine = in.readLine()) != null) {
                html.append(inputLine);
            }
            in.close();

            System.out.println("URL Content... \n" + html.toString());
            System.out.println("Done");

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}

public class RestClientJIRAProjectConfigImpExp_HTTP
{

    public static void main(String[] args) {

        try {

            String url = "http://&lt;JIRA_URL&gt;/secure/admin/WebSudoAuthenticate.jspa?webSudoPassword=XXXXX&amp;webSudoDestination=/secure/project-config-file-upload.jspa";

            URL obj = new URL(url);
            HttpURLConnection conn = (HttpURLConnection) obj.openConnection();
            conn.setReadTimeout(5000);
            conn.addRequestProperty("Authorization", "Basic Y3NmYWRtaW46VGFqbWFoYWw2OA==");
            conn.setRequestMethod("POST");
            conn.addRequestProperty("X-Atlassian-Token", "no-check");
            conn.setInstanceFollowRedirects(false);
            System.out.println("Request URL ... " + url);

            boolean redirect = false;

            // normally, 3xx is redirect
            int status = conn.getResponseCode();
            if (status != HttpURLConnection.HTTP_OK) {
                if (status == HttpURLConnection.HTTP_MOVED_TEMP
                        || status == HttpURLConnection.HTTP_MOVED_PERM
                        || status == HttpURLConnection.HTTP_SEE_OTHER)
                    redirect = true;
            }

            System.out.println("Response Code ... " + status);

Hi Somnath,

AFAIK, in order to go past the websudo page you only need to navigate to the url:

../jira/secure/admin/WebSudoAuthenticate.jspa

and supply the administrator password as parameter
"webSudoPassword".

After that, just call the URL to upload the configuration.

You need not do anything special with redirections, just call one URL and then the other.

Also check that your websudo timeout (property jira.websudo.timeout) is not too low.
Default is 10 minutes which should be more than enough.

Hope this helps!


Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

362 views 0 6
Read article

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