Skip to content

Commit

Permalink
add configuration for build points
Browse files Browse the repository at this point in the history
  • Loading branch information
octavian-h committed Dec 20, 2013
1 parent bf811b9 commit c6b1874
Show file tree
Hide file tree
Showing 50 changed files with 142 additions and 485 deletions.
34 changes: 26 additions & 8 deletions src/main/java/hudson/plugins/cigame/GameDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import hudson.plugins.cigame.model.RuleBook;
import hudson.plugins.cigame.model.RuleSet;
import hudson.plugins.cigame.model.ScoreLevel;
import hudson.plugins.cigame.rules.build.BuildResultRule;
import hudson.plugins.cigame.rules.build.BuildRuleSet;
import hudson.plugins.cigame.rules.plugins.checkstyle.CheckstyleRuleSet;
import hudson.plugins.cigame.rules.plugins.findbugs.FindBugsRuleSet;
import hudson.plugins.cigame.rules.plugins.opentasks.OpenTasksRuleSet;
import hudson.plugins.cigame.rules.plugins.pmd.PmdRuleSet;
import hudson.plugins.cigame.rules.plugins.violation.ViolationsRuleSet;
import hudson.plugins.cigame.rules.plugins.warnings.WarningsRuleSet;
import hudson.plugins.cigame.rules.unittesting.UnitTestingRuleSet;
import hudson.plugins.cigame.rules.unittesting.*;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import net.sf.json.JSONObject;
Expand All @@ -33,16 +34,17 @@
public class GameDescriptor extends BuildStepDescriptor<Publisher> {

public static final String ACTION_LOGO_SMALL = "/plugin/ci-game/icons/24x24/game.png"; //$NON-NLS-1$

private transient RuleBook rulebook;
private transient List<ScoreLevel> scoreLevels;
private boolean namesAreCaseSensitive = true;
private int passedTestIncreasingPoints = 1;
private int passedTestDecreasingPoints = 0;
private int failedTestIncreasingPoints = -1;
private int failedTestDecreasingPoints = 0;
private int skippedTestIncreasingPoints = 0;
private int skippedTestDecreasingPoints = 0;
private int passedTestIncreasingPoints = IncreasingPassedTestsRule.DEFAULT_POINTS;
private int passedTestDecreasingPoints = DecreasingPassedTestsRule.DEFAULT_POINTS;
private int failedTestIncreasingPoints = IncreasingFailedTestsRule.DEFAULT_POINTS;
private int failedTestDecreasingPoints = DecreasingFailedTestsRule.DEFAULT_POINTS;
private int skippedTestIncreasingPoints = IncreasingSkippedTestsRule.DEFAULT_POINTS;
private int skippedTestDecreasingPoints = DecreasingSkippedTestsRule.DEFAULT_POINTS;
private int buildSuccessPoints = BuildResultRule.DEFAULT_SUCCESS_POINTS;
private int buildFailurePoints = BuildResultRule.DEFAULT_FAILURE_POINTS;

public GameDescriptor() {
super(GamePublisher.class);
Expand Down Expand Up @@ -184,4 +186,20 @@ public int getSkippedTestDecreasingPoints() {
public void setSkippedTestDecreasingPoints(int skippedTestDecreasingPoints) {
this.skippedTestDecreasingPoints = skippedTestDecreasingPoints;
}

public int getBuildSuccessPoints() {
return buildSuccessPoints;
}

public void setBuildSuccessPoints(int buildSuccessPoints) {
this.buildSuccessPoints = buildSuccessPoints;
}

public int getBuildFailurePoints() {
return buildFailurePoints;
}

public void setBuildFailurePoints(int buildFailurePoints) {
this.buildFailurePoints = buildFailurePoints;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@

import hudson.model.AbstractBuild;
import hudson.model.Result;
import hudson.plugins.cigame.GameDescriptor;
import hudson.plugins.cigame.model.Rule;
import hudson.plugins.cigame.model.RuleResult;
import jenkins.model.Jenkins;

/**
* Rule that gives points on the result of the build.
*/
public class BuildResultRule implements Rule<Void> {

public static final int DEFAULT_SUCCESS_POINTS = 1;
public static final int DEFAULT_FAILURE_POINTS = -10;
private int failurePoints;
private int successPoints;

public BuildResultRule() {
this(1, -10);
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
if (gameDescriptor != null) {
this.successPoints = DEFAULT_SUCCESS_POINTS;
this.failurePoints = DEFAULT_FAILURE_POINTS;
} else {
this.successPoints = gameDescriptor.getBuildSuccessPoints();
this.failurePoints = gameDescriptor.getBuildFailurePoints();
}
}

public BuildResultRule(int successPoints, int failurePoints) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
public class DecreasingFailedTestsRule extends AbstractFailedTestsRule {

private static final int DEFAULT_POINTS = 0;
public static final int DEFAULT_POINTS = 0;

private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
public class DecreasingPassedTestsRule extends AbstractPassedTestsRule {

private static final int DEFAULT_POINTS = 1;
public static final int DEFAULT_POINTS = 0;

private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
public class DecreasingSkippedTestsRule extends AbstractSkippedTestsRule {

private static final int DEFAULT_POINTS = 0;
public static final int DEFAULT_POINTS = 0;

private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public class IncreasingFailedTestsRule extends AbstractFailedTestsRule {

private static final int DEFAULT_POINTS = -1;
public static final int DEFAULT_POINTS = -1;

private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public class IncreasingPassedTestsRule extends AbstractPassedTestsRule {

private static final int DEFAULT_POINTS = 1;
public static final int DEFAULT_POINTS = 1;

private int getPoints() {
GameDescriptor gameDescriptor = Hudson.getInstance().getDescriptorByType(GameDescriptor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
public class IncreasingSkippedTestsRule extends AbstractSkippedTestsRule {

private static final int DEFAULT_POINTS = 0;
public static final int DEFAULT_POINTS = 0;

private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
<j:jelly xmlns:j="jelly:core"
xmlns:f="/lib/form">
<f:section title="${%cigame.title}">
<f:entry title="${%cigame.namesarecasesensitive}" help="/plugin/ci-game/namesarecasesensitive.html">
<f:checkbox field="namesAreCaseSensitive"/>
<f:entry title="${%cigame.namesAreCaseSensitive}"
field="namesAreCaseSensitive">
<f:checkbox/>
</f:entry>

<f:advanced title="${%cigame.unittests.subtitle}">
<f:entry title="${%cigame.unittests.subtitle}">
<table width="100%" style="border: 1px solid #aaa">
<table>
<f:entry title="${%cigame.unittests.marksForIncreasingPassedTestsByOne}"
field="passedTestIncreasingPoints">
<f:textbox/>
Expand Down Expand Up @@ -35,5 +37,20 @@
</table>
</f:entry>
</f:advanced>

<f:advanced title="${%cigame.build.subtitle}">
<f:entry title="${%cigame.build.subtitle}">
<table>
<f:entry title="${%cigame.build.marksForSuccessfulBuild}"
field="buildSuccessPoints">
<f:textbox/>
</f:entry>
<f:entry title="${%cigame.build.marksForFailedBuild}"
field="buildFailurePoints">
<f:textbox/>
</f:entry>
</table>
</f:entry>
</f:advanced>
</f:section>
</j:jelly>
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

cigame.namesarecasesensitive=User names are case sensitive
cigame.namesAreCaseSensitive=User names are case sensitive
cigame.title=Continuous integration game

cigame.unittests.subtitle=Unit Tests

cigame.unittests.subtitle=Points for Unit Tests
cigame.unittests.marksForIncreasingPassedTestsByOne=Points for increasing Passed Tests
cigame.unittests.marksForDecreasingPassedTestsByOne=Points for decreasing Passed Tests
cigame.unittests.marksForIncreasingFailedTestsByOne=Points for increasing Failed Tests
cigame.unittests.marksForDecreasingFailedTestsByOne=Points for decreasing Failed Tests
cigame.unittests.marksForIncreasingSkippedTestsByOne=Points for increasing Skipped Tests
cigame.unittests.marksForDecreasingSkippedTestsByOne=Points for decreasing Skipped Tests

cigame.build.subtitle=Points for Build
cigame.build.marksForSuccessfulBuild=Points for build successfully
cigame.build.marksForFailedBuild=Points for failing the build

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
# The MIT License
#
# Copyright (c) 2004-2010, Sun Microsystems, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
cigame.namesAreCaseSensitive=Les noms d'utilisateurs sont sensibles à la casse
cigame.title=Jeu de l'intégration continue

cigame.namesarecasesensitive=Les noms d''utilisateurs sont sensibles \u00E0 la casse
cigame.title=Jeu de l''int\u00E9gration continue
cigame.unittests.subtitle=Tests unitaires
cigame.unittests.marksForIncreasingPassedTestsByOne=Points pour augmenter tests réussis
cigame.unittests.marksForDecreasingPassedTestsByOne=Points pour diminuer tests réussis
cigame.unittests.marksForIncreasingFailedTestsByOne=Points pour augmenter l'échec des tests
cigame.unittests.marksForDecreasingFailedTestsByOne=Points pour diminuer l'échec des tests
cigame.unittests.marksForIncreasingSkippedTestsByOne=Points pour augmenter tests ignor\u00E9s
cigame.unittests.marksForDecreasingSkippedTestsByOne=Points pour diminuer tests ignor\u00E9s

cigame.build.subtitle=Build
cigame.build.marksForSuccessfulBuild=Points pour build avec succès
cigame.build.marksForFailedBuild=Points de refus de la build

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
How many marks are given for the user for failing the build
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
How many marks are given for the user for building with success.
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<div>
<p>
How many marks given for the user for decreasing the number of Failed Tests by one
</p>
How many marks are given for the user for decreasing the number of Failed Tests by one.
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<div>
<p>
How many marks given for the user for increasing the number of Failed Tests by one
</p>
How many marks are given for the user for increasing the number of Failed Tests by one
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div>
<span>
The checkbox decides if the game should treat the user names in Jenkins case sensitive or not.
Jenkins treats user names as case sensitive, which mean that user "John" is not the same user as "john".
Some SCMs make it possible to login with the same user but with different casing,
which means that to Jenkins there are separate users.
This introduces a problem in the game as one real user can have several Jenkins users.
</span>
<br/>
<br/>
<span>
If this checkbox is enabled, the game will treat all users as separate, just like Jenkins does.
If this checkbox is disabled, the game will make case insensitive look ups of the user names
which mean points awarded to "John" and "john" will be awarded to the same user.
</span>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<div>
<p>
How many marks given for the user for decreasing the number of Passed Tests by one
</p>
How many marks are given for the user for decreasing the number of Passed Tests by one
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<div>
<p>
How many marks given for the user for increasing the number of Passed Tests by one
</p>
How many marks are given for the user for increasing the number of Passed Tests by one
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<div>
<p>
How many marks given for the user for decreasing the number of Skipped Tests by one
</p>
How many marks are given for the user for decreasing the number of Skipped Tests by one
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<div>
<p>
How many marks given for the user for increasing the number of Skipped Tests by one
</p>
How many marks are given for the user for increasing the number of Skipped Tests by one
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<l:main-panel>
<form method="post" action="importScores">
<div>
<label for="jsonData">Score file</label>
<label for="jsonData">${%cigame.Leaderboard.scoreFile}</label>
<input type="file" name="jsonData" jsonAware="yes"/>
</div>
<div>
<f:submit value="Import scores"/>
<f:submit value="${%cigame.Leaderboard.importScores"/>
</div>
</form>
</l:main-panel>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cigame.Leaderboard.scoreFile=Score file
cigame.Leaderboard.importScores=Import scores

0 comments on commit c6b1874

Please sign in to comment.