Skip to content
Permalink
Browse files

[JENKINS-39394] Removed notifications section.

  • Loading branch information...
abayer committed Nov 2, 2016
1 parent eb197a9 commit d95465079b2f354cfba69cfdbaad533de2f18044
Showing with 37 additions and 841 deletions.
  1. +1 −1 ...ain/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTBuildConditionsContainer.java
  2. +0 −33 ...l-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTNotifications.java
  3. +0 −26 ...del-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPipelineDef.java
  4. +0 −3 ...el-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java
  5. +0 −16 ...pi/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorTest.java
  6. +1 −1 ...roovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/AbstractBuildConditionResponder.groovy
  7. +0 −36 ...inition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Notifications.groovy
  8. +1 −21 ...model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
  9. +0 −10 ...efinition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
  10. +3 −10 ...finition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
  11. +0 −7 ...rc/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
  12. +2 −22 pipeline-model-definition/src/main/resources/ast-schema.json
  13. +4 −27 ...inition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
  14. +1 −3 ...definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
  15. +0 −20 ...el-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
  16. +5 −65 ...ion/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BuildConditionResponderTest.java
  17. +0 −2 ...el-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/JobPropertiesTest.java
  18. +0 −1 ...model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ParametersTest.java
  19. +2 −9 ...-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/PostStageTest.java
  20. +0 −1 ...e-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/TriggersTest.java
  21. +7 −24 ...-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
  22. +0 −2 ...e-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WrappersTest.java
  23. +2 −2 ...ion/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ExecuteConvertedTest.java
  24. +0 −49 pipeline-model-definition/src/test/resources/abortedNotification.groovy
  25. +1 −1 pipeline-model-definition/src/test/resources/buildConditionOrdering.groovy
  26. +0 −48 pipeline-model-definition/src/test/resources/errors/duplicateNotificationConditions.groovy
  27. +0 −39 pipeline-model-definition/src/test/resources/errors/emptyNotifications.groovy
  28. +1 −1 pipeline-model-definition/src/test/resources/errors/invalidBuildCondition.groovy
  29. 0 ...nition/src/test/resources/{simpleNotification.groovy → errors/notificationsSectionRemoved.groovy}
  30. +0 −51 pipeline-model-definition/src/test/resources/errors/rejectParallelInNotifications.groovy
  31. +0 −47 pipeline-model-definition/src/test/resources/failingNotifications.groovy
  32. +0 −5 pipeline-model-definition/src/test/resources/failingPipeline.groovy
  33. +0 −5 pipeline-model-definition/src/test/resources/failingPostBuild.groovy
  34. +0 −23 pipeline-model-definition/src/test/resources/json/errors/emptyNotifications.json
  35. +1 −14 pipeline-model-definition/src/test/resources/json/errors/invalidBuildCondition.json
  36. 0 ...ition/src/test/resources/json/{simpleNotification.json → errors/notificationsSectionRemoved.json}
  37. +0 −60 pipeline-model-definition/src/test/resources/json/postBuildAndNotifications.json
  38. +0 −50 pipeline-model-definition/src/test/resources/postBuildAndNotifications.groovy
  39. +1 −1 ...l-definition/src/test/resources/{notificationOnChangeChanged.groovy → postOnChangeChanged.groovy}
  40. +1 −1 ...del-definition/src/test/resources/{notificationOnChangeFailed.groovy → postOnChangeFailed.groovy}
  41. +0 −53 pipeline-model-definition/src/test/resources/postStage/failingNotifications.groovy
  42. +1 −1 pipeline-model-definition/src/test/resources/postStage/globalAndLocalAlways.groovy
  43. +1 −1 pipeline-model-definition/src/test/resources/postStage/localAll.groovy
  44. +0 −48 pipeline-model-definition/src/test/resources/shInNotification.groovy
  45. +1 −1 pipeline-model-definition/src/test/resources/{unstableNotification.groovy → unstablePost.groovy}
@@ -12,7 +12,7 @@
* Corresponds to {@code Notifications} or {@code PostBuild}
*
* @author Robert Sandell <rsandell@cloudbees.com>.
* @see ModelASTNotifications
* @see ModelASTPostStage
* @see ModelASTPostBuild
*/
public abstract class ModelASTBuildConditionsContainer extends ModelASTElement {

This file was deleted.

@@ -12,7 +12,6 @@
*/
public final class ModelASTPipelineDef extends ModelASTElement {
private ModelASTStages stages;
private ModelASTNotifications notifications;
private ModelASTPostBuild postBuild;
private ModelASTEnvironment environment;
private ModelASTAgent agent;
@@ -30,7 +29,6 @@ public ModelASTPipelineDef(Object sourceLocation) {
public JSONObject toJSON() {
JSONObject a = new JSONObject();
a.put("stages", stages != null ? stages.toJSON() : null);
a.put("notifications", notifications != null ? notifications.toJSON() : null);
a.put("postBuild", postBuild != null ? postBuild.toJSON() : null);
a.put("environment", environment != null ? environment.toJSON() : null);
a.put("agent", agent != null ? agent.toJSON() : null);
@@ -65,9 +63,6 @@ public void validate(ModelValidator validator) {
if (stages != null) {
stages.validate(validator);
}
if (notifications != null) {
notifications.validate(validator);
}
if (postBuild != null) {
postBuild.validate(validator);
}
@@ -113,9 +108,6 @@ public String toGroovy() {
if (postBuild != null) {
result.append(postBuild.toGroovy()).append('\n');
}
if (notifications != null) {
result.append(notifications.toGroovy()).append('\n');
}
if (jobProperties != null && !jobProperties.getProperties().isEmpty()) {
result.append(jobProperties.toGroovy()).append('\n');
}
@@ -181,9 +173,6 @@ public void removeSourceLocation() {
if (stages != null) {
stages.removeSourceLocation();
}
if (notifications != null) {
notifications.removeSourceLocation();
}
if (postBuild != null) {
postBuild.removeSourceLocation();
}
@@ -219,14 +208,6 @@ public void setStages(ModelASTStages stages) {
this.stages = stages;
}

public ModelASTNotifications getNotifications() {
return notifications;
}

public void setNotifications(ModelASTNotifications notifications) {
this.notifications = notifications;
}

public ModelASTPostBuild getPostBuild() {
return postBuild;
}
@@ -295,7 +276,6 @@ public void setWrappers(ModelASTWrappers wrappers) {
public String toString() {
return "ModelASTPipelineDef{" +
"stages=" + stages +
", notifications=" + notifications +
", postBuild=" + postBuild +
", environment=" + environment +
", agent=" + agent +
@@ -324,11 +304,6 @@ public boolean equals(Object o) {
if (getStages() != null ? !getStages().equals(that.getStages()) : that.getStages() != null) {
return false;
}
if (getNotifications() != null
? !getNotifications().equals(that.getNotifications())
: that.getNotifications() != null) {
return false;
}
if (getPostBuild() != null ? !getPostBuild().equals(that.getPostBuild()) : that.getPostBuild() != null) {
return false;
}
@@ -362,7 +337,6 @@ public boolean equals(Object o) {
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (getStages() != null ? getStages().hashCode() : 0);
result = 31 * result + (getNotifications() != null ? getNotifications().hashCode() : 0);
result = 31 * result + (getPostBuild() != null ? getPostBuild().hashCode() : 0);
result = 31 * result + (getEnvironment() != null ? getEnvironment().hashCode() : 0);
result = 31 * result + (getAgent() != null ? getAgent().hashCode() : 0);
@@ -35,7 +35,6 @@
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTJobProperties;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTJobProperty;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTMethodCall;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTNotifications;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPipelineDef;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPostBuild;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPostStage;
@@ -60,8 +59,6 @@

boolean validateElement(ModelASTPostStage post);

boolean validateElement(ModelASTNotifications notifications);

boolean validateElement(ModelASTBuildCondition buildCondition);

boolean validateElement(ModelASTEnvironment environment);
@@ -4,7 +4,6 @@
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTBranch;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTBuildCondition;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTBuildConditionsContainer;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTNotifications;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPostBuild;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPostStage;
import org.junit.Test;
@@ -45,19 +44,4 @@ public void ensure_postStage_calls_own_validator_and_super() {
inOrder.verify(validator, Mockito.times(1)).validateElement(branch);
}

@Test
public void ensure_notifications_calls_own_validator_and_super() {
ModelValidator validator = Mockito.mock(ModelValidator.class);
ModelASTBuildCondition condition = new ModelASTBuildCondition(null);
ModelASTBranch branch = new ModelASTBranch(null);
condition.setBranch(branch);
ModelASTNotifications instance = new ModelASTNotifications(null);
instance.setConditions(Collections.singletonList(condition));
instance.validate(validator);
InOrder inOrder = Mockito.inOrder(validator);
inOrder.verify(validator, Mockito.times(1)).validateElement(instance);
inOrder.verify(validator, Mockito.times(1)).validateElement((ModelASTBuildConditionsContainer) instance);
inOrder.verify(validator, Mockito.times(1)).validateElement(condition);
inOrder.verify(validator, Mockito.times(1)).validateElement(branch);
}
}
@@ -31,7 +31,7 @@ import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper


/**
* Parent for {@link Notifications} and {@link PostBuild} - containers for condition name/step block pairs.
* Parent for {@link PostStage} and {@link PostBuild} - containers for condition name/step block pairs.
*
* @author Andrew Bayer
*/

This file was deleted.

@@ -45,9 +45,6 @@ public class Root implements NestedModel, Serializable {
@Whitelisted
Stages stages

@Whitelisted
Notifications notifications

@Whitelisted
PostBuild postBuild

@@ -75,12 +72,6 @@ public class Root implements NestedModel, Serializable {
return this
}

@Whitelisted
Root notifications(Notifications n) {
this.notifications = n
return this
}

@Whitelisted
Root postBuild(PostBuild p) {
this.postBuild = p
@@ -148,17 +139,6 @@ public class Root implements NestedModel, Serializable {
}
}

/**
* Returns a list of notification closures whose conditions have been satisfied and should be run.
*
* @param runWrapperObj The {@link RunWrapper} for the build.
* @return a list of closures whose conditions have been satisfied.
*/
@Whitelisted
List<Closure> satisfiedNotifications(Object runWrapperObj) {
return satisfiedConditionsForField(notifications, runWrapperObj)
}

/**
* Returns a list of post-build closures whose conditions have been satisfied and should be run.
*
@@ -181,7 +161,7 @@ public class Root implements NestedModel, Serializable {
/**
* Gets the list of satisfied build condition closures for the given responder.
*
* @param r an {@link AbstractBuildConditionResponder}, such as {@link Notifications} or {@link PostBuild}.
* @param r an {@link AbstractBuildConditionResponder}, such as {@link PostStage} or {@link PostBuild}.
* @param runWrapperObj The {@link RunWrapper} for the build.
* @return A list of closures from the responder which have had their conditions satisfied.
*/
@@ -55,7 +55,6 @@ import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTTriggers
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTValue
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTBuildCondition
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTAgent
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTNotifications
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPipelineDef
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPostBuild
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTScriptBlock
@@ -131,9 +130,6 @@ class JSONParser {
case 'postBuild':
pipelineDef.postBuild = parsePostBuild(pipelineJson.getJSONObject("postBuild"))
break
case 'notifications':
pipelineDef.notifications = parseNotifications(pipelineJson.getJSONObject("notifications"))
break
case 'tools':
pipelineDef.tools = parseTools(pipelineJson.getJSONArray("tools"))
break
@@ -439,12 +435,6 @@ class JSONParser {
return condition
}

public @CheckForNull ModelASTNotifications parseNotifications(JSONObject j) {
ModelASTNotifications notifications = new ModelASTNotifications(j)

return parseBuildConditionResponder(j, notifications)
}

public @CheckForNull ModelASTPostBuild parsePostBuild(JSONObject j) {
ModelASTPostBuild postBuild = new ModelASTPostBuild(j)
return parseBuildConditionResponder(j, postBuild)
@@ -57,7 +57,6 @@ import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTBranch
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTBuildCondition
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTAgent
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTKey
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTNotifications
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPipelineDef
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPostBuild
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTScriptBlock
@@ -173,9 +172,6 @@ class ModelParser {
case 'environment':
r.environment = parseEnvironment(stmt);
break;
case 'notifications':
r.notifications = parseNotifications(stmt);
break;
case 'postBuild':
r.postBuild = parsePostBuild(stmt);
break;
@@ -197,6 +193,9 @@ class ModelParser {
case 'wrappers':
r.wrappers = parseWrappers(stmt)
break
case 'notifications':
errorCollector.error(r, "The 'notifications' section has been removed as of version 0.6. Use 'post' for all post-build actions.")
break
default:
// We need to check for unknowns here.
errorCollector.error(r, "Undefined section '$name'")
@@ -671,12 +670,6 @@ class ModelParser {
return agent
}

public @Nonnull ModelASTNotifications parseNotifications(Statement stmt) {
def r = new ModelASTNotifications(stmt);

return parseBuildConditionResponder(stmt, r);
}

public @Nonnull ModelASTPostBuild parsePostBuild(Statement stmt) {
def r = new ModelASTPostBuild(stmt);

@@ -45,7 +45,6 @@ import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTKey
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTKeyValueOrMethodCallPair
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTMethodCall
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTNamedArgumentList
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTNotifications
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPipelineDef
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPositionalArgumentList
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPostBuild
@@ -63,7 +62,6 @@ import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTTools
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTWrapper
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTWrappers
import org.jenkinsci.plugins.pipeline.modeldefinition.model.BuildCondition
import org.jenkinsci.plugins.pipeline.modeldefinition.model.Agent
import org.jenkinsci.plugins.pipeline.modeldefinition.model.JobProperties
import org.jenkinsci.plugins.pipeline.modeldefinition.model.Parameters
import org.jenkinsci.plugins.pipeline.modeldefinition.model.Tools
@@ -113,11 +111,6 @@ class ModelValidatorImpl implements ModelValidator {
true
}

public boolean validateElement(ModelASTNotifications notifications) {
// notifications specific validation
true
}

public boolean validateElement(@Nonnull ModelASTBuildConditionsContainer post) {
boolean valid = true

0 comments on commit d954650

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