Skip to content
Permalink
Browse files

[JENKINS-39134] Workaround for Pipeline/Guice bug.

  • Loading branch information...
jglick committed Nov 29, 2016
1 parent 705ad8a commit a2729547dc0c545043ad882e48b8de60623490db
30 pom.xml
@@ -29,7 +29,8 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.11</version>
<version>2.19</version>
<relativePath/>
</parent>

<artifactId>pipeline-maven</artifactId>
@@ -87,12 +88,37 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.2</version>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>config-file-provider</artifactId>
<version>2.11</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.23</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.11</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -140,6 +140,11 @@ public boolean start() throws Exception {
return false;
}

@Override
public void onResume() {
// TODO JENKINS-39134 do not call: super.onResume();
}

/**
* Detects if this step is running inside <tt>docker.image()</tt>
*
@@ -0,0 +1,71 @@
/*
* The MIT License
*
* Copyright 2016 CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.jenkinsci.plugins.pipeline.maven;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.Rule;
import org.junit.runners.model.Statement;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.RestartableJenkinsRule;

public class WithMavenStepTest {

@ClassRule
public static BuildWatcher buildWatcher = new BuildWatcher();

@Rule
public RestartableJenkinsRule rr = new RestartableJenkinsRule();

@Issue("JENKINS-39134")
@Test
public void resume() throws Exception {
rr.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
WorkflowJob p = rr.j.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("node {withMaven {semaphore 'wait'}}", true));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.waitForStart("wait/1", b);
}
});
rr.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
WorkflowJob p = rr.j.jenkins.getItemByFullName("p", WorkflowJob.class);
WorkflowRun b = p.getBuildByNumber(1);
SemaphoreStep.success("wait/1", null);
rr.j.assertBuildStatusSuccess(rr.j.waitForCompletion(b));
SemaphoreStep.success("wait/2", null);
rr.j.buildAndAssertSuccess(p);
}
});
}

}

0 comments on commit a272954

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