Can I use wget to download attachments?

Deleted user December 16, 2012

We are using a JIRA web site as a transfer point between two companies and a particular ticket to pass patches back and forth. (I won't go into the politics as to why this is so. Suffice it to say that this vehicle was chosen as the result of a negotiating process.) Anyway, as you might suspect, the list of stuff I need to pull gets long. I got what I thought was a list of URL's to pull, only to discover wget had pulled 30 copies of a java script intended to bring up a "where do you want this" helpful window. Not what I want. How do I just get the files without all the extra UI help? Thank you!

3 answers

1 accepted

0 votes
Answer accepted
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
December 16, 2012

Don't know about that, but you may find JIRA Command Line Interface useful. Specifically getAttachment and getAttachmentList

Deleted user December 16, 2012

I went to your "JIRA Command Line Interface" link and confess I found it confusing. There are a lot of entries there with no clear ordering or way to decide which one it is I want. I guess this one: jira-cli-3.1.0-distribution.zip -- I'll know in a bit. Thank you!

https://bobswift.atlassian.net/wiki/display/JCLI/Documentation#Documentation-getAttachment ``Get lastest'' I found to be a fun term. :)

0 votes
Higashi
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 12, 2016

Yes, you can. You can use bash `wget`, `curl` or whatever tool suits you. But not without any preparation. You have to use WebDav Servlet. So, assuming we are talking about confluence cloud and domain: `example.atlassian.net`, your URL would be: 

https://example.atlassian.net/wiki/plugins/servlet/confluence/default/Global/

This would get you "dashboard" view. If you want to download attachment 'samplefile' on space 'EXAMPLE' under page `subsite`, with tree as follows:

EXAMPLE/
├── home
│   └── subsite
└── test

Your URL would look like: 

https://example.atlassian.net/wiki/plugins/servlet/confluence/default/Global/EXAMPLE/home/subsite/samplefile

Example in bash, using `wget`:

$ wget --user=test.user --ask-pass https://example.atlassian.net/wiki/plugins/servlet/confluence/default/Global/EXAMPLE/home/subsite/samplefile
0 votes
Deleted user December 16, 2012

It takes a little getting used to, but it works like a charm. Thank you. A tiny nit: "$@" will _always_ expand to at least one parameter. If it is empty, the program sees one empty argument. ${1+"$@"} is a little geeky, but expands to nothing when there are no arguments.

$ cat jira.sh 
#!/bin/bash

# Comments
# - Customize for your installation, for instance you might
# want to add default parameters like the following:
# java -jar `dirname $0`/lib/jira-cli-3.1.0.jar --server
# http://my-server --user automation --password automation "$@"

server='--server http://jira-..../'
passwd='--user automation --password automation'
jar="-jar $(dirname $0)/lib/jira-cli-3.1.0.jar"
java $jar $server $passwd ${1+"$@"}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events