forked from electric-cloud/PluginLite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec_setup.pl
executable file
·46 lines (42 loc) · 1.42 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
use Cwd;
use File::Spec;
my $dir = getcwd;
my $logfile ="";
my $pluginDir;
if(defined $ENV{'QUERY_STRING'}) { # Promotion through UI
$logfile = "../../$pluginName/ec_setup.log";
$pluginDir = File::Spec->rel2abs( "../../$pluginName" );
} else {
$logfile = "$ENV{'TEMP'}/ec_setup.log";
$pluginDir = $dir;
}
$commander->setProperty("/plugins/$pluginName/project/pluginDir",{value=>$pluginDir});
open(my $fh, '>', $logfile) or die "Could not open file '$logfile' $!";
print $fh "Plugin Name: $pluginName\n";
print $fh "Current directory: $dir\n";
# Evaluate promote.groovy or demote.groovy based on whether plugin is being promoted or demoted ($promoteAction)
local $/ = undef;
# If env variable QUERY_STRING exists:
if(defined $ENV{'QUERY_STRING'}) { # Promotion through UI
open FILE, "../../$pluginName/dsl/$promoteAction.groovy" or die "Couldn't open file: $!";
} else { # Promotion from the command line
open FILE, "dsl/$promoteAction.groovy" or die "Couldn't open file: $!";
}
my $dsl = <FILE>;
close FILE;
my $dslReponse = $commander->evalDsl($dsl,
{parameters=>qq(
{
"pluginName":"$pluginName"
}
)}
)->findnodes_as_string("/");
print $fh $dslReponse;
close $fh;
# Create log file output property
open LOGFILE, $logfile or die "Couldn't open file: $!";
my $logFileContent = <LOGFILE>;
my $propertyResponse = $commander->setProperty("/plugins/$pluginName/project/ec_setup.log",
{value=>$logFileContent}
);
close LOGFILE;