Skip to content

Commit

Permalink
[JENKINS-39394] Removed notifications section.
Browse files Browse the repository at this point in the history
  • Loading branch information
abayer committed Nov 2, 2016
1 parent eb197a9 commit d954650
Show file tree
Hide file tree
Showing 45 changed files with 37 additions and 841 deletions.
Expand Up @@ -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 {
Expand Down

This file was deleted.

Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -181,9 +173,6 @@ public void removeSourceLocation() {
if (stages != null) {
stages.removeSourceLocation();
}
if (notifications != null) {
notifications.removeSourceLocation();
}
if (postBuild != null) {
postBuild.removeSourceLocation();
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -295,7 +276,6 @@ public void setWrappers(ModelASTWrappers wrappers) {
public String toString() {
return "ModelASTPipelineDef{" +
"stages=" + stages +
", notifications=" + notifications +
", postBuild=" + postBuild +
", environment=" + environment +
", agent=" + agent +
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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;
Expand All @@ -60,8 +59,6 @@ public interface ModelValidator {

boolean validateElement(ModelASTPostStage post);

boolean validateElement(ModelASTNotifications notifications);

boolean validateElement(ModelASTBuildCondition buildCondition);

boolean validateElement(ModelASTEnvironment environment);
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Up @@ -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
*/
Expand Down

This file was deleted.

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

@Whitelisted
Notifications notifications

@Whitelisted
PostBuild postBuild

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
*
Expand All @@ -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.
*/
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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'")
Expand Down Expand Up @@ -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);

Expand Down
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d954650

Please sign in to comment.