Skip to content

Commit

Permalink
Merge pull request jenkinsci#45 from abayer/jenkins-39394
Browse files Browse the repository at this point in the history
JENKINS-39394 - Get rid of notifications, rename postBuild to post
  • Loading branch information
abayer authored Nov 15, 2016
2 parents 58626c6 + f3c05b3 commit e9b5bf8
Show file tree
Hide file tree
Showing 59 changed files with 248 additions and 937 deletions.
12 changes: 12 additions & 0 deletions pipeline-model-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
<url>https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Model+Definition+Plugin</url>

<dependencies>
<!-- JSON schema stuff -->
<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-json-org</artifactId>
<version>2.2.3</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* The MIT License
*
* Copyright (c) 2016, CloudBees, 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.
*/

package org.jenkinsci.plugins.pipeline.modeldefinition;

import com.github.fge.jsonschema.exceptions.ProcessingException;
import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import hudson.Extension;
import hudson.model.RootAction;
import hudson.util.TimeUnit2;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import javax.servlet.ServletException;
import java.io.IOException;

/**
* Endpoint for exposing the AST JSON schema.
*
* @author Andrew Bayer
*/
@Extension
public class ASTSchema implements RootAction {
public static final String AST_SCHEMA_URL = "pipeline-model-schema";

@Override
public String getUrlName() {
return AST_SCHEMA_URL;
}

@Override
public String getIconFileName() {
return null;
}

@Override
public String getDisplayName() {
return null;
}

@SuppressWarnings("unused")
public void doJson(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
rsp.serveFile(req, getClass().getResource("/ast-schema.json"));
}

/**
* Get the Pipeline Config AST JSON schema.
*
* @return the schema in {@link JsonSchema} form.
* @throws ProcessingException
*/
public static JsonSchema getJSONSchema() throws ProcessingException {
final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
return factory.getJsonSchema("resource:/ast-schema.json");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Corresponds to {@code Notifications} or {@code PostBuild}
*
* @author Robert Sandell &lt;[email protected]&gt;.
* @see ModelASTNotifications
* @see ModelASTPostStage
* @see ModelASTPostBuild
*/
public abstract class ModelASTBuildConditionsContainer extends ModelASTElement {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
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,8 +29,7 @@ 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("post", postBuild != null ? postBuild.toJSON() : null);
a.put("environment", environment != null ? environment.toJSON() : null);
a.put("agent", agent != null ? agent.toJSON() : null);
a.put("tools", tools != null ? tools.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,8 +276,7 @@ public void setWrappers(ModelASTWrappers wrappers) {
public String toString() {
return "ModelASTPipelineDef{" +
"stages=" + stages +
", notifications=" + notifications +
", postBuild=" + postBuild +
", post=" + postBuild +
", environment=" + environment +
", agent=" + agent +
", tools=" + tools +
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ModelASTPostBuild(Object sourceLocation) {

@Override
public java.lang.String getName() {
return "postBuild";
return "post";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
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 @@ -61,8 +60,6 @@ public interface ModelValidator {

boolean validateElement(ModelASTPostStage post);

boolean validateElement(ModelASTNotifications notifications);

boolean validateElement(ModelASTBuildCondition buildCondition);

boolean validateElement(ModelASTEnvironment environment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,25 +302,8 @@
"additionalProperties": false

},
"notifications": {
"description": "An array of build conditions with blocks of steps to run if those conditions are satisfied at the end of the build",
"type": "object",
"properties": {
"conditions": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/buildCondition"
}
}
},
"required": [
"conditions"
],
"additionalProperties": false
},
"postBuild": {
"description": "An array of build conditions with blocks of steps to run if those conditions are satisfied at the end of the build while still on the image/node the build ran on, before notifications",
"post": {
"description": "An array of build conditions with blocks of steps to run if those conditions are satisfied at the end of the build while still on the image/node the build ran on",
"type": "object",
"properties": {
"conditions": {
Expand Down Expand Up @@ -350,7 +333,7 @@
"$ref": "#/definitions/when"
},
"post": {
"$ref": "#/definitions/notifications"
"$ref": "#/definitions/post"
},
"tools": {
"$ref": "#/definitions/tools"
Expand Down Expand Up @@ -385,11 +368,8 @@
"stages": {
"$ref": "#/definitions/stages"
},
"notifications": {
"$ref": "#/definitions/notifications"
},
"postBuild": {
"$ref": "#/definitions/postBuild"
"post": {
"$ref": "#/definitions/post"
},
"environment": {
"$ref": "#/definitions/environment"
Expand Down
Loading

0 comments on commit e9b5bf8

Please sign in to comment.