Permalink
Browse files

Merge branch 'master' of github.com:jenkinsci/pipeline-model-definiti…

…on-plugin into JENKINS-37781

 Conflicts:
	pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java
	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/model/Stage.groovy
	pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
	pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
	pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
	pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
  • Loading branch information...
rsandell committed Nov 2, 2016
2 parents eddf70b + 3890852 commit d65d3dc3117f30a4502cfa7ad48c7494b9c0915d
Showing with 2,585 additions and 351 deletions.
  1. +9 −1 README.md
  2. +6 −6 SYNTAX.md
  3. +4 −93 pipeline-model-api/pom.xml
  4. +29 −2 ...del-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPipelineDef.java
  5. +58 −6 ...ine-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java
  6. +1 −1 ...line-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStep.java
  7. +54 −0 ...e-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWrapper.java
  8. +120 −0 ...-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWrappers.java
  9. +6 −0 ...el-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java
  10. +49 −0 pipeline-model-declarative-agent/pom.xml
  11. +66 −0 ...ve-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgent.java
  12. +175 −0 ...rc/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgentDescriptor.java
  13. +41 −0 ...nt/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgentScript.java
  14. +14 −85 pipeline-model-definition/pom.xml
  15. +28 −30 ...odel-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Agent.groovy
  16. +11 −2 ...model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
  17. +32 −0 ...odel-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
  18. +60 −0 ...l-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Wrappers.groovy
  19. +33 −0 ...inition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/WrappersToMap.groovy
  20. +27 −2 ...efinition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
  21. +56 −0 ...finition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
  22. +62 −6 ...rc/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
  23. +48 −0 ...model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Any.java
  24. +76 −0 ...ition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipeline.java
  25. +54 −0 ...del-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Label.java
  26. +45 −0 ...odel-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/None.java
  27. +23 −0 pipeline-model-definition/src/main/resources/ast-schema.json
  28. +8 −2 ...n/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy
  29. +113 −96 ...inition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
  30. +82 −0 .../src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/WrappersToMapTranslator.groovy
  31. +51 −0 ...n/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineScript.groovy
  32. +46 −0 ...n/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelScript.groovy
  33. +42 −0 ...on/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/NoneScript.groovy
  34. +14 −4 ...definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
  35. +21 −1 ...line-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AgentTest.java
  36. +10 −0 ...odel-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/EnvironmentTest.java
  37. +10 −0 ...line-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ToolsTest.java
  38. +36 −0 ...-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
  39. +61 −0 ...e-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WrappersTest.java
  40. +67 −0 .../test/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelAndOtherFieldAgent.java
  41. +38 −0 pipeline-model-definition/src/test/resources/agentAnyInStage.groovy
  42. +37 −0 pipeline-model-definition/src/test/resources/agentTypeOrdering.groovy
  43. +45 −0 pipeline-model-definition/src/test/resources/environmentInStage.groovy
  44. +37 −0 pipeline-model-definition/src/test/resources/errors/agentMissingRequiredParam.groovy
  45. +37 −0 pipeline-model-definition/src/test/resources/errors/agentUnknownParamForType.groovy
  46. +40 −0 pipeline-model-definition/src/test/resources/errors/invalidWrapperType.groovy
  47. +37 −0 pipeline-model-definition/src/test/resources/errors/unknownAgentType.groovy
  48. +37 −0 pipeline-model-definition/src/test/resources/errors/unknownBareAgentType.groovy
  49. +31 −0 pipeline-model-definition/src/test/resources/json/agentTypeOrdering.json
  50. +36 −0 pipeline-model-definition/src/test/resources/json/environmentInStage.json
  51. +22 −0 pipeline-model-definition/src/test/resources/json/errors/agentMissingRequiredParam.json
  52. +38 −0 pipeline-model-definition/src/test/resources/json/errors/agentUnknownParamForType.json
  53. +26 −0 pipeline-model-definition/src/test/resources/json/errors/invalidWrapperType.json
  54. +22 −0 pipeline-model-definition/src/test/resources/json/errors/unknownAgentType.json
  55. +19 −0 pipeline-model-definition/src/test/resources/json/errors/unknownBareAgentType.json
  56. +47 −0 pipeline-model-definition/src/test/resources/json/multipleWrappers.json
  57. +38 −0 pipeline-model-definition/src/test/resources/json/simpleWrapper.json
  58. +29 −0 pipeline-model-definition/src/test/resources/json/toolsInStage.json
  59. +41 −0 pipeline-model-definition/src/test/resources/multipleWrappers.groovy
  60. +46 −0 ...es/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelAndOtherFieldAgentScript.groovy
  61. +40 −0 pipeline-model-definition/src/test/resources/simpleWrapper.groovy
  62. +41 −0 pipeline-model-definition/src/test/resources/toolsInStage.groovy
  63. +53 −14 pom.xml
@@ -1,4 +1,12 @@
A config-like syntax for defining Pipelines. See [the
wiki](https://github.com/jenkinsci/pipeline-config-plugin/wiki/Getting-Started)
for more information.
for more information on how to use it.

For developing this:

`cd pipeline-model-definition && mvn install && mvn hpi:run`

Look in the [SYNTAX.md](SYNTAX.md)SYNTAX.md for a description of the Syntax somewhat formally which should be kept up to date.

For extending, and the api information, consult [EXTENDING.md](EXTENDING.md)

@@ -42,7 +42,7 @@ These are sections that are specified directly within the `pipeline` argument cl
* *Description*: A sequence of `key = value` pairs, which will be passed to the `withEnv` step the build will be
executed within.
* *Required*: No
* *Allowed In*: Top-level `pipeline` closure only.
* *Allowed In*: Top-level `pipeline` or `stage` closures only.
* *Parameters*: None
* *Takes a Closure*: Yes
* *Closure Contents*: One or more lines with `foo = 'bar'` variable name/value pairs.
@@ -59,7 +59,7 @@ environment {
```

### stages
* *Description*: A sequence of one or more Pipeline `stage`s, each of which consist of a sequence of steps.
* *Description*: A sequence of one or more Pipeline `stage`s, each of which consists of a sequence of steps.
* *Required*: Yes
* *Allowed In*: Top-level `pipeline` closure only.
* *Parameters*: None
@@ -146,10 +146,10 @@ stages {
```

### tools
* *Description*: A top-level section defining tools to auto-install and put on the PATH. This is ignored if `image none`
* *Description*: A section defining tools to auto-install and put on the PATH. This is ignored if `image none`
is specified.
* *Required*: No
* *Allowed In*: Top-level `pipeline` closure only.
* *Allowed In*: Top-level `pipeline` or `stage` closures only.
* *Parameters*: None
* *Takes a Closure*: Yes
* *Closure Contents*: Names and versions of tools configured in Jenkins to install.
@@ -173,10 +173,10 @@ tools {
* *Parameters*: None
* *Takes a Closure*: Yes
* *Closure Contents*: A sequence of one or more build conditions containing Pipeline steps to run. See below for
definition of build conditions and their contents.
definitions of build conditions and their contents.

### postBuild
* *Description*: Defines post build actions to be run after build completion, assuming build status conditions are met.
* *Description*: Defines post-build actions to be run after build completion, assuming build status conditions are met.
Note that `postBuild` steps are run *before* `notifications`.
* *Required*: No
* *Allowed In*: Top-level `pipeline` closure only.
@@ -25,42 +25,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.13</version>
<relativePath/>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-parent</artifactId>
<version>0.5-SNAPSHOT</version>
</parent>

<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-api</artifactId>
<version>0.5-SNAPSHOT</version>
<packaging>hpi</packaging>
<name>Pipeline: Model API</name>
<description>An opinionated, declarative Pipeline</description>
<description>Model API for Declarative Pipeline</description>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Model+Definition+Plugin</url>

<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<id>abayer</id>
<name>Andrew Bayer</name>
</developer>
</developers>

<scm>
<connection>scm:git:git://git@github.com/jenkinsci/pipeline-config-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/pipeline-config-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/pipeline-config-plugin</url>
<tag>HEAD</tag>
</scm>

<dependencies>
<dependency>
<groupId>org.mockito</groupId>
@@ -70,69 +46,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.4</version>
<configuration>
<providerSelection>1.8</providerSelection>
</configuration>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>hudson.udp</name>
<value>33849</value>
</property>
</systemProperties>
<argLine>-Xmx4g -XX:MaxPermSize=256m</argLine>
<reuseForks>true</reuseForks>
<forkCount>0.5C</forkCount>
<!-- TODO: I hate the retrying tests but given the nondeterministic whackiness of JENKINS-37101... -->
<rerunFailingTestsCount>3</rerunFailingTestsCount>
</configuration>
</plugin>

</plugins>
</build>

<properties>
<jenkins.version>2.7.1</jenkins.version>
<java.level>7</java.level>
<groovy.version>2.4.7</groovy.version>
</properties>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

</project>
@@ -20,6 +20,7 @@
private ModelASTJobProperties jobProperties;
private ModelASTBuildParameters parameters;
private ModelASTTriggers triggers;
private ModelASTWrappers wrappers;

public ModelASTPipelineDef(Object sourceLocation) {
super(sourceLocation);
@@ -49,6 +50,11 @@ 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);
}

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

@Override
@@ -116,7 +125,9 @@ 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,6 +202,9 @@ public void removeSourceLocation() {
if (triggers != null) {
triggers.removeSourceLocation();
}
if (wrappers != null) {
wrappers.removeSourceLocation();
}
}

private String indent(int count) {
@@ -269,6 +283,14 @@ 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() {
return "ModelASTPipelineDef{" +
@@ -281,6 +303,7 @@ public String toString() {
", jobProperties=" + jobProperties +
", parameters=" + parameters +
", triggers=" + triggers +
", wrappers=" + wrappers +
"}";
}

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

}

@@ -344,6 +370,7 @@ public int hashCode() {
result = 31 * result + (getJobProperties() != null ? getJobProperties().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;
}
}
Oops, something went wrong.

0 comments on commit d65d3dc

Please sign in to comment.