7 =head1 NAME updateWatchLists.pl
9 Copy CC lists from Bugzilla -> JIRA
17 Andrew DeFaria <Andrew@ClearSCM.com>
25 Thu Mar 20 10:11:53 PDT 2014
35 Updates JIRA watchlists by copying the CC list information from Bugzilla
37 $ updateWatchLists.pl [-login <login email>] [-products product1,
38 product2,...] [-[no]exec]
39 [-verbose] [-help] [-usage]
43 -v|erbose: Display progress output
44 -he|lp: Display full help
45 -usa|ge: Display usage
46 -[no]e|xec: Whether or not to update JIRA. -noexec says only
47 tell me what you would have updated.
48 -use|rname: Username to log into JIRA with (Default: jira-admin)
49 -p|assword: Password to log into JIRA with (Default: jira-admin's
51 -bugzillaserver: Machine where Bugzilla lives (Default: bugs-dev)
52 -jiraserver: Machine where Jira lives (Default: jira-dev)
53 -bugi|ds: Comma separated list of BugIDs to process
54 -f|ile: File of BugIDs, one per line
58 This script updates JIRA watchlists by copying the CC List information from
64 use lib "$FindBin::Bin/lib";
80 # Login should be the email address of the bugzilla account which has
81 # priviledges to create products and components
84 bugzillaserver => $ENV{BUGZILLASERVER} || 'bugs-dev',
85 jiraserver => $ENV{JIRASERVER} || 'jira-dev:8081',
86 username => 'jira-admin',
87 password => 'jira-admin',
88 usage => sub { pod2usage },
89 help => sub { pod2usage (-verbose => 2)},
90 verbose => sub { set_verbose },
95 my ($bugzilla, $jira);
118 open my $file, '<', $opts{file}
119 or die "Unable to open $opts{file} - $!";
121 $opts{bugids} = [<$file>];
123 chomp @{$opts{bugids}};
127 push @bugids, (split /,/, join (',', $_)) for (@{$opts{bugids}});
129 $opts{bugids} = [@bugids];
132 pod2usage 'Must specify -bugids <bugid>[,<bugid>,...] or -file <filename>'
133 unless $opts{bugids};
135 openBugzilla $opts{bugzillaserver}
136 or $log->err ("Unable to connect to $opts{bugzillaserver}", 1);
138 Connect2JIRA ($opts{username}, $opts{password}, $opts{jiraserver})
139 or $log->err ("Unable to connect to $opts{jiraserver}", 1);
141 for (@{$opts{bugids}}) {
142 my $issue = findIssue $_;
144 if ($issue =~ /^Future JIRA Issue/ or $issue =~ /^Unable to find/) {
147 my %watchers = getWatchers $_;
149 $log->msg ('Found ' . scalar (keys %watchers) . " watchers for JIRA Issue $issue");
151 my $result = updateIssueWatchers ($issue, %watchers);
153 if ($result =~ /^Unable to/) {
154 $total{'Missing JIRA Issues'}++;
158 $total{'Issues updated'}++;
163 display_duration $startTime, $log;
165 Stats (\%total, $log) unless $opts{quiet};