Automation Ideas for Project Configuration XML Import

SomnathK February 24, 2014

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

0 votes
José Marañón [Awnaba Software S.L.]
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.
March 2, 2014

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!


0 votes
José Marañón [Awnaba Software S.L.]
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 24, 2014
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!
SomnathK February 24, 2014

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 ?

José Marañón [Awnaba Software S.L.]
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 24, 2014

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

SomnathK March 2, 2014

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.

SomnathK March 2, 2014

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();
}

}

}

SomnathK March 2, 2014
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();
        }

    }

}

SomnathK March 2, 2014
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);

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events