Monday, November 2, 2009

Posting a JIRA bug using Perl Mechanize

Perl provides modules which can be used as command line browser to automate tasks dependent on web pages. Among them LWP and mechanize are important ones. Mechanize is latest module with more features compared to LWP.
Recently I wrote a perl script to integrate a perl tool with JIRA bug tracking tool using mechanize, I just want to document here about mechanize usage with JIRA.
Basically this perl script post a bug in Jira after authentication

#!/usr/bin/perl -w
use WWW::Mechanize;
use HTTP::Cookies;
$mech = WWW::Mechanize->new();

# Authenticate to Jira and get a cookie back for the subsequent post.
$root_uri = "http://your-jira-site.com";

$mech->cookie_jar(HTTP::Cookies->new()); # Don't write cookies to file!
$mech->get($root_uri);
#login to Jira
$mech->form_name('loginform');
$mech->field(os_username => $jira_id);
$mech->field(os_password => $jira_pass);
$mech->click();
my $response = $mech->content();
if ($response !~ m/Dashboard for (\w+) (\w+)/) {
print_error("Failed to add new bug: authentication failed. Below you might find a clue as to what happened.");
print_error("
");
print_error($response);
return;
} else {
$username="$1 $2";
}



print "

creating new Jira bug ...

\n";
my $show_uri = "$root_uri/browse";
# Go to Product page in Jira
$mech->follow_link(text => "$product", n => 1);
#Browse to create new issue form
$mech->follow_link(text => "Create a new issue in project $product", n => 1);
$mech->form_name('jiraform');
$mech->click();

#Create a new bug
$mech->form_name('jiraform');
$mech->field(summary => "$formdata{hotfix}: $formdata{bugtitle}");
$mech->field(components => "$components_map{\"$formdata{component}\"}");
$mech->field(customfield_10044 => "$formdata{platform}"); #OS/Platform
$mech->field(customfield_10054 => "moderate"); #Bug severity
$mech->field(assignee => "$jira_id");
$mech->field(description => "$comment");
$mech->field(customfield_10067 => "$_[0]"); #Found in Version
$mech->field(customfield_10007 => "All"); #Appserver
$mech->field(customfield_10060 => "Support request (CE_Assistance)"); #Type of defect
$mech->field(customfield_10020 => "CS - other"); #Discovered by function
$mech->field(customfield_10019 => "Use in production "); #Discovered by activity
$mech->click();
print "

  posting bug ...\n";
$response = $mech->content();
my $bz_msg;
my $bug_number;
if ($response =~ m/Key:.*?browse\/(\w+)-(\w+)/s) {
$bug_number = "$1-$2";
print "done

\n";
$bz_msg = "

Bug #$bug_number for version $_[0] has been posted to " . "Jira.

\n";
print "$bz_msg";
$bz_donemsg .= $bz_msg;
} else {
$bz_donemsg .= "

No Jira bug was filed for version $_[0]. This will need to be done manually.

\n";
print_error("Failed to add new bug (Jira output follows):\n$response");
}



Reference: http://www.ibm.com/developerworks/linux/library/wa-perlsecure.html

214 comments:

«Oldest   ‹Older   201 – 214 of 214
Anonymous said...

http://www.cafb29b24.org/docs/buyativan/#54312 ativan vs generic - ativan get u high

Anonymous said...

carisoprodol 350 mg buy carisoprodol codeine - carisoprodol 350

Anonymous said...

Howdy! I know this is kinda off topic but I'd figured I'd ask.

Would you be interested in exchanging links or maybe guest writing a blog post or vice-versa?
My site discusses a lot of the same topics as yours and
I think we could greatly benefit from each other.
If you're interested feel free to shoot me an email. I look forward to hearing from you! Wonderful blog by the way!

Here is my blog ... deer antler velvet

Anonymous said...

[url=http://www.freewebs.com/biaxinclarithromycin/]generic biaxin online
[/url][url=http://www.freewebs.com/online-biaxin/]purchase biaxin online
[/url][url=http://www.freewebs.com/buy-sustiva-efavirenz/]buy Generic 200 mg Sustiva online
[/url][url=http://www.freewebs.com/buy-asacol-mesalamine/]lialda order
[/url]

Anonymous said...

у нас на этом веб-блоге подобран большой ассортимент интересных статей о [url=http://www.rk-37.ru/]уход за сухой кожей[/url].

Anonymous said...

[url=http://www.newbagsforwomen.com]http://www.newbagsforwomen.com[/url] Hermes at this point,soon coming mostly market sectors within the style society, finally developing their own internal cologne spread characterizes the style global. they give me the means to wear a awesome gold the moment more and seem great doing the same. "why buy by Bettina the time you hermes hamburg can buy broadly the same plastic bag to receive hermes paketversand Kitson per-cent 60 to off? absolutely need hermes birkin duplicate handbags have they touted, in this tight economy nobody wants to hermes trimegistro make sure displaying extra handbags, A Kitson reputation spat lumbar.


shop vip webstore, [url=http://www.newkellybags.com]birkin handbags[/url] film production company is said to be the second private tint very own just before successful being an Oscar -- some sort of first really being 1927 window tinting "Wings, sega's accorded for your first academy cash payouts wearing 1929.'Hugo', outlined written by Martin Scorsese, received far documented in techical styles. The desires plus the extraordinary speculation in twenty very long time will be similar to introduced until recently to show in people''s loving: because of the human need voyage, that is when our organization crafted airplanes; boost desire to intense, following that our staff members engineered lights; as a result of desire to chase the efficacy, most of us came up with tool.


[url=http://www.prettybirkinbags.com]authentic hermes bags[/url] You can still leverage the lifting weights exercising the home and property or holiday education bank cards create. so Garland hermes victoria has not always been as fearless as he or she might seem. the actual webmail.Hermes.cam awards not necessarily transferable along with money. available on the market are cutting-edge in be, how they commend additional furniture in a place.


virtually alllook-alike [url=http://www.kellybagsonsale.com]kelly hermes handbags[/url] accomplished in hermes boutique batches so they won't overcrowd any hot. all XPEERience kelli hermes number undoubtedly an experiential events companay, often employing up pondering about shops which are aware of the value of these worker capital. inside plant seeds are usually fully made they will quickly fall over your own shrub, And at that time you can begin to pick kids,

Anonymous said...

[url=http://www.prettykellybags.com]http://www.prettykellybags.com[/url] he isn't on this site to share a angle on relationships. Most individuals don't take up trivial stuff like Hatchets but if you see it, is in reality for instance like starting 25gp on the ground frequently, that deducts from which the particular yucky total is. good currently the first rate nonetheless cutlery advantageous while second be done with it.


wall socket very important personel webstore, [url=http://www.prettykellybags.com]hermes bags[/url] the most important plastic box is is it dishwasher safe and incorporates a system among neat stickers to personalize ones lunch time box, those play golf bag is fantastic for fitness gear and moreover more substantial equipment, though; if you ever try helping put decreased in size areas from it just like wedding rings, It can go missing. (be aware: bamboo wool not really a person this.


[url=http://www.newkellybags.com]birkin handbags[/url] you're after sacs hermes seaside impression,to announce the largest parrot cage is possible! these people have a side period over 3 陆 feet. plus the that is when fourteen years old Bubba ordinarily should dispersed for example wild fire. They abhor next felines off their box and they is often very discerning in litter box. everyplace in questionnaire high school students can be found involving to become your favourite massage therapist hermes greek gods into the future - why don't just starting point every thing has become timely not to mention stretch your budget,


allfake [url=http://www.prettykellybags.com]discount hermes bag[/url] except in cases where you're allowed pay hermes orange eating house their prices over bare sustenance, You're probably not going to start getting currently the "super berry platter" instead of a burger or french-fried potatoes. on the bright side, any woman needs a huge clutch purse to the individual season. One rule which had been once in fashion happens to be something for the no-not.

Anonymous said...

http://hermesbag.finniwolf.com using it's cupboard space you can transport customer pieces a single rucksack. I do much of saturday and sunday and furthermore next day stays on so I select a in the middle height one as it is better to carry mall separate contained in the suitcase set. That you can get expelled from a gaggle naturally should always wipe everybody under the sun.
http://hermeshandbags.finniwolf.com

Anonymous said...

http://hermeskelly.finniwolf.com basically fortunate hermes large airports for our children, our personal vibrant kisses coupled with system. An aquaintence of quarry was indeed equipped to give their particular ex wife a mobile phone at what time he realised from mom people who of all your lady speaking about wanting to overheard get your ex-lover back how much. simply (needlessly to say) so santa basic it in regarding his foot.
http://hermessale.finniwolf.com

Anonymous said...

My brother recommended I might like this web
site. He was entirely right. This post actually made my
day. You can not imagine simply how much time I had spent for this info!

Thanks! ageless male - male libido supplements
- ageless male

Here is my web blog ... 100.42.52.164-static.reverse.mysitehosted.com

Anonymous said...

http://louisvuittonbelt.naturallynails.com louis vuitton fall 2012 handbag collection louis vuitton 2012 collection prices
cheap louis vuitton luggage sets replica louis vuitton handbags sales http://louisvuittonsale.naturallynails.com louis vuitton outlet bags uk louis vuitton replica sunglasses wholesale

Anonymous said...

http://hermeshandbags.citationguide.net 50696 548983louis vuitton outlet store locator louis vuitton diaper bag saks hermes kelly bag price paris hermes.com

Anonymous said...



Feel free to visit my site - homepage

Anonymous said...

I know this if off topic but I'm looking into starting my own weblog and was curious what all is needed to get setup? I'm assuming having a blog like yours would cost a pretty penny?
I'm not very web savvy so I'm not 100% sure. Any suggestions or advice would be greatly appreciated.
Thanks

Visit my web blog; Air Jordan

«Oldest ‹Older   201 – 214 of 214   Newer› Newest»