Skip to content
Permalink
Browse files

[JENKINS-27152] Option for pwd step to return temp directory.

Originally-Committed-As: 8c74333321f007e829b2a9581af643b792ef47a6
  • Loading branch information
jglick committed Mar 1, 2016
1 parent e99aa25 commit d6dbe7480cab9cb96dd584c2066de164ba36c868
Showing with 15 additions and 2 deletions.
  1. +15 −2 aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/PwdStepTest.java
@@ -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;
@@ -36,8 +38,19 @@

@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 d6dbe74

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