Skip to content
Permalink
Browse files

Merge pull request #255 from scoheb/label-clash

Allow override of code-review/verified value from job
  • Loading branch information...
rsandell committed Oct 26, 2015
2 parents d0541c8 + 3a5273e commit 9e92f863ed711452f6732ab836b9a88e486c0d8c
Showing with 485 additions and 204 deletions.
  1. +83 −71 src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/config/Config.java
  2. +10 −10 src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/config/IGerritHudsonTriggerConfig.java
  3. +37 −18 src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java
  4. +12 −6 ...yericsson/hudson/plugins/gerrit/trigger/gerritnotifier/job/rest/BuildCompletedRestCommandJob.java
  5. +10 −20 src/main/resources/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritServer/index.jelly
  6. +5 −0 src/main/webapp/help-GerritBuildFailedCodeReview.html
  7. +5 −0 src/main/webapp/help-GerritBuildFailedVerified.html
  8. +5 −0 src/main/webapp/help-GerritBuildNotBuiltCodeReview.html
  9. +5 −0 src/main/webapp/help-GerritBuildNotBuiltVerified.html
  10. +5 −0 src/main/webapp/help-GerritBuildStartedCodeReview.html
  11. +5 −0 src/main/webapp/help-GerritBuildStartedVerified.html
  12. +5 −0 src/main/webapp/help-GerritBuildSuccessfulCodeReview.html
  13. +5 −0 src/main/webapp/help-GerritBuildSuccessfulVerified.html
  14. +5 −0 src/main/webapp/help-GerritBuildUnstableCodeReview.html
  15. +5 −0 src/main/webapp/help-GerritBuildUnstableVerified.html
  16. +20 −20 src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/config/ConfigTest.java
  17. +6 −2 ...sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpanderParameterizedTest.java
  18. +24 −12 ...ericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpanderSkipVoteParameterTest.java
  19. +97 −11 ...est/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpanderTest.java
  20. +112 −24 src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/MockGerritHudsonTriggerConfig.java
  21. +14 −0 src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/Setup.java
  22. +10 −10 src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/utils/MockPluginCheckerConfig.java
@@ -50,10 +50,6 @@
import java.util.List;
import java.util.concurrent.TimeUnit;





//CS IGNORE LineLength FOR NEXT 11 LINES. REASON: static import.
import static com.sonymobile.tools.gerrit.gerritevents.GerritDefaultValues.DEFAULT_BUILD_SCHEDULE_DELAY;
import static com.sonymobile.tools.gerrit.gerritevents.GerritDefaultValues.DEFAULT_DYNAMIC_CONFIG_REFRESH_INTERVAL;
@@ -77,30 +73,14 @@
* Default verified vote to Gerrit when a build is started.
*/
public static final int DEFAULT_GERRIT_BUILD_STARTED_VERIFIED_VALUE = 0;
/**
* Default code review vote to Gerrit when a build is started.
*/
public static final int DEFAULT_GERRIT_BUILD_STARTED_CODE_REVIEW_VALUE = 0;
/**
* Default verified vote to Gerrit when a build is unstable.
*/
public static final int DEFAULT_GERRIT_BUILD_UNSTABLE_VERIFIED_VALUE = 0;
/**
* Default code review vote to Gerrit when a build is unstable.
*/
public static final int DEFAULT_GERRIT_BUILD_UNSTABLE_CODE_REVIEW_VALUE = -1;
/**
* Default verified vote to Gerrit when a build is failed.
*/
public static final int DEFAULT_GERRIT_BUILD_FAILURE_VERIFIED_VALUE = -1;
/**
* Default code review vote to Gerrit when a build is failed.
*/
public static final int DEFAULT_GERRIT_BUILD_FAILURE_CODE_REVIEW_VALUE = 0;
/**
* Default code review vote to Gerrit when a build is successful.
*/
public static final int DEFAULT_GERRIT_BUILD_SUCCESSFUL_CODE_REVIEW_VALUE = 0;
/**
* Default verified vote to Gerrit when a build is successful.
*/
@@ -109,11 +89,26 @@
* Default verified vote to Gerrit when a build is not built.
*/
public static final int DEFAULT_GERRIT_BUILD_NOT_BUILT_VERIFIED_VALUE = 0;
/**
- * Default code review vote to Gerrit when a build is started.
*/
public static final int DEFAULT_GERRIT_BUILD_STARTED_CODE_REVIEW_VALUE = 0;
/**
* Default code review vote to Gerrit when a build is unstable.
*/
public static final int DEFAULT_GERRIT_BUILD_UNSTABLE_CODE_REVIEW_VALUE = -1;
/**
* Default code review vote to Gerrit when a build is failed.
*/
public static final int DEFAULT_GERRIT_BUILD_FAILURE_CODE_REVIEW_VALUE = 0;
/**
* Default code review vote to Gerrit when a build is successful.
*/
public static final int DEFAULT_GERRIT_BUILD_SUCCESSFUL_CODE_REVIEW_VALUE = 0;
/**
* Default code review vote to Gerrit when a build is not built.
*/
public static final int DEFAULT_GERRIT_BUILD_NOT_BUILT_CODE_REVIEW_VALUE = 0;

/**
* Default value indicating if the Gerrit server should be used to fetch project names.
*/
@@ -171,16 +166,16 @@
private String gerritVerifiedCmdBuildStarted;
private String gerritVerifiedCmdBuildNotBuilt;
private String gerritFrontEndUrl;
private int gerritBuildStartedVerifiedValue;
private int gerritBuildStartedCodeReviewValue;
private int gerritBuildSuccessfulVerifiedValue;
private int gerritBuildSuccessfulCodeReviewValue;
private int gerritBuildFailedVerifiedValue;
private int gerritBuildFailedCodeReviewValue;
private int gerritBuildUnstableVerifiedValue;
private int gerritBuildUnstableCodeReviewValue;
private int gerritBuildNotBuiltVerifiedValue;
private int gerritBuildNotBuiltCodeReviewValue;
private Integer gerritBuildStartedVerifiedValue = null;
private Integer gerritBuildSuccessfulVerifiedValue = null;
private Integer gerritBuildFailedVerifiedValue = null;
private Integer gerritBuildUnstableVerifiedValue = null;
private Integer gerritBuildNotBuiltVerifiedValue = null;
private Integer gerritBuildStartedCodeReviewValue = null;
private Integer gerritBuildSuccessfulCodeReviewValue = null;
private Integer gerritBuildFailedCodeReviewValue = null;
private Integer gerritBuildUnstableCodeReviewValue = null;
private Integer gerritBuildNotBuiltCodeReviewValue = null;
private boolean enableManualTrigger;
private boolean enablePluginMessages;
@Deprecated
@@ -305,36 +300,31 @@ public void setValues(JSONObject formData) {
numberOfSendingWorkerThreads = DEFAULT_NR_OF_SENDING_WORKER_THREADS;
}

gerritBuildStartedVerifiedValue = formData.optInt(
"gerritBuildStartedVerifiedValue",
DEFAULT_GERRIT_BUILD_STARTED_VERIFIED_VALUE);
gerritBuildStartedCodeReviewValue = formData.optInt(
"gerritBuildStartedCodeReviewValue",
DEFAULT_GERRIT_BUILD_STARTED_CODE_REVIEW_VALUE);
gerritBuildSuccessfulVerifiedValue = formData.optInt(
"gerritBuildSuccessfulVerifiedValue",
DEFAULT_GERRIT_BUILD_SUCCESSFUL_VERIFIED_VALUE);
gerritBuildSuccessfulCodeReviewValue = formData.optInt(
"gerritBuildSuccessfulCodeReviewValue",
DEFAULT_GERRIT_BUILD_SUCCESSFUL_CODE_REVIEW_VALUE);
gerritBuildFailedVerifiedValue = formData.optInt(
"gerritBuildFailedVerifiedValue",
DEFAULT_GERRIT_BUILD_FAILURE_VERIFIED_VALUE);
gerritBuildFailedCodeReviewValue = formData.optInt(
"gerritBuildFailedCodeReviewValue",
DEFAULT_GERRIT_BUILD_FAILURE_CODE_REVIEW_VALUE);
gerritBuildUnstableVerifiedValue = formData.optInt(
"gerritBuildUnstableVerifiedValue",
DEFAULT_GERRIT_BUILD_UNSTABLE_VERIFIED_VALUE);
gerritBuildUnstableCodeReviewValue = formData.optInt(
"gerritBuildUnstableCodeReviewValue",
DEFAULT_GERRIT_BUILD_UNSTABLE_CODE_REVIEW_VALUE);
gerritBuildNotBuiltVerifiedValue = formData.optInt(
"gerritBuildNotBuiltVerifiedValue",
DEFAULT_GERRIT_BUILD_NOT_BUILT_VERIFIED_VALUE);
gerritBuildNotBuiltCodeReviewValue = formData.optInt(
"gerritBuildNotBuiltCodeReviewValue",
DEFAULT_GERRIT_BUILD_NOT_BUILT_CODE_REVIEW_VALUE);
if (formData.isEmpty()) {
gerritBuildStartedVerifiedValue = DEFAULT_GERRIT_BUILD_STARTED_VERIFIED_VALUE;
gerritBuildSuccessfulVerifiedValue = DEFAULT_GERRIT_BUILD_SUCCESSFUL_VERIFIED_VALUE;
gerritBuildFailedVerifiedValue = DEFAULT_GERRIT_BUILD_FAILURE_VERIFIED_VALUE;
gerritBuildUnstableVerifiedValue = DEFAULT_GERRIT_BUILD_UNSTABLE_VERIFIED_VALUE;
gerritBuildNotBuiltVerifiedValue = DEFAULT_GERRIT_BUILD_NOT_BUILT_VERIFIED_VALUE;
gerritBuildStartedCodeReviewValue = DEFAULT_GERRIT_BUILD_STARTED_CODE_REVIEW_VALUE;
gerritBuildSuccessfulCodeReviewValue = DEFAULT_GERRIT_BUILD_SUCCESSFUL_CODE_REVIEW_VALUE;
gerritBuildFailedCodeReviewValue = DEFAULT_GERRIT_BUILD_FAILURE_CODE_REVIEW_VALUE;
gerritBuildUnstableCodeReviewValue = DEFAULT_GERRIT_BUILD_UNSTABLE_CODE_REVIEW_VALUE;
gerritBuildNotBuiltCodeReviewValue = DEFAULT_GERRIT_BUILD_NOT_BUILT_CODE_REVIEW_VALUE;
} else {
gerritBuildStartedVerifiedValue = getValueFromFormData(formData, "gerritBuildStartedVerifiedValue");
gerritBuildSuccessfulVerifiedValue = getValueFromFormData(formData, "gerritBuildSuccessfulVerifiedValue");
gerritBuildFailedVerifiedValue = getValueFromFormData(formData, "gerritBuildFailedVerifiedValue");
gerritBuildUnstableVerifiedValue = getValueFromFormData(formData, "gerritBuildUnstableVerifiedValue");
gerritBuildNotBuiltVerifiedValue = getValueFromFormData(formData, "gerritBuildNotBuiltVerifiedValue");
gerritBuildStartedCodeReviewValue = getValueFromFormData(formData, "gerritBuildStartedCodeReviewValue");
gerritBuildSuccessfulCodeReviewValue = getValueFromFormData(formData,
"gerritBuildSuccessfulCodeReviewValue");
gerritBuildFailedCodeReviewValue = getValueFromFormData(formData, "gerritBuildFailedCodeReviewValue");
gerritBuildUnstableCodeReviewValue = getValueFromFormData(formData, "gerritBuildUnstableCodeReviewValue");
gerritBuildNotBuiltCodeReviewValue = getValueFromFormData(formData, "gerritBuildNotBuiltCodeReviewValue");
}


gerritVerifiedCmdBuildStarted = formData.optString(
"gerritVerifiedCmdBuildStarted",
@@ -414,6 +404,28 @@ public void setValues(JSONObject formData) {
replicationConfig = ReplicationConfig.createReplicationConfigFromJSON(formData);
}

/**
* Obtain value from a key in formdata.
* @param formData JSONObject.
* @param key key to extract value for.
* @return value.
*/
private Integer getValueFromFormData(JSONObject formData, String key) {
if (formData.has(key)) {
String testData = formData.optString(key);
if (testData == null || testData.equals("")) {
return null;
} else {
try {
return Integer.parseInt(testData);
} catch (NumberFormatException nfe) {
return null;
}
}
}
return null;
}

/**
* Adds the WatchTimeExceptionData from the form.
*
@@ -815,52 +827,52 @@ public void setGerritVerifiedCmdBuildNotBuilt(String cmd) {
}

@Override
public int getGerritBuildStartedVerifiedValue() {
public Integer getGerritBuildStartedVerifiedValue() {
return gerritBuildStartedVerifiedValue;
}

@Override
public int getGerritBuildStartedCodeReviewValue() {
public Integer getGerritBuildStartedCodeReviewValue() {
return gerritBuildStartedCodeReviewValue;
}

@Override
public int getGerritBuildSuccessfulVerifiedValue() {
public Integer getGerritBuildSuccessfulVerifiedValue() {
return gerritBuildSuccessfulVerifiedValue;
}

@Override
public int getGerritBuildSuccessfulCodeReviewValue() {
public Integer getGerritBuildSuccessfulCodeReviewValue() {
return gerritBuildSuccessfulCodeReviewValue;
}

@Override
public int getGerritBuildFailedVerifiedValue() {
public Integer getGerritBuildFailedVerifiedValue() {
return gerritBuildFailedVerifiedValue;
}

@Override
public int getGerritBuildFailedCodeReviewValue() {
public Integer getGerritBuildFailedCodeReviewValue() {
return gerritBuildFailedCodeReviewValue;
}

@Override
public int getGerritBuildUnstableVerifiedValue() {
public Integer getGerritBuildUnstableVerifiedValue() {
return gerritBuildUnstableVerifiedValue;
}

@Override
public int getGerritBuildUnstableCodeReviewValue() {
public Integer getGerritBuildUnstableCodeReviewValue() {
return gerritBuildUnstableCodeReviewValue;
}

@Override
public int getGerritBuildNotBuiltVerifiedValue() {
public Integer getGerritBuildNotBuiltVerifiedValue() {
return gerritBuildNotBuiltVerifiedValue;
}

@Override
public int getGerritBuildNotBuiltCodeReviewValue() {
public Integer getGerritBuildNotBuiltCodeReviewValue() {
return gerritBuildNotBuiltCodeReviewValue;
}

@@ -95,61 +95,61 @@
* The default verified value for build started.
* @return the value.
*/
int getGerritBuildStartedVerifiedValue();
Integer getGerritBuildStartedVerifiedValue();

/**
* The default code review value for build started.
* @return the value.
*/
int getGerritBuildStartedCodeReviewValue();
Integer getGerritBuildStartedCodeReviewValue();

/**
* The default verified value for build successful.
* @return the falue.
*/
int getGerritBuildSuccessfulVerifiedValue();
Integer getGerritBuildSuccessfulVerifiedValue();

/**
* The default code review value for build successful.
* @return the value.
*/
int getGerritBuildSuccessfulCodeReviewValue();
Integer getGerritBuildSuccessfulCodeReviewValue();

/**
* The default verified value for build failed.
* @return the value.
*/
int getGerritBuildFailedVerifiedValue();
Integer getGerritBuildFailedVerifiedValue();

/**
* The default code review value for build failed.
* @return the value.
*/
int getGerritBuildFailedCodeReviewValue();
Integer getGerritBuildFailedCodeReviewValue();

/**
* The default verified value for build unstable.
* @return the value.
*/
int getGerritBuildUnstableVerifiedValue();
Integer getGerritBuildUnstableVerifiedValue();

/**
* The default code review value for build unstable.
* @return the value.
*/
int getGerritBuildUnstableCodeReviewValue();
Integer getGerritBuildUnstableCodeReviewValue();

/**
* The default verified value for build not built.
* @return the value.
*/
int getGerritBuildNotBuiltVerifiedValue();
Integer getGerritBuildNotBuiltVerifiedValue();

/**
* The default code review value for build not built.
* @return the value.
*/
int getGerritBuildNotBuiltCodeReviewValue();
Integer getGerritBuildNotBuiltCodeReviewValue();

/**
* Sets all config values from the provided JSONObject.

0 comments on commit 9e92f86

Please sign in to comment.
You can’t perform that action at this time.