Skip to content
Permalink
Browse files
[JENKINS-41759] Fixing failing credentials tests after refactor
Some other tests are still failing...
  • Loading branch information
rsandell committed Feb 9, 2017
1 parent 5d2bc33 commit a97ef23928606c1dc2db4df97436e8d8ebc4dc53
@@ -32,6 +32,7 @@
import org.jenkinsci.plugins.pipeline.modeldefinition.environment.DeclarativeEnvironmentContributorDescriptor;
import org.jenkinsci.plugins.pipeline.modeldefinition.model.CredentialsBindingHandler;
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
import org.jenkinsci.plugins.workflow.cps.CpsScript;
import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper;
import org.kohsuke.stapler.DataBoundConstructor;

@@ -57,7 +58,14 @@ public String getCredentialsId() {
return credentialsId;
}

public void prepare(RunWrapper currentBuild) throws CredentialNotFoundException {
@Whitelisted
public void addParameters(CpsScript script, String envVarName, List<Map<String, Object>> list) throws CredentialNotFoundException {
RunWrapper currentBuild = (RunWrapper) script.getProperty("currentBuild");
prepare(currentBuild);
list.addAll(resolveParameters(envVarName));
}

private void prepare(RunWrapper currentBuild) throws CredentialNotFoundException {
CredentialsBindingHandler handler = CredentialsBindingHandler.forId(credentialsId, currentBuild.getRawBuild());
withCredentialsParameters = handler.getWithCredentialsParameters(credentialsId);
}
@@ -230,7 +230,7 @@ public class ModelInterpreter implements Serializable {
List<Map<String, Object>> parameters = []
Set<Map.Entry<String, Credentials>> set = credentials.entrySet()
for (Map.Entry<String, Credentials> entry : set) {
entry.value.getScript(script).addParameters(entry.key, parameters)
entry.value.addParameters(script, entry.key, parameters)
}
parameters
}
@@ -25,25 +25,18 @@
package org.jenkinsci.plugins.pipeline.modeldefinition.environment.impl

import org.jenkinsci.plugins.pipeline.modeldefinition.environment.DeclarativeEnvironmentContributorScript
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted
import org.jenkinsci.plugins.workflow.cps.CpsScript
import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper

public class CredentialsScript extends DeclarativeEnvironmentContributorScript<Credentials> {

CredentialsScript(CpsScript script, Credentials contributor) {
super(script, contributor)
RunWrapper currentBuild = script.getProperty("currentBuild")
contributor.prepare(currentBuild)
}

@Override
List<String> generate(String key) {
return null //Not used because MutedGenerator
}

@Whitelisted
public void addParameters(String envVarName, List<Map<String, Object>> list) {
list.addAll(describable.resolveParameters(envVarName))
}

}

0 comments on commit a97ef23

Please sign in to comment.