Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JENKINS-31830] Added support for rcov publisher as part of the RubyM…
…etrics Reports Plugin
- Loading branch information
Showing
4 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...rc/main/docs/examples/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext/rcov.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
job('example') { | ||
publishers { | ||
rcov { | ||
reportDirectory('folder') | ||
totalCoverage(80, 50, 0) | ||
codeCoverage(80, 50, 0) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/RcovContext.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package javaposse.jobdsl.dsl.helpers.publisher | ||
|
||
import groovy.transform.Canonical | ||
import javaposse.jobdsl.dsl.Context | ||
|
||
class RcovContext implements Context { | ||
private static final VALID_TYPES = ['TOTAL_COVERAGE', 'CODE_COVERAGE'] | ||
|
||
final Map<String, MetricEntry> entries = VALID_TYPES.collectEntries { [it, createEntry()] } | ||
String reportDirectory | ||
|
||
/** | ||
* Resolves class names to source file names. | ||
*/ | ||
void reportDirectory(String reportDirectory) { | ||
this.reportDirectory = reportDirectory | ||
} | ||
|
||
/** | ||
* Configure health reporting thresholds for the total coverage. | ||
*/ | ||
void totalCoverage(int healthy, int unhealthy, int unstable) { | ||
addEntry('TOTAL_COVERAGE', healthy, unhealthy, unstable) | ||
} | ||
|
||
/** | ||
* Configure health reporting thresholds for the code coverage. | ||
*/ | ||
void codeCoverage(int healthy, int unhealthy, int unstable) { | ||
addEntry('CODE_COVERAGE', healthy, unhealthy, unstable) | ||
} | ||
|
||
private static createEntry(int healthy = 80, int unhealthy = 0, int unstable = 0) { | ||
new MetricEntry( | ||
healthy: healthy ?: 80, | ||
unhealthy: unhealthy ?: 0, | ||
unstable: unstable ?: 0, | ||
) | ||
} | ||
|
||
private addEntry(String key, int healthy, int unhealthy, int unstable) { | ||
entries[key] = createEntry(healthy, unhealthy, unstable) | ||
} | ||
|
||
@Canonical | ||
static class MetricEntry { | ||
int healthy | ||
int unhealthy | ||
int unstable | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters