Re: Export a report form the gerrit web interface (AOSP public project)

1,849 views
Skip to first unread message

Magnus Bäck

unread,
Aug 22, 2012, 1:55:33 PM8/22/12
to repo-d...@googlegroups.com
On Wednesday, August 22, 2012 at 13:32 EDT,
Bruce J Beare <bruce....@intel.com> wrote:

> I would like to be able to export a report from gerrit into a
> spreadsheet. I used to be able to do this with "ssh <server> gerrit"
> style queries (I used to use JSON), but I believe that that is no
> longer possible with android-review.googlesource.com.
>
> Is there a way to pull the JSON data in from the public servers?

You can use the new REST API, coming in Gerrit 2.5 but currently live
on android-review. I don't know if the 2.5 documentation has been posted
publicly anywhere yet, but you can at least look at the source asciidoc
and the commit messages.

https://gerrit-review.googlesource.com/34490
https://gerrit-review.googlesource.com/34511
https://gerrit-review.googlesource.com/36832

Simple example:

$ curl 'https://android-review.googlesource.com/changes/?format=JSON&q=status:open&n=1'
)]}'
[
{
"project": "platform/system/core",
"branch": "master",
"id": "I7c997a33552f3eab23af3254045da738394db0a6",
"subject": "libusbhost: handle more of innotify_event in one event
buffer.",
"status": "NEW",
"created": "2012-08-02 08:06:44.006000000",
"updated": "2012-08-22 17:47:24.307000000",
"_sortkey": "001f3d4b00009cf7",
"_number": 40183,
"owner": {
"name": "Bo Huang"
},
"_more_changes": true
}
]

(What's ")]}'" doing on the first line of output?)

[...]

--
Magnus Bäck
ba...@google.com

Conley Owens

unread,
Aug 22, 2012, 2:27:42 PM8/22/12
to repo-d...@googlegroups.com
It's a security measure.

Copied from RestApiServlet.java:

/**
* Garbage prefix inserted before JSON output to prevent XSSI.
* <p>
* This prefix is ")]}'\n" and is designed to prevent a web browser from
* executing the response body if the resource URI were to be referenced using
* a &lt;script src="...&gt; HTML tag from another web site. Clients using the
* HTTP interface will need to always strip the first line of response data to
* remove this magic header.
*/
protected static final byte[] JSON_MAGIC;


~cco3

>
> [...]
>
> --
> Magnus Bäck
> ba...@google.com
>
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en

Dave Borowitz

unread,
Aug 22, 2012, 2:52:57 PM8/22/12
to repo-d...@googlegroups.com
On Wed, Aug 22, 2012 at 10:55 AM, Magnus Bäck <ba...@google.com> wrote:
On Wednesday, August 22, 2012 at 13:32 EDT,
     Bruce J Beare <bruce....@intel.com> wrote:

> I would like to be able to export a report from gerrit into a
> spreadsheet.  I used to be able to do this with "ssh <server> gerrit"
> style queries (I used to use JSON), but I believe that that is no
> longer possible with android-review.googlesource.com.
>
> Is there a way to pull the JSON data in from the public servers?

You can use the new REST API, coming in Gerrit 2.5 but currently live
on android-review. I don't know if the 2.5 documentation has been posted
publicly anywhere yet,

If it's live on android-review, the documentation is also hosted there:
 

Bruce Beare

unread,
Aug 22, 2012, 7:05:28 PM8/22/12
to repo-d...@googlegroups.com
Very nice indeed. I've been able to get simple queries to work:

I can't seem to get "/a/" (authenticated) queries to work:

Where can I place the /a/ so that I can use owner:self or ownerin:%22group%20name%22  ?

thanks!
-Bruce

Conley Owens

unread,
Aug 22, 2012, 7:11:44 PM8/22/12
to Bruce Beare, repo-d...@googlegroups.com
That's the correct url. Unfortunately it gives the confusing message:
Error 401 (Not Found)

When Error 401 means you are unauthorized.

Conley Owens

unread,
Aug 22, 2012, 7:14:27 PM8/22/12
to Bruce Beare, repo-d...@googlegroups.com

Bruce Beare

unread,
Aug 22, 2012, 7:45:59 PM8/22/12
to repo-d...@googlegroups.com, Bruce Beare
sweet! works.
Thank you.
Reply all
Reply to author
Forward
0 new messages