Script to link tasks with stories

30 views
Skip to first unread message

okrasz

unread,
Dec 17, 2009, 8:41:22 AM12/17/09
to Agilo for Scrum
Hi,
I have created a script that links tasks with stories, so that you do
not have to enter them manually after you import from CSV. The import
did not work for i_links and o_links (it may now though) so I created
a script to recteate them. You just provide story ID and range of task
IDs.

It runs on Linux or requires Cygwin with curl for Windows
(unfortunately my case). Just run without params to get usage help.

One limatation is that it works only with Agilo with HTTP
authentication, not form based authorization, because this is what I
use. This is just when you install Agilo on plain Trac. It wouldn't be
a big deal to update it though, probably just adding proper post data
to login request would make it.

There is also no fancy input check but it wasn't supposed to be bullet
proof tool.

I hope it will help someone. I have saved hours with that probably.

Marcin


#!/bin/sh
# author: Marcin Okraszewski - okrasz_news -at- o2 -dot- pl

if [ $# -lt 6 ] ; then
echo "This script creates links between story and tasks (hopefully
other links as well)."
echo "This version works only with digest authentication, not
through web form."
echo
echo "Syntax:"
echo " $0 AGILO_URL USER PASS STORY_ID TASK_ID_FROM TASK_ID_TO"
echo "Where:"
echo " AGILO_URL - base URL to your Agilo project"
echo " USER - your user name"
echo " PASS - your password"
echo " STORY_ID - ID of the story that will have tasked linked"
echo " TASK_ID_FROM - ID of the first of tasks to link to story
(inclusive)"
echo " TASK_ID_TO - ID of the last task to link to the story
(inclusive)"
echo
echo "Example:"
echo " $0 http://localhost/demo admin adminPass 1 3 5"
echo "This example will link tasks 3-5 to a story 1 "
echo "in Agilo project http://localhost/demo"
echo
echo "NOTE: to link a single task, use the same number "
echo "in TASK_ID_FROM and TASK_ID_TO"
echo
echo "(c) Marcin Okraszewski - okrasz_news -at- o2 -dot- pl"
exit
fi

agilo=$1
user=$2
pass=$3
dst=$4
from=$5
to=$6

cookies=cookies.txt

# login
echo "Logging into $agilo"
curl --digest -u "$user:$pass" -c "$cookies" $agilo/login > /dev/null
# get form token
echo "Obtaining form token"
curl --digest -u "$user:$pass" -b "$cookies" -c "$cookies" $agilo > /
dev/null
formtoken=$( cat cookies.txt | grep trac_form_token | cut -f 7 | tr -d
"\r" )

# create links
for (( i=$from ; i <= $to ; i++ )) ; do
echo -n -e "\nlink $i to $dst "
data="__FORM_TOKEN=$formtoken&url_orig=%2Fav%2Fticket%2F438%3Fpane
%3Dedit&src=$dst&dest=$i&autocomplete_parameter=&cmd=create+link"
curl -e "$agilo/ticket/$dst"'?pane=edit' -b "$cookies" -d "$data"
$agilo/links 2>/dev/null
done

rm "$cookies"

Martin Häcker

unread,
Dec 18, 2009, 6:32:17 AM12/18/09
to ag...@googlegroups.com
Hi Marcin,

> I hope it will help someone. I have saved hours with that probably.

This is nice!

If that is ok with you I would like to link this on the wiki.

Do you have a homepage where I could link to?

Regards,
Martin

okrasz

unread,
Dec 18, 2009, 8:09:15 AM12/18/09
to Agilo for Scrum
I'm fine with linking it anywhere. I'll try to enhance it to support
form based logins as well.

Unfortunately I do not have any homepage. Probably I should ...

Marcin

Martin Häcker

unread,
Jan 18, 2010, 4:03:13 AM1/18/10
to ag...@googlegroups.com
Hi Marcin,

> I'm fine with linking it anywhere. I'll try to enhance it to support
> form based logins as well.
>
> Unfortunately I do not have any homepage. Probably I should ...

Yes you should. :)

I've now linked this version of the script on our wiki at
<https://dev.agile42.com/wiki/agilo/users/Plugins/StoryTaskLinker>

If you put it up on your page, please notify and I will gladly link to
that page instead.

Many Thanks again for your contribution!

Best Regards,
Martin

okrasz

unread,
Jan 18, 2010, 10:27:09 AM1/18/10
to Agilo for Scrum
Hi,
You have remind me that I was to make a universal version which also
allows form based login. I wanted to update wiki but seems it is not
open to public.

I've tested it with Agilo applience 0.7, but unfortunately 0.7 uses
different URL to do the links, so to use it in 0.7 you need to
uncomment the right curl command in the for loop. By default it is for
0.8. I didn't want to make too much integligence to it.

As for the web page, the problem is with time to maitain it.

Marcin

#!/bin/sh
# author: Marcin Okraszewski - okrasz_news -at- o2 -dot- pl

if [ $# -lt 6 ] ; then

echo "This script creates links between story and tasks (and
hopefully other links as well)."
echo

cookies=cookies.txt

# get form token
echo "Obtaining form token"
curl --digest -u "$user:$pass" -c "$cookies" $agilo > /dev/null


formtoken=$( cat cookies.txt | grep trac_form_token | cut -f 7 | tr -d
"\r" )

# login; try to log in either form based or with HTTP authentication
# unfortunately couldn't use post data and HTTP authentication to
# make it in a single run; instead just doing both ways works - either
one will work
echo "Logging into $agilo"
# try logging login for form based login
loginData="__FORM_TOKEN=$formtoken&user=$user&password=$pass"
curl -b "$cookies" -c "$cookies" -d "$loginData" $agilo/login > /dev/
null
# try logging with digest HTTP authentication
curl -b "$cookies" -c "$cookies" --digest -u "$user:$pass" $agilo/
login > /dev/null

# create links
for (( i=$from ; i <= $to ; i++ )) ; do
echo -n -e "\nlink $i to $dst "
data="__FORM_TOKEN=$formtoken&url_orig=%2Fav%2Fticket%2F438%3Fpane
%3Dedit&src=$dst&dest=$i&autocomplete_parameter=&cmd=create+link"

# for agilo 0.8


curl -e "$agilo/ticket/$dst"'?pane=edit' -b "$cookies" -d "$data"
$agilo/links 2>/dev/null

# for agilo 0.7
# curl -e "$agilo/ticket/$dst"'?pane=edit' -b "$cookies" -d "$data"
$agilo/agilo-links 2>/dev/null
done

rm "$cookies"

Martin Häcker

unread,
Jan 19, 2010, 8:38:51 AM1/19/10
to ag...@googlegroups.com
Hi Marcin,

> You have remind me that I was to make a universal version which also
> allows form based login. I wanted to update wiki but seems it is not
> open to public.

You should be able to log in with l/p: agilouser (same as for bug
reporting) after which you should be able to change wiki pages.

> I've tested it with Agilo applience 0.7, but unfortunately 0.7 uses
> different URL to do the links, so to use it in 0.7 you need to
> uncomment the right curl command in the for loop. By default it is for
> 0.8. I didn't want to make too much integligence to it.
>
> As for the web page, the problem is with time to maitain it.

I can so sympathize.

Just setting up a trac for myself with the blog plugin from
<http://trac-hacks.org/wiki/FullBlogPlugin> has worked wonderfully for
myself though (see it at: <http://haecker.me>)

I've updated the version in the wiki - if you have any more changes,
please feel free to update that as well.

Regards,
Martin

No Name

unread,
Oct 20, 2015, 9:35:54 AM10/20/15
to Agilo for Trac
Hi,

Have there been any updates since 2010 on this?

I am looking for an easy way to link tasks to user stories, and the I_links and the O_links don't work via CSV import.

Thanks,
Patrick

Claudio Di Cosmo

unread,
Oct 23, 2015, 12:12:49 PM10/23/15
to ag...@googlegroups.com
Hi Patrick,

Unfortunately the links between tasks and stories are not carried out during the CSV export and import process.
You can try with the new version of the script for agilofortrac.

Sorry for the inconvenience, let me know if you have more issues

Cheers,

Claudio Di Cosmo
Software Engineer
Agilo Software GmbH
Gruenberger Str. 54
10245 Berlin, Germany

claudio...@agilosoftware.com
http://www.agilosoftware.com

Follow us on twitter: http://twitter.com/agiloforscrumhttp://twitter.com/agilofortrac

Amtsgericht Charlottenburg: HRB 127146
CEO Marion Eickmann, Andrea Tomasini
Reply all
Reply to author
Forward
0 new messages