@@ -1,41 +1,33 | |||||
1 | package Jobs; |
|
1 | package Jobs; | |
2 | use File::Basename; |
|
2 | use File::Basename; | |
3 |
use Config:: |
|
3 | use Config::Tiny; | |
4 |
|
||||
5 | # NOTE: |
|
|||
6 | # Config::IniFiles is from CPAN |
|
|||
7 | # http://search.cpan.org/dist/Config-IniFiles-2.72/ |
|
|||
8 | # |
|
|||
9 | # On windows (ActivePerl) install it from command line by calling: |
|
|||
10 | # ppm install Config-IniFiles |
|
|||
11 |
|
4 | |||
12 | sub get { |
|
5 | sub get { | |
13 | my $inifile = shift; |
|
6 | my $inifile = shift; | |
14 | my $jobname = shift; |
|
7 | my $jobname = shift; | |
15 |
|
8 | |||
16 | # Strip the prefix from job name when using ${bamboo.buildPlanName} |
|
9 | # Strip the prefix from job name when using ${bamboo.buildPlanName} | |
17 | my $prefix = "Digia Qt Commercial - Chart component - "; |
|
10 | my $prefix = "Digia Qt Commercial - Chart component - "; | |
18 | $jobname =~ s/$prefix//; |
|
11 | $jobname =~ s/$prefix//; | |
19 |
|
12 | |||
20 | # read ini file |
|
13 | # read ini file | |
21 | my %cfg; |
|
14 | my $cfg = Config::Tiny->read( $inifile ); | |
22 | tie %cfg, 'Config::IniFiles', ( -file => $inifile ); |
|
15 | ||
23 |
|
||||
24 | # get section from ini by jobname |
|
16 | # get section from ini by jobname | |
25 | my %job = %{$cfg{$jobname}}; |
|
17 | my %job = %{$cfg->{$jobname}}; | |
26 | if (!%job) { |
|
18 | if (!%job) { | |
27 | die ("Unknown jobname! Check $inifile and bamboo job name."); |
|
19 | die ("Unknown jobname! Check $inifile and bamboo job name."); | |
28 | } |
|
20 | } | |
29 |
|
21 | |||
30 | # print out the ini settings |
|
22 | # print out the ini settings | |
31 | print "\n\nini file: $inifile\n"; |
|
23 | print "\n\nini file: $inifile\n"; | |
32 | print "[$jobname]\n"; |
|
24 | print "[$jobname]\n"; | |
33 | foreach (keys %job) { |
|
25 | foreach (keys %job) { | |
34 | print $_ . "=" . $job{$_} . "\n"; |
|
26 | print $_ . "=" . $job{$_} . "\n"; | |
35 | } |
|
27 | } | |
36 | print "\n"; |
|
28 | print "\n"; | |
37 |
|
29 | |||
38 | return %job; |
|
30 | return %job; | |
39 | } |
|
31 | } | |
40 |
|
32 | |||
41 | 1; No newline at end of file |
|
33 | 1; |
General Comments 0
You need to be logged in to leave comments.
Login now