Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-37054] Bump Jenkins core version and other dependencies to f…
…ully test symbol annotation
  • Loading branch information
alexsomai committed Nov 8, 2016
1 parent 00232be commit 2a9c7f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 51 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Expand Up @@ -14,12 +14,12 @@
<url>http://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin</url>

<properties>
<jenkins.version>1.609</jenkins.version>
<java.level>6</java.level>
<workflow-job.version>1.4.3</workflow-job.version>
<workflow-cps.version>1.4.3</workflow-cps.version>
<workflow-basic-steps.version>1.4.3</workflow-basic-steps.version>
<workflow-durable-task-step.version>1.4.3</workflow-durable-task-step.version>
<jenkins.version>1.642.1</jenkins.version>
<java.level>7</java.level>
<workflow-job.version>2.4</workflow-job.version>
<workflow-cps.version>2.10</workflow-cps.version>
<workflow-basic-steps.version>2.1</workflow-basic-steps.version>
<workflow-durable-task-step.version>2.4</workflow-durable-task-step.version>
</properties>

<developers>
Expand Down
48 changes: 3 additions & 45 deletions src/test/java/hudson/plugins/ws_cleanup/CleanupTest.java
Expand Up @@ -27,7 +27,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeThat;
import static org.junit.Assume.assumeTrue;
import static org.hamcrest.Matchers.*;

Expand Down Expand Up @@ -55,7 +54,6 @@
import java.util.concurrent.Future;

import hudson.util.DescribableList;
import hudson.util.VersionNumber;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand All @@ -66,9 +64,6 @@
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestExtension;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

public class CleanupTest {

@Rule public JenkinsRule j = new JenkinsRule();
Expand Down Expand Up @@ -269,11 +264,8 @@ public void pipelineWorkspaceCleanupUnlessBuildFails() throws Exception {
verifyFileExists("foo.txt");
}

@Test
@Issue("JENKINS-37054")
@Test @Issue("JENKINS-37054")
public void symbolAnnotationWorkspaceCleanup() throws Exception {
assumeSymbolDependencies();

WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("" +
"node { \n" +
Expand All @@ -291,11 +283,8 @@ public void symbolAnnotationWorkspaceCleanup() throws Exception {
assertThat(ws.getRoot().listFiles(), nullValue());
}

@Test
@Issue("JENKINS-37054")
@Test @Issue("JENKINS-37054")
public void symbolWorkspaceCleanupAnnotationUsingPattern() throws Exception {
assumeSymbolDependencies();

WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("" +
"node { \n" +
Expand All @@ -314,11 +303,8 @@ public void symbolWorkspaceCleanupAnnotationUsingPattern() throws Exception {
verifyFileExists("foo.txt");
}

@Test
@Issue("JENKINS-37054")
@Test @Issue("JENKINS-37054")
public void symbolAnnotationWorkspaceCleanupUnlessBuildFails() throws Exception {
assumeSymbolDependencies();

WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("" +
"node { \n" +
Expand All @@ -340,34 +326,6 @@ public void symbolAnnotationWorkspaceCleanupUnlessBuildFails() throws Exception
verifyFileExists("foo.txt");
}

/**
* To use the @Symbol annotation in tests, minimum workflow-cps version 2.10 is required.
* This dependency comes with other dependency version requirements, as stated by this method.
* To run tests restricted by this method, type
* <pre>
* mvn clean install -Djenkins.version=1.642.1 -Djava.level=7 -Dworkflow-job.version=2.4 -Dworkflow-basic-steps.version=2.1 -Dworkflow-cps.version=2.10 -Dworkflow-durable-task-step.version=2.4
* </pre>
*/
private static void assumeSymbolDependencies() {
assumePropertyIsGreaterThanOrEqualTo(System.getProperty("jenkins.version"), "1.642.1");
assumePropertyIsGreaterThanOrEqualTo(System.getProperty("java.level"), "7");
assumePropertyIsGreaterThanOrEqualTo(System.getProperty("workflow-job.version"), "2.4");
assumePropertyIsGreaterThanOrEqualTo(System.getProperty("workflow-basic-steps.version"), "2.1");
assumePropertyIsGreaterThanOrEqualTo(System.getProperty("workflow-cps.version"), "2.10");
assumePropertyIsGreaterThanOrEqualTo(System.getProperty("workflow-durable-task-step.version"), "2.4");
}

/**
* Checks if the given property is not null, and if it's greater than or equal to the given version.
*
* @param property the property to be checked
* @param version the version on which the property is checked against
*/
private static void assumePropertyIsGreaterThanOrEqualTo(@CheckForNull String property, @Nonnull String version) {
assumeThat(property, notNullValue());
assumeThat(new VersionNumber(property).compareTo(new VersionNumber(version)), is(greaterThanOrEqualTo(0)));
}

private void verifyFileExists(String fileName) {
File[] files = ws.getRoot().listFiles();
assertThat(files, notNullValue());
Expand Down

0 comments on commit 2a9c7f5

Please sign in to comment.