Class AbstractOnDiskBinding<C extends com.cloudbees.plugins.credentials.common.StandardCredentials>
java.lang.Object
hudson.model.AbstractDescribableImpl<MultiBinding<C>>
org.jenkinsci.plugins.credentialsbinding.MultiBinding<C>
org.jenkinsci.plugins.credentialsbinding.Binding<C>
org.jenkinsci.plugins.credentialsbinding.impl.AbstractOnDiskBinding<C>
- Type Parameters:
C
- a kind of credentials
- All Implemented Interfaces:
ExtensionPoint
,Describable<MultiBinding<C>>
- Direct Known Subclasses:
FileBinding
,ZipFileBinding
public abstract class AbstractOnDiskBinding<C extends com.cloudbees.plugins.credentials.common.StandardCredentials>
extends Binding<C>
Base class for writing credentials to a file or directory, and binding its path to a single variable. Handles
creation of a -rwx------ temporary directory, and its full deletion when unbinding, using
UnbindableDir
.
This can only safely be used for binding implementations for which BindingDescriptor.requiresWorkspace()
is true.-
Nested Class Summary
Nested classes/interfaces inherited from class org.jenkinsci.plugins.credentialsbinding.Binding
Binding.Environment, Binding.SingleEnvironment
Nested classes/interfaces inherited from class org.jenkinsci.plugins.credentialsbinding.MultiBinding
MultiBinding.MultiEnvironment, MultiBinding.NullUnbinder, MultiBinding.Unbinder
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractOnDiskBinding
(String variable, String credentialsId) -
Method Summary
Modifier and TypeMethodDescriptionbindSingle
(Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener) Sets up bindings for a build.protected abstract FilePath
Writes credentials under a given temporary directory, and returns their path (will be bound to the variable).Methods inherited from class org.jenkinsci.plugins.credentialsbinding.Binding
bind, bind, getCredentials, getVariable, variables
Methods inherited from class org.jenkinsci.plugins.credentialsbinding.MultiBinding
getCredentials, getCredentialsId, getDescriptor, type, variables
-
Constructor Details
-
AbstractOnDiskBinding
-
-
Method Details
-
bindSingle
public final Binding.SingleEnvironment bindSingle(@NonNull Run<?, ?> build, FilePath workspace, Launcher launcher, @NonNull TaskListener listener) throws IOException, InterruptedExceptionDescription copied from class:Binding
Sets up bindings for a build.- Overrides:
bindSingle
in classBinding<C extends com.cloudbees.plugins.credentials.common.StandardCredentials>
- Parameters:
build
- The build. Cannot be nullworkspace
- The workspace - can be null ifBindingDescriptor.requiresWorkspace()
is false.launcher
- The launcher - can be null ifBindingDescriptor.requiresWorkspace()
is false.listener
- The task listener. Cannot be null.- Returns:
- The configured
Binding.SingleEnvironment
- Throws:
IOException
InterruptedException
-
write
protected abstract FilePath write(C credentials, FilePath dir) throws IOException, InterruptedException Writes credentials under a given temporary directory, and returns their path (will be bound to the variable).- Parameters:
credentials
- the credentials to binddir
- a temporary directory where credentials should be written. You can assume it has already been created, with secure permissions.- Returns:
- the path to the on-disk credentials, to be bound to the variable
- Throws:
IOException
InterruptedException
-