1#!/usr/bin/env perl 2 3use 5.016; 4use utf8; 5use autodie; 6use warnings; 7use FindBin; 8use lib "$FindBin::Bin/lib"; 9use Getopt::Long::Descriptive; 10use JIRACLI qw/get_credentials/; 11 12my ($opt, $usage) = describe_options( 13 '%c %o', 14 ['jiraurl=s', "JIRA server base URL", {default => 'https://jira.cpqd.com.br'}], 15 ['issue|i=s', "Key of the issue to progress", {required => 1}], 16 ['transition-id|t=i', "ID of the transition to make", {required => 1}], 17 ['resolution|r=s', "Resolution name to set"], 18 ['comment|c=s', "Comment string to insert during transition"], 19 ['help|h', "Print usage message and exit"], 20 {show_defaults => 1}, 21); 22 23if ($opt->help) { 24 print $usage->text; 25 exit 0; 26} 27 28my $jira = JIRA::REST->new( 29 $opt->jiraurl, 30 get_credentials(), 31); 32 33my $data = { 34 transition => { id => $opt->transition_id }, 35}; 36 37$data->{fields}{resolution} = { name => $opt->resolution } if $opt->resolution; 38$data->{update}{comment} = [{ add => { body => $opt->comment }}] if $opt->comment; 39 40$jira->POST("/issue/@{[$opt->issue]}/transitions", undef, $data); 41 42 43__END__ 44=encoding utf8 45 46=head1 NAME 47 48transition.pl - Make a transition in a JIRA issue 49 50=head1 SYNOPSIS 51 52 transition.pl [-hn] [long options...] 53 --jiraurl STR JIRA server base URL 54 (default value: https://jira.cpqd.com.br) 55 --issue STR Key of the issue to progress 56 --transition-id INT ID of the transition to make 57 --resolution STR Resolution name to set 58 --comment STR Comment string to insert during transition 59 -n --dont Do not change anything 60 -h --help Print usage message and exit 61 62=head1 DESCRIPTION 63 64This script makes a JIRA issue transition through its workflow. 65 66=head1 OPTIONS 67 68Common options are specified in the L<JIRACLI> documentation. Specific 69options are defined below: 70 71=over 72 73=item * B<--issue STR> 74 75Specifies the issue by its key (e.g. HD-1234). 76 77=item * B<--transition-id INT> 78 79Specifies the transition that should be performed by its numeric ID. You can 80grok it by hovering the mouse over the transition button and looking for the 81C<action=N> part in its URL. 82 83=item * B<--resolution STR> 84 85If the transition leads to a terminal state you can specify a Resolution to 86be set. 87 88=item * B<--comment STR> 89 90Specifies a comment to be added to the issue during the transition. Note 91that the comment will not be added if the transition doesn't have a screen 92associated with it. 93 94=back 95 96=head1 ENVIRONMENT 97 98See the L<JIRACLI> documentation. 99 100=head1 COPYRIGHT 101 102Copyright 2016 CPQD. 103 104This program is free software; you can redistribute it and/or modify 105it under the same terms as Perl itself. 106 107=head1 AUTHOR 108 109Gustavo Chaves <gustavo@cpqd.com.br> 110Lisa Hare <lharey@gmail.com> 111