Skip to content

Commit a7edc53

Browse files
authored
Add link_issue.pl to examples
Covering the `remotelink` endpoint: https://developer.atlassian.com/server/jira/platform/jira-rest-api-for-remote-issue-links/
1 parent 5de3eb6 commit a7edc53

1 file changed

Lines changed: 95 additions & 0 deletions

File tree

examples/link_issue.pl

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.016;
4+
use utf8;
5+
use warnings;
6+
use FindBin;
7+
use lib "$FindBin::Bin/lib";
8+
use Getopt::Long::Descriptive;
9+
use JIRACLI qw/get_credentials/;
10+
11+
my ($opt, $usage) = describe_options(
12+
'%c %o',
13+
['jiraurl=s', "JIRA server base URL", {required => 1}],
14+
['issue|i=s', "Key of the issue to progress", {required => 1}],
15+
['url|u=s', "URL of the link", {required => 1}],
16+
['title|t=s', "Title of the link", {required => 1}],
17+
['help|h', "Print usage message and exit"],
18+
{show_defaults => 1},
19+
);
20+
21+
if ($opt->help) {
22+
print $usage->text;
23+
exit 0;
24+
}
25+
26+
my $jira = JIRA::REST->new(
27+
$opt->jiraurl,
28+
get_credentials(),
29+
);
30+
31+
my $link = {
32+
object => {
33+
url => $opt->url, # eg. 'https://example.com/'
34+
title => $opt->title # eg. 'Link to the website'
35+
}
36+
}; # See https://developer.atlassian.com/server/jira/platform/jira-rest-api-for-remote-issue-links/
37+
38+
$jira->POST("/issue/@{[$opt->issue]}/remotelink", undef, $link);
39+
40+
41+
__END__
42+
=encoding utf8
43+
44+
=head1 NAME
45+
46+
link_issue.pl - Link a JIRA issue
47+
48+
=head1 SYNOPSIS
49+
50+
link_issue.pl [-ghir] [long options...]
51+
--jiraurl STR JIRA server base URL
52+
-i STR --issue STR Key of the issue to progress
53+
-u STR --url STR URL of the link
54+
-t STR --title STR Title of the link
55+
-h --help Print usage message and exit
56+
57+
=head1 DESCRIPTION
58+
59+
This script adds a link to a JIRA issue.
60+
61+
=head1 OPTIONS
62+
63+
Common options are specified in the L<JIRACLI> documentation. Specific
64+
options are defined below:
65+
66+
=over
67+
68+
=item * B<--issue STR>
69+
70+
Specifies the issue by its key (e.g. HD-1234).
71+
72+
=item * B<--url STR>
73+
74+
URL of the link.
75+
76+
=item * B<--title STR>
77+
78+
Title of the link.
79+
80+
=back
81+
82+
=head1 ENVIRONMENT
83+
84+
See the L<JIRACLI> documentation.
85+
86+
=head1 COPYRIGHT
87+
88+
Copyright 2019-2024 CPQD.
89+
90+
This program is free software; you can redistribute it and/or modify
91+
it under the same terms as Perl itself.
92+
93+
=head1 AUTHOR
94+
95+
Elvin Aslanov <rwp.primary@gmail.com>

0 commit comments

Comments
 (0)