This repository has been archived by the owner on Feb 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ec_setup.pl
75 lines (57 loc) · 1.86 KB
/
ec_setup.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use Cwd;
use File::Spec;
use POSIX;
use MIME::Base64;
use File::Temp qw(tempfile tempdir);
use Archive::Zip;
use Digest::MD5 qw(md5_hex);
my $dir = getcwd;
my $logfile ="";
my $pluginDir;
if ( defined $ENV{QUERY_STRING} ) { # Promotion through UI
$pluginDir = $ENV{COMMANDER_PLUGINS} . "/$pluginName";
}
else {
my $commanderPluginDir = $commander->getProperty('/server/settings/pluginsDirectory')->findvalue('//value');
# We are not checking for the directory, because we can run this script on a different machine
$pluginDir = "$commanderPluginDir/$pluginName";
}
$logfile .= "Plugin directory is $pluginDir";
$commander->setProperty("/plugins/$pluginName/project/pluginDir", {value=>$pluginDir});
$logfile .= "Plugin Name: $pluginName\n";
$logfile .= "Current directory: $dir\n";
# Evaluate promote.groovy or demote.groovy based on whether plugin is being promoted or demoted ($promoteAction)
local $/ = undef;
my $demoteDsl = q{
# demote.groovy placeholder
};
my $promoteDsl = q{
# promote.groovy placeholder
};
my $dsl;
if ($promoteAction eq 'promote') {
$dsl = $promoteDsl;
}
else {
$dsl = $demoteDsl;
}
my $serverLibraryPath = "$pluginDir/dsl";
my $dslReponse = $commander->evalDsl(
$dsl, {
parameters => qq(
{
"pluginName":"$pluginName",
"upgradeAction":"$upgradeAction",
"otherPluginName":"$otherPluginName"
}
),
debug => 'false',
serverLibraryPath => $serverLibraryPath,
},
);
$logfile .= $dslReponse->findnodes_as_string("/");
my $errorMessage = $commander->getError();
# Create output property for plugin setup debug logs
my $nowString = localtime;
$commander->setProperty( "/plugins/$pluginName/project/logs/$nowString", { value => $logfile } );
die $errorMessage unless !$errorMessage;