Skip to content
Permalink
Browse files

[JENKINS-27389] Reproduced problem in test.

  • Loading branch information
jglick committed Mar 30, 2015
1 parent 40af344 commit 82c0d5e025abec7ec00b1179c46f9c9b3266c18a
Showing with 27 additions and 0 deletions.
  1. +27 −0 src/test/java/org/jenkinsci/plugins/credentialsbinding/impl/BindingStepTest.java
@@ -53,10 +53,12 @@
import org.jenkinsci.plugins.workflow.steps.StepConfigTester;
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runners.model.Statement;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.RestartableJenkinsRule;

@@ -193,6 +195,31 @@
});
}

@Ignore("TODO reproduced")
@Issue("JENKINS-27389")
@Test public void grabEnv() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
String credentialsId = "creds";
String secret = "s3cr3t";
CredentialsProvider.lookupStores(story.j.jenkins).iterator().next().addCredentials(Domain.global(), new StringCredentialsImpl(CredentialsScope.GLOBAL, credentialsId, "sample", Secret.fromString(secret)));
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(""
+ "def extract(id) {\n"
+ " def v\n"
+ " withCredentials([[$class: 'StringBinding', credentialsId: id, variable: 'tmp']]) {\n"
+ " v = env.tmp\n"
+ " }\n"
+ " v\n"
+ "}\n"
+ "node {\n"
+ " echo \"got: ${extract('" + credentialsId + "')}\"\n"
+ "}", true));
story.j.assertLogContains("got: " + secret, story.j.assertBuildStatusSuccess(p.scheduleBuild2(0).get()));
}
});
}

private static Set<String> grep(File dir, String text) throws IOException {
Set<String> matches = new TreeSet<String>();
grep(dir, text, "", matches);

0 comments on commit 82c0d5e

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