Skip to content
Permalink
Browse files

[JENKINS-38831] Fix binary incompatability and fix erroneous extra cr…

…edential lookups.
  • Loading branch information...
iwarapter committed Oct 24, 2016
1 parent f220b8a commit be563fab1fc7b72ad869b9a4e0d18cbe1de2b0c3
@@ -24,17 +24,13 @@

package org.jenkinsci.plugins.credentialsbinding;

import com.cloudbees.plugins.credentials.CredentialsDescriptor;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.IdCredentials;
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import hudson.ExtensionPoint;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.model.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Serializable;
@@ -62,7 +58,7 @@ protected MultiBinding(String credentialsId) {
}

/** Type token. */
public abstract Class<C> type();
protected abstract Class<C> type();

/** Identifier of the credentials to be bound. */
public final String getCredentialsId() {
@@ -120,6 +116,7 @@ public Unbinder getUnbinder() {
*/
protected final @Nonnull C getCredentials(@Nonnull Run<?,?> build) throws IOException {
IdCredentials cred = CredentialsProvider.findCredentialById(credentialsId, IdCredentials.class, build);
CredentialsProvider.track(build, cred);
if (cred==null)
throw new CredentialNotFoundException(credentialsId);

@@ -24,8 +24,6 @@

package org.jenkinsci.plugins.credentialsbinding.impl;

import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.IdCredentials;
import com.google.inject.Inject;
import hudson.EnvVars;
import hudson.Extension;
@@ -94,8 +92,6 @@
MultiBinding.MultiEnvironment environment = binding.bind(run, workspace, launcher, listener);
unbinders.add(environment.getUnbinder());
overrides.putAll(environment.getValues());
IdCredentials id = CredentialsProvider.findCredentialById(binding.getCredentialsId(), binding.type(), run);
CredentialsProvider.track(run, id);
}
getContext().newBodyInvoker().
withContext(EnvironmentExpander.merge(getContext().get(EnvironmentExpander.class), new Overrider(overrides))).
@@ -44,7 +44,7 @@
super(variable, credentialsId);
}

@Override public Class<FileCredentials> type() {
@Override protected Class<FileCredentials> type() {
return FileCredentials.class;
}

@@ -24,8 +24,6 @@

package org.jenkinsci.plugins.credentialsbinding.impl;

import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.IdCredentials;
import hudson.Extension;
import hudson.Launcher;
import hudson.model.AbstractBuild;
@@ -59,8 +57,6 @@
final List<MultiBinding.MultiEnvironment> m = new ArrayList<MultiBinding.MultiEnvironment>();
for (MultiBinding binding : bindings) {
m.add(binding.bind(build, build.getWorkspace(), launcher, listener));
IdCredentials id = CredentialsProvider.findCredentialById(binding.getCredentialsId(), binding.type(), build);
CredentialsProvider.track(build, id);
}
return new Environment() {
@Override public void buildEnvVars(Map<String,String> env) {
@@ -42,7 +42,7 @@
super(variable, credentialsId);
}

@Override public Class<StringCredentials> type() {
@Override protected Class<StringCredentials> type() {
return StringCredentials.class;
}

@@ -42,7 +42,7 @@
super(variable, credentialsId);
}

@Override public Class<StandardUsernamePasswordCredentials> type() {
@Override protected Class<StandardUsernamePasswordCredentials> type() {
return StandardUsernamePasswordCredentials.class;
}

@@ -60,7 +60,7 @@ public String getPasswordVariable() {
return passwordVariable;
}

@Override public Class<StandardUsernamePasswordCredentials> type() {
@Override protected Class<StandardUsernamePasswordCredentials> type() {
return StandardUsernamePasswordCredentials.class;
}

0 comments on commit be563fa

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