Skip to content
Permalink
Browse files

Merge branch 'master' into JENKINS-40370

Conflicts:
	pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java
	pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
	pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
  • Loading branch information
abayer committed Jan 5, 2017
2 parents 289e89e + 85b8005 commit 729dfabcd270c25f0ceaadfd012c019f8da70e74
Showing with 113 additions and 608 deletions.
  1. +1 −2 SYNTAX.md
  2. +1 −28 ...del-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPipelineDef.java
  3. +0 −52 ...e-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWrapper.java
  4. +0 −120 ...-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWrappers.java
  5. +0 −6 ...el-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java
  6. +1 −18 pipeline-model-api/src/main/resources/ast-schema.json
  7. +19 −10 ...line-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/Utils.groovy
  8. +43 −12 ...el-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Options.groovy
  9. +0 −7 ...model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
  10. +0 −63 ...l-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Wrappers.groovy
  11. +0 −33 ...inition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/WrappersToMap.groovy
  12. +0 −17 ...efinition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
  13. +3 −48 ...finition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
  14. +0 −31 ...rc/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
  15. +0 −5 ...n/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy
  16. +0 −3 ...-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/Messages.properties
  17. +6 −6 ...inition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
  18. +5 −1 ...nition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/OptionsTranslator.groovy
  19. +0 −82 .../src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/WrappersToMapTranslator.groovy
  20. +1 −1 ...definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
  21. +25 −1 ...ne-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/OptionsTest.java
  22. +1 −2 ...-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
  23. +0 −54 ...e-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WrappersTest.java
  24. +1 −1 pipeline-model-definition/src/test/resources/errors/invalidWrapperType.groovy
  25. +1 −1 pipeline-model-definition/src/test/resources/json/errors/invalidWrapperType.json
  26. +1 −1 pipeline-model-definition/src/test/resources/json/multipleWrappers.json
  27. +1 −1 pipeline-model-definition/src/test/resources/json/simpleWrapper.json
  28. +1 −0 pipeline-model-definition/src/test/resources/multipleProperties.groovy
  29. +1 −1 pipeline-model-definition/src/test/resources/multipleWrappers.groovy
  30. +1 −1 pipeline-model-definition/src/test/resources/simpleWrapper.groovy
@@ -296,8 +296,7 @@ parameters {
```

### Options
* *Description*: Other options exclusive to Declarative, such as `skipDefaultCheckout`, and traditional `JobProperty`s, such as
build discarding, limiting concurrent builds, and more.
* *Description*: Traditional `JobProperty`s, such as `buildDiscarder` or `disableConcurrentBuilds`, Declarative-specifc options, such as `skipDefaultCheckout`, and "wrappers" that should wrap the entire build, such as `timeout`.
* *Required*: No
* *Allowed In*: Top-level `pipeline` closure only.
* *Parameters*: None
@@ -19,7 +19,6 @@
private ModelASTOptions options;
private ModelASTBuildParameters parameters;
private ModelASTTriggers triggers;
private ModelASTWrappers wrappers;

public ModelASTPipelineDef(Object sourceLocation) {
super(sourceLocation);
@@ -48,11 +47,6 @@ public JSONObject toJSON() {
} else {
a.put("triggers", null);
}
if (wrappers != null && !wrappers.getWrappers().isEmpty()) {
a.put("wrappers", wrappers.toJSON());
} else {
a.put("wrappers", null);
}
return new JSONObject().accumulate("pipeline", a);
}

@@ -84,9 +78,6 @@ public void validate(ModelValidator validator) {
if (triggers != null) {
triggers.validate(validator);
}
if (wrappers != null) {
wrappers.validate(validator);
}
}

@Override
@@ -117,9 +108,6 @@ public String toGroovy() {
if (triggers != null && !triggers.getTriggers().isEmpty()) {
result.append(triggers.toGroovy()).append('\n');
}
if (wrappers != null && !wrappers.getWrappers().isEmpty()) {
result.append(wrappers.toGroovy()).append('\n');
}

result.append("}\n");
return result.toString();
@@ -191,9 +179,6 @@ public void removeSourceLocation() {
if (triggers != null) {
triggers.removeSourceLocation();
}
if (wrappers != null) {
wrappers.removeSourceLocation();
}
}

private String indent(int count) {
@@ -264,13 +249,6 @@ public void setTriggers(ModelASTTriggers triggers) {
this.triggers = triggers;
}

public ModelASTWrappers getWrappers() {
return wrappers;
}

public void setWrappers(ModelASTWrappers wrappers) {
this.wrappers = wrappers;
}

@Override
public String toString() {
@@ -283,7 +261,6 @@ public String toString() {
", options=" + options +
", parameters=" + parameters +
", triggers=" + triggers +
", wrappers=" + wrappers +
"}";
}

@@ -326,10 +303,7 @@ public boolean equals(Object o) {
if (getParameters() != null ? !getParameters().equals(that.getParameters()) : that.getParameters() != null) {
return false;
}
if (getTriggers() != null ? !getTriggers().equals(that.getTriggers()) : that.getTriggers() != null) {
return false;
}
return getWrappers() != null ? getWrappers().equals(that.getWrappers()) : that.getWrappers() == null;
return getTriggers() != null ? getTriggers().equals(that.getTriggers()) : that.getTriggers() == null;

}

@@ -344,7 +318,6 @@ public int hashCode() {
result = 31 * result + (getOptions() != null ? getOptions().hashCode() : 0);
result = 31 * result + (getParameters() != null ? getParameters().hashCode() : 0);
result = 31 * result + (getTriggers() != null ? getTriggers().hashCode() : 0);
result = 31 * result + (getWrappers() != null ? getWrappers().hashCode() : 0);
return result;
}
}

This file was deleted.

This file was deleted.

@@ -45,8 +45,6 @@
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTTrigger;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTTriggers;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTWhen;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTWrapper;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTWrappers;


public interface ModelValidator {
@@ -90,9 +88,5 @@

boolean validateElement(ModelASTStages stages);

boolean validateElement(ModelASTWrapper wrapper);

boolean validateElement(ModelASTWrappers wrappers);

boolean validateWhenCondition(ModelASTStep condition);
}
@@ -117,7 +117,7 @@
]
},
"options": {
"description": "One or more options (including job properties)",
"description": "One or more options (including job properties, wrappers, and options specific to Declarative Pipelines)",
"type": "object",
"properties": {
"options": {
@@ -158,20 +158,6 @@
},
"additionalProperties": false
},
"wrappers": {
"description": "One or more wrappers",
"type": "object",
"properties": {
"wrappers": {
"type": "array",
"items": {
"$ref": "#/definitions/methodCall"
},
"minItems": 1
}
},
"additionalProperties": false
},
"step": {
"description": "A single step with parameters",
"type": "object",
@@ -402,9 +388,6 @@
},
"parameters": {
"$ref": "#/definitions/parameters"
},
"wrappers": {
"$ref": "#/definitions/wrappers"
}
},
"required": [
@@ -53,6 +53,7 @@ import org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode
import org.jenkinsci.plugins.workflow.graph.FlowNode
import org.jenkinsci.plugins.workflow.job.WorkflowRun
import org.jenkinsci.plugins.workflow.steps.StepDescriptor
import org.jenkinsci.plugins.workflow.support.steps.StageStep

import javax.annotation.Nullable
@@ -313,13 +314,13 @@ public class Utils {
* @return A {@link LoadingCache} for looking up types from symbols.
*/
static generateTypeCache(Class<? extends Descriptor> type, boolean includeClassNames = false,
List<String> excludedSymbols = []) {
List<String> excludedSymbols = [], Closure<Boolean> filter = null) {
return CacheBuilder.newBuilder()
.expireAfterWrite(10, TimeUnit.MINUTES)
.build(new CacheLoader<Object, Map<String, String>>() {
@Override
Map<String, String> load(Object key) throws Exception {
return populateTypeCache(type, includeClassNames, excludedSymbols)
return populateTypeCache(type, includeClassNames, excludedSymbols, filter)
}
})
}
@@ -334,18 +335,26 @@ public class Utils {
*/
private static Map<String,String> populateTypeCache(Class<? extends Descriptor> type,
boolean includeClassNames = false,
List<String> excludedSymbols = []) {
List<String> excludedSymbols = [],
Closure<Boolean> filter = null) {
Map<String,String> knownTypes = [:]

ExtensionList.lookup(type).each { t ->
Set<String> symbolValue = SymbolLookup.getSymbolValue(t)
if (!symbolValue.isEmpty() && !symbolValue.any { excludedSymbols.contains(it) }) {
knownTypes.put(symbolValue.iterator().next(), t.clazz.getName())
}
if (filter == null || filter.call(t)) {
// Have to special-case StepDescriptor since it doesn't actually have symbols!
if (t instanceof StepDescriptor) {
knownTypes.put(t.functionName, t.clazz.getName())
} else {
Set<String> symbolValue = SymbolLookup.getSymbolValue(t)
if (!symbolValue.isEmpty() && !symbolValue.any { excludedSymbols.contains(it) }) {
knownTypes.put(symbolValue.iterator().next(), t.clazz.getName())
}
}

if (includeClassNames) {
// Add the class name mapping even if we also found the symbol, for backwards compatibility reasons.
knownTypes.put(t.clazz.getName(), t.clazz.getName())
if (includeClassNames) {
// Add the class name mapping even if we also found the symbol, for backwards compatibility reasons.
knownTypes.put(t.clazz.getName(), t.clazz.getName())
}
}
}

0 comments on commit 729dfab

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