Things have changed “recently”:
- no wiki mark-up any longerΒ π
- https://confluence.atlassian.com/doc/export-content-to-word-pdf-html-and-xml-139475.html – exporting got more powerful
- REST API available (?!!)
- …
Things have changed “recently”:
Sample URL-s:
On Mediawiki’s CMS a user’s activity streams looks like this:
On β¦ β¦ looks like this:
These are the means to achieve my goals:
jq, jqPlay, jq-tutorial, ⦓jq” (presumably) stands for “JSON query processor”.
jq helps writing shell scripts processing JSON responses from e.g. RESTful application APIs like Jenkins, Atlassian JIRA, Atlassian Confluence, β¦ β code making use of powerful means like XPath (β¦) or jq is supposedly far more readable than Python / Perl / β¦ scripts slurping the JSON and processing it (w/o jq resp. XPath) β but there are also Python resp. Perl bindings for jq.
A couple of weeks ago I had written a shell script querying a Jenkins server’s REST API “Γ la XML”. Now it looks a little straighter to query the API “Γ la JSON” and employ jq. But the critical question is, whether the (industrial) customer (I wrote the Jenkins utility for) will like the dependency on a utility like jq. My Jenkins utility might have to serve for quite a couple of years β but who can predict the future and availability of jq?
Update 2016-02-23: Meanwhile I built a shell script with a couple of simple jq queries accessing Jenkins CI. Looks rather impressive to me.
If you do XPath queries from shell scripts, you always have the option to rewrite the shell script as Python or Perl script. But what about JSON queries (…) in Python or Perl?
By default, jq pretty-prints JSON output.
$ jq . < β¦ > β¦
There are certainly legion of reasons to use a REST API and also to use the JIRA REST API, I wanted to create a linear “diary” of JIRA actions.
This is our sample JIRA issue URL:
http://kelpie9:8081/browse/QA-31
This is its corresponding REST URL:
http://kelpie9:8081/rest/api/2/issue/QA-31
Find yourself a working sample JIRA issue URL use the corresponding REST URL in your browser, save the JSON returned to a file!
You usually want to read “pretty” / tidied JSON, so before you start reading JSON, find yourself a JSON-tidy utility:
Usually we want to retrieve JSON from JIRA through REST URLs via the curl utility.
CAVEAT: See my note on the cookie jar below!
This is the “simple example”, that the page referred to above (“Basic Authentication“) shows you:
$ curl -D- -u fred:fred -X GET
-H "Content-Type: application/json"
http://kelpie9:8081/rest/api/2/search?jql=assignee=fred
If your JIRA site requires you to use “Basic Authentication”, you have to encode username:password base64-wise, and this is how to do it:
$ echo -n fred:fred | base64
So if you want to use “Basic Authentication” with these credentials, this is how … (using our sample REST URL):
$ curl -D- -X GET
-H "Authorization: Basic $(echo -n fred:fred | base64)"
-H "Content-Type: application/json"
"http://kelpie9:8081/rest/api/2/issue/QA-31"
During my experiments I got locked out of the company’s Active Directory / SSO quite a few times — and I had to call the help desk in order to get my account reset. This is what JIRA tells you, once it decides you have to go through a CAPTCHA_CHALLENGE procedure, because you are behaving a little too suspicious:
HTTP/1.1 403 Forbidden
Server: Apache-Coyote/1.1
X-AREQUESTID: ...
X-Seraph-LoginReason: AUTHENTICATED_FAILED
Set-Cookie: JSESSIONID=...; Path=/; Secure; HttpOnly
WWW-Authenticate: OAuth realm="https%3A%2F%2Fjira.___.com"
X-Content-Type-Options: nosniff
X-Authentication-Denied-Reason: CAPTCHA_CHALLENGE; login-url=https://jira.___.com/login.jsp
Content-Type: text/html;charset=UTF-8
Content-Length: 6494
Date: Wed, 02 Dec 2015 11:59:15 GMT
But once you are beyond this, making use of the JIRA REST API works like a charm.
Update: Although I certainly had not failed (“basic”) authentication, JIRA got my Active Directory / SSO account locked again and again. My new strategy:
Wishlist:
FishEye – Subversion, Git, Mercurial, CVS, & Perforce in your browser.:
FishEye provides a web interface for Subversion, Git, CVS & Perforce source control repositories. Features include email & RSS feeds, JIRA integration, charts, search.
Get started for $10 or a free 30-day trial.