From cf88bc6c41e014c78d193a12f700d0738aac9552 Mon Sep 17 00:00:00 2001 From: Dominic Hargreaves Date: Thu, 10 Sep 2015 14:23:35 +0100 Subject: [PATCH 1/4] jenkins_: Reformat status mapping for better readability --- plugins/jenkins/jenkins_ | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/jenkins/jenkins_ b/plugins/jenkins/jenkins_ index 6112c8c2..edab804f 100644 --- a/plugins/jenkins/jenkins_ +++ b/plugins/jenkins/jenkins_ @@ -66,7 +66,18 @@ my $wgetBin = "/usr/bin/wget"; my $type = basename($0); $type =~ s/jenkins_//; -my %states = ('blue' =>'stable', 'blue_anime' =>'stable', 'yellow'=>'unstable', 'yellow_anime'=>'unstable', 'red'=>'failing', 'red_anime'=>'failing', 'disabled'=>'disabled', 'notbuilt_anime' =>'disabled', 'aborted'=>'failing', 'aborted_anime'=>'failing' ); +my %states = ( + 'blue' =>'stable', + 'blue_anime' =>'stable', + 'yellow'=>'unstable', + 'yellow_anime'=>'unstable', + 'red'=>'failing', + 'red_anime'=>'failing', + 'disabled'=>'disabled', + 'notbuilt_anime' =>'disabled', + 'aborted'=>'failing', + 'aborted_anime'=>'failing' +); my %counts = ('blue' => 0, 'yellow'=>0, 'red'=>0, 'disabled'=>0); if ( exists $ARGV[0] and $ARGV[0] eq "config" ) { From b2080e1178ea401d4aba8f9b9ef33875671d2b33 Mon Sep 17 00:00:00 2001 From: Dominic Hargreaves Date: Thu, 10 Sep 2015 14:25:26 +0100 Subject: [PATCH 2/4] jenkins_: Fix uninitialized values warning with unmapped states --- plugins/jenkins/jenkins_ | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/jenkins/jenkins_ b/plugins/jenkins/jenkins_ index edab804f..d60ef71c 100644 --- a/plugins/jenkins/jenkins_ +++ b/plugins/jenkins/jenkins_ @@ -134,7 +134,11 @@ if ( exists $ARGV[0] and $ARGV[0] eq "config" ) { my $result = `$cmd/api/json`; my $parsed = decode_json($result); foreach my $cur(@{$parsed->{'jobs'}}) { - $counts{$cur->{'color'}} += 1; + if (defined $states{$cur->{'color'}}) { + $counts{$cur->{'color'}} += 1; + } else { + warn "Ignoring unknown color " . $cur->{'color'} . "\n" + } } foreach my $status (keys %counts) { From 8ad8e1b9e21c107ea4aae697248de1c93536c9f5 Mon Sep 17 00:00:00 2001 From: Dominic Hargreaves Date: Thu, 10 Sep 2015 14:26:05 +0100 Subject: [PATCH 3/4] jenkins_: Add a missing mapping for notbuilt --- plugins/jenkins/jenkins_ | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/jenkins/jenkins_ b/plugins/jenkins/jenkins_ index d60ef71c..d37c2605 100644 --- a/plugins/jenkins/jenkins_ +++ b/plugins/jenkins/jenkins_ @@ -74,6 +74,7 @@ my %states = ( 'red'=>'failing', 'red_anime'=>'failing', 'disabled'=>'disabled', + 'notbuilt' => 'disabled', 'notbuilt_anime' =>'disabled', 'aborted'=>'failing', 'aborted_anime'=>'failing' From 3e70ec380380d433cc2f178bf4a9e135466e3eff Mon Sep 17 00:00:00 2001 From: Dominic Hargreaves Date: Thu, 10 Sep 2015 14:26:51 +0100 Subject: [PATCH 4/4] jenkins_: Accumulate build result counts correctly The previous behaviour ignored initial statuses other than blue, yellow, red, disabled --- plugins/jenkins/jenkins_ | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/jenkins/jenkins_ b/plugins/jenkins/jenkins_ index d37c2605..7dd34068 100644 --- a/plugins/jenkins/jenkins_ +++ b/plugins/jenkins/jenkins_ @@ -79,7 +79,7 @@ my %states = ( 'aborted'=>'failing', 'aborted_anime'=>'failing' ); -my %counts = ('blue' => 0, 'yellow'=>0, 'red'=>0, 'disabled'=>0); +my %counts = ('stable' => 0, 'unstable'=>0, 'failing'=>0, 'disabled'=>0); if ( exists $ARGV[0] and $ARGV[0] eq "config" ) { if( $type eq "results" ) { @@ -136,14 +136,14 @@ if ( exists $ARGV[0] and $ARGV[0] eq "config" ) { my $parsed = decode_json($result); foreach my $cur(@{$parsed->{'jobs'}}) { if (defined $states{$cur->{'color'}}) { - $counts{$cur->{'color'}} += 1; + $counts{$states{$cur->{'color'}}} += 1; } else { warn "Ignoring unknown color " . $cur->{'color'} . "\n" } } foreach my $status (keys %counts) { - print "build_$states{$status}.value $counts{$status}\n"; + print "build_$status.value $counts{$status}\n"; } exit; }