Skip to content

Commit

Permalink
[JENKINS-27152] Option for pwd step to return temp directory.
Browse files Browse the repository at this point in the history
Originally-Committed-As: 8c74333321f007e829b2a9581af643b792ef47a6
  • Loading branch information
jglick committed Mar 1, 2016
1 parent 9b85b7f commit 65490d1
Showing 1 changed file with 15 additions and 2 deletions.
Expand Up @@ -24,6 +24,8 @@

package org.jenkinsci.plugins.workflow.steps;

import hudson.FilePath;
import hudson.slaves.WorkspaceList;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.junit.Test;
Expand All @@ -36,8 +38,19 @@ public class PwdStepTest {

@Test public void basics() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("node {echo \"cwd=${pwd()}\"}", true));
r.assertLogContains("cwd=" + r.jenkins.getWorkspaceFor(p), r.assertBuildStatusSuccess(p.scheduleBuild2(0)));
p.setDefinition(new CpsFlowDefinition("node {echo \"cwd='${pwd()}'\"}", true));
r.assertLogContains("cwd='" + r.jenkins.getWorkspaceFor(p) + "'", r.assertBuildStatusSuccess(p.scheduleBuild2(0)));
}

// TODO use https://github.com/jenkinsci/jenkins/pull/2066
private static FilePath tempDir(FilePath ws) {
return ws.sibling(ws.getName() + System.getProperty(WorkspaceList.class.getName(), "@") + "tmp");
}

@Test public void tmp() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("node {echo \"tmp='${pwd tmp: true}'\"}", true));
r.assertLogContains("tmp='" + tempDir(r.jenkins.getWorkspaceFor(p)) + "'", r.assertBuildStatusSuccess(p.scheduleBuild2(0)));
}

}

0 comments on commit 65490d1

Please sign in to comment.