It's all about the answers!

Ask a question

Export defect query results to file via command line?


Jarett Stein (161) | asked Jan 06 '09, 2:54 p.m.
JAZZ DEVELOPER
I'm trying to find a programmatic way to export queried defect information to a local file. I know I can export defect information from a defect query in the web client by clicking the "export to .csv" feature.

Is there any way to do this via the command line? I need a way to export defect information to a local text file without using a GUI interface.

For instance, ClearQuest includes a cqperl executable that can be run via command line where I can open a session with the CQ server and export to a local file. Looking for something in Jazz that will give me similar results.

Thanks in advance!
Jarett

3 answers



permanent link
Patrick Streule (4.9k21) | answered Jan 08 '09, 5:58 a.m.
JAZZ DEVELOPER
I'm trying to find a programmatic way to export queried defect
information to a local file. I know I can export defect information
from a defect query in the web client by clicking the "export to
csv" feature.

Is there any way to do this via the command line? I need a way to
export defect information to a local text file without using a GUI
interface.

As the export functionality is available using plain HTTP, you could use
'curl' to download the CSV. The export URL looks as follows:

https://server:port/jazz/resource/itemOid/com.ibm.team.workitem.query.QueryDescriptor/_7yQNQLYnEd29gJkOCv4V6Q?_mediaType=text/csv

If your server is using form-based auth, you need to log in explicity
(curl's -u parameter doesn't work here):

COOKIES=./cookies.txt
USER=user
PWD=password
HOST=https://localhost:9443/jazz

curl -k -c $COOKIES -d j_username=$USER -d j_password=$PWD
$HOST/j_security_check


Then you can do the export:

curl -k -b $COOKIES
https://localhost:9443/jazz/resource/itemOid/com.ibm.team.workitem.query.QueryDescriptor/_7yQNQLYnEd29gJkOCv4V6Q?_mediaType=text/csv


--
Regards,
Patrick
Jazz Work Item Team

permanent link
Jarett Stein (161) | answered Jan 08 '09, 5:57 p.m.
JAZZ DEVELOPER
Patrick,

Thanks for the reply. I think this will work perfectly for what I need. I'm having some trouble getting the first command to work. When I try it like this:
> curl -D -k -c "d:\cookies.txt" -d "j_username=username" -d "j_password=mypassword" https://server:9943/jazz/j_security_check


I get an error from the site:
HTTP Status 408 - The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser.

I get this same error on two different Jazz installs, each running TomCat.

I haven't gotten the second command to work yet because the login isn't working yet.

Any ideas?

Thanks again,
Jarett Stein

permanent link
Patrick Streule (4.9k21) | answered Jan 09 '09, 6:08 a.m.
JAZZ DEVELOPER
I get an error from the site:
HTTP Status 408 - The time allowed for the login process has been
exceeded. If you wish to continue you must either click back twice
and re-click the link you requested or close and re-open your
browser.

I get this same error on two different Jazz installs, each running
TomCat.

I haven't gotten the second command to work yet because the login
isn't working yet.

Any ideas?

I haven't come across this situation yet, but I have used the script
examples only against Jetty, which may be different from Tomcat: AFAIK,
Tomcat does not allow "drive-by" logins, i.e. directly posting to
j_security_check. It expects the JSESSIONID cookie that is sent along with
the login page.

So you could probably do the following:

1) curl -k -c $COOKIES
https://localhost:9443/jazz/resource/itemOid/com.ibm.team.workitem.query.QueryDescriptor/_7yQNQLYnEd29gJkOCv4V6Q?_mediaType=text/csv
--> This will record the challenge cookie.
2) post login data
3) do 1) again.

You may want to check if 1) already returns the export CSV (you may this
have a valid cookie in the cookie file).

--
Regards,
Patrick
Jazz Work Item Team

Comments
Pheneenda gadipoodi commented Dec 27 '12, 3:57 a.m.

I am getting same error after following the above instructions.

Please help me to sort it out.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.