Initial Commit
This commit is contained in:
46
updateJiraBaseURL
Executable file
46
updateJiraBaseURL
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use 5.010;
|
||||
use Getopt::Long qw(GetOptions);
|
||||
|
||||
|
||||
my $username;
|
||||
my $password;
|
||||
my $serverurl;
|
||||
my $baseurl;
|
||||
my $updateURL;
|
||||
my $updateArgs;
|
||||
my $response;
|
||||
my $cmd;
|
||||
my $isJira;
|
||||
|
||||
GetOptions('username=s' => \$username,
|
||||
'password=s' => \$password,
|
||||
'baseurl=s' => \$baseurl) or usage();
|
||||
|
||||
if (!defined $username) { $username = "admin" }
|
||||
if (!defined $password) { $password = "admin" }
|
||||
if (!defined $baseurl) { usage(); }
|
||||
|
||||
$updateURL = "$baseurl/rest/api/2/settings/baseUrl";
|
||||
$updateArgs = "-X PUT -H \"X-Atlassian-Token: no-check\" -u \"$username:$password\" -H \"Content-Type:application/json\" -d \"$baseurl\"";
|
||||
|
||||
|
||||
# use curl to update the baseURL
|
||||
$cmd = "curl -s -S -o /dev/null -w %{http_code} $updateArgs $updateURL";
|
||||
print "updating BaseURL with: $cmd\n";
|
||||
$response = `$cmd`;
|
||||
print "http response: $response\n";
|
||||
|
||||
|
||||
if ($response == "204") { print "Jira baseURL updated successfully\n"; }
|
||||
else { print "FAILED: http status code on update: $response\n"; exit 1; }
|
||||
exit 0;
|
||||
|
||||
sub usage
|
||||
{
|
||||
print "Usage: $0 --baseurl newBaseURL [--username adminUsername] [--password adminPassword]\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user