Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jenkinsci/pipeline-model-definiti…
Browse files Browse the repository at this point in the history
…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 d65d3dc
Show file tree
Hide file tree
Showing 63 changed files with 2,585 additions and 351 deletions.
10 changes: 9 additions & 1 deletion README.md
@@ -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)

12 changes: 6 additions & 6 deletions SYNTAX.md
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
97 changes: 4 additions & 93 deletions pipeline-model-api/pom.xml
Expand Up @@ -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>
Expand All @@ -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>
Expand Up @@ -20,6 +20,7 @@ public final class ModelASTPipelineDef extends ModelASTElement {
private ModelASTJobProperties jobProperties;
private ModelASTBuildParameters parameters;
private ModelASTTriggers triggers;
private ModelASTWrappers wrappers;

public ModelASTPipelineDef(Object sourceLocation) {
super(sourceLocation);
Expand Down Expand Up @@ -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);
}

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

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

private String indent(int count) {
Expand Down Expand Up @@ -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{" +
Expand All @@ -281,6 +303,7 @@ public String toString() {
", jobProperties=" + jobProperties +
", parameters=" + parameters +
", triggers=" + triggers +
", wrappers=" + wrappers +
"}";
}

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

}

Expand All @@ -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;
}
}

0 comments on commit d65d3dc

Please sign in to comment.