Skip to content
Permalink
Browse files

Merge pull request #63 from abayer/jenkins-34464

[JENKINS-34464] Test for Result working in Snippet Generator
  • Loading branch information...
abayer committed May 26, 2017
2 parents 0f5fae9 + 68b1a48 commit adf46741ea0520c42aea62cc02c916ff5a8e6d21
Showing with 43 additions and 6 deletions.
  1. +19 −6 pom.xml
  2. +24 −0 src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java
25 pom.xml
@@ -66,8 +66,11 @@ THE SOFTWARE.
<jenkins.version>1.642.3</jenkins.version>
<scm-api.version>2.0.7</scm-api.version>
<no-test-jar>false</no-test-jar>
<workflow-step-api.version>2.9</workflow-step-api.version>
<workflow-step-api.version>2.10</workflow-step-api.version>
<workflow-scm-step-plugin.version>2.4</workflow-scm-step-plugin.version>
<workflow-support.version>2.14</workflow-support.version>
<workflow-cps.version>2.32-20170524.171102-1</workflow-cps.version> <!-- TODO: Switch to release after https://github.com/jenkinsci/workflow-cps-plugin/pull/136 is merged and released -->

</properties>
<dependencies>
<dependency>
@@ -80,10 +83,20 @@ THE SOFTWARE.
<artifactId>workflow-job</artifactId>
<version>2.10</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>${workflow-support.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.19</version>
<version>${workflow-cps.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -103,7 +116,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.5</version>
<version>2.15</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
@@ -113,7 +126,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.23</version>
<version>1.26</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -156,14 +169,14 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.10</version>
<version>${workflow-support.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.19</version>
<version>${workflow-cps.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
@@ -29,6 +29,7 @@
import hudson.model.JobProperty;
import hudson.model.ParametersAction;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.Result;
import hudson.model.StringParameterDefinition;
import hudson.model.StringParameterValue;
import hudson.model.queue.QueueTaskFuture;
@@ -50,6 +51,7 @@
import jenkins.model.BuildDiscarderProperty;
import jenkins.plugins.git.GitSCMSource;
import jenkins.plugins.git.GitSampleRepoRule;
import jenkins.triggers.ReverseBuildTrigger;
import org.jenkinsci.Symbol;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMSource;
@@ -559,6 +561,28 @@ public void configRoundTripSCMTrigger() throws Exception {
}
}

@Issue("JENKINS-34464")
@Test
public void configRoundTripReverseBuildTrigger() throws Exception {
List<JobProperty> properties = Collections.<JobProperty>singletonList(new PipelineTriggersJobProperty(Collections.<Trigger>singletonList(new ReverseBuildTrigger("some-job", Result.UNSTABLE))));
String snippetJson = "{'propertiesMap': {\n" +
" 'stapler-class-bag': 'true',\n" +
" 'org-jenkinsci-plugins-workflow-job-properties-PipelineTriggersJobProperty': {'triggers': {\n" +
" 'stapler-class-bag': 'true',\n" +
" 'jenkins-triggers-ReverseBuildTrigger': { 'threshold': 'UNSTABLE', 'upstreamProjects': 'some-job'}\n" +
" }}},\n" +
" 'stapler-class': 'org.jenkinsci.plugins.workflow.multibranch.JobPropertyStep',\n" +
" '$class': 'org.jenkinsci.plugins.workflow.multibranch.JobPropertyStep'}";

if (ReverseBuildTrigger.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) {
new SnippetizerTester(r).assertGenerateSnippet(snippetJson, "properties([pipelineTriggers([upstream(threshold: 'UNSTABLE', upstreamProjects: 'some-job')])])", null);
new SnippetizerTester(r).assertRoundTrip(new JobPropertyStep(properties), "properties([pipelineTriggers([upstream(threshold: 'UNSTABLE', upstreamProjects: 'some-job')])])");
} else {
new SnippetizerTester(r).assertGenerateSnippet(snippetJson, "properties([pipelineTriggers([[$class: 'ReverseBuildTrigger', threshold: 'UNSTABLE', upstreamProjects: 'some-job']])])", null);
new SnippetizerTester(r).assertRoundTrip(new JobPropertyStep(properties), "properties([pipelineTriggers([[$class: 'ReverseBuildTrigger', threshold: 'UNSTABLE', upstreamProjects: 'some-job']])])");
}
}

@Issue("JENKINS-37005")
@Test
public void noPropertiesWarnings() throws Exception {

0 comments on commit adf4674

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