Skip to content

Commit

Permalink
Merge pull request #63 from abayer/jenkins-34464
Browse files Browse the repository at this point in the history
[JENKINS-34464] Test for Result working in Snippet Generator
  • Loading branch information
abayer committed May 26, 2017
2 parents 0f5fae9 + 68b1a48 commit adf4674
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
25 changes: 19 additions & 6 deletions pom.xml
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit adf4674

Please sign in to comment.