public abstract class AbstractUpload extends Object implements hudson.model.Describable<AbstractUpload>, hudson.ExtensionPoint, Serializable
ClassicUpload,
We provide the following hooks for implementations to inject additional
functionality:
- Required {@link #getDetails}: provides detail information for the
GCS upload report.
- Required {@link #getInclusions}: surfaces the set of
{@link UploadSpec} for the base class to upload to GCS.
- Optional {@link #forResult}: determines the build states for which
uploading should be performed.
- Optional {@link #getMetadata}: allows the implementation to surface
additional metadata on the storage object
- Optional {@link #annotateObject}: allows the implementation to
~arbitrarily rewrite parts of the object prior to insertion.
,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractUpload.UploadSpec
This tuple is used to return the modified workspace and collection of
FilePaths to upload to perform(com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials, hudson.model.AbstractBuild<?, ?>, hudson.model.TaskListener). |
| Modifier and Type | Field and Description |
|---|---|
protected UploadModule |
module
The module to use for providing dependencies.
|
| Constructor and Description |
|---|
AbstractUpload(String bucket,
boolean sharedPublicly,
boolean forFailedJobs,
String pathPrefix,
UploadModule module)
Construct the base upload from a handful of universal properties.
|
| Modifier and Type | Method and Description |
|---|---|
static hudson.DescriptorExtensionList<AbstractUpload,AbstractUploadDescriptor> |
all()
Boilerplate, see:
https://wiki.jenkins-ci.org/display/JENKINS/Defining+a+new+extension+point
|
protected void |
annotateObject(com.google.api.services.storage.model.StorageObject object,
hudson.model.TaskListener listener)
This hook is intended to give implementations the opportunity to further
annotate the
StorageObject with metadata before uploading it to
cloud storage. |
boolean |
forResult(hudson.model.Result result)
Determine whether we should upload the pattern for the given
build result.
|
String |
getBucket()
The bucket name specified by the user, which potentially contains
unresolved symbols, such as $JOB_NAME and $BUILD_NUMBER.
|
AbstractUploadDescriptor |
getDescriptor()
Boilerplate, see:
https://wiki.jenkins-ci.org/display/JENKINS/Defining+a+new+extension+point
|
abstract String |
getDetails()
Provide detail information summarizing this download for the GCS
upload report.
|
protected abstract AbstractUpload.UploadSpec |
getInclusions(hudson.model.AbstractBuild<?,?> build,
hudson.FilePath workspace,
hudson.model.TaskListener listener)
Implementations override this interface in order to surface the set of
FilePaths the core logic should upload. |
protected Map<String,String> |
getMetadata(hudson.model.AbstractBuild<?,?> build)
Retrieves the metadata to attach to the storage object.
|
protected com.google.api.services.storage.model.Bucket |
getOrCreateBucket(com.google.api.services.storage.Storage service,
com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials,
com.google.jenkins.plugins.util.Executor executor,
String bucketName)
Fetches or creates an instance of the bucket with the given name with the
specified storage service.
|
String |
getPathPrefix()
The path prefix that will be stripped from uploaded files.
|
static String |
getRelative(hudson.FilePath include,
hudson.FilePath workspace)
Compute the relative path of the given file inclusion, relative to the
given workspace.
|
boolean |
isForFailedJobs()
Whether to attempt the upload, even if the job failed.
|
boolean |
isSharedPublicly()
Whether to surface the file being uploaded to anyone with the link.
|
void |
perform(com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials,
hudson.model.AbstractBuild<?,?> build,
hudson.model.TaskListener listener)
The main action entrypoint of this extension.
|
protected final UploadModule module
public AbstractUpload(String bucket, boolean sharedPublicly, boolean forFailedJobs, @Nullable String pathPrefix, @Nullable UploadModule module)
bucket - The unresolved name of the storage bucket within
which to store the resulting objects.sharedPublicly - Whether to publicly share the objects being uploadedforFailedJobs - Whether to perform the upload regardless of the
build's outcomepathPrefix - Path prefix to strip from uploaded files when determining
the filename in GCS. Null indicates no stripping. Filenames that do not
start with this prefix will not be modified. Trailing slash is
automatically added if it is missing.public final void perform(com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials,
hudson.model.AbstractBuild<?,?> build,
hudson.model.TaskListener listener)
throws UploadException
UploadException@Nullable protected abstract AbstractUpload.UploadSpec getInclusions(hudson.model.AbstractBuild<?,?> build, hudson.FilePath workspace, hudson.model.TaskListener listener) throws UploadException
FilePaths the core logic should upload.UploadExceptionfor further details.public abstract String getDetails()
protected void annotateObject(com.google.api.services.storage.model.StorageObject object,
hudson.model.TaskListener listener)
throws UploadException
StorageObject with metadata before uploading it to
cloud storage.
NOTE: The base implementation does not do anything, so calling
super.annotateObject() is unnecessary.UploadExceptionprotected Map<String,String> getMetadata(hudson.model.AbstractBuild<?,?> build)
public boolean forResult(hudson.model.Result result)
public String getBucket()
public boolean isSharedPublicly()
public boolean isForFailedJobs()
@Nullable public String getPathPrefix()
public static hudson.DescriptorExtensionList<AbstractUpload,AbstractUploadDescriptor> all()
public AbstractUploadDescriptor getDescriptor()
getDescriptor in interface hudson.model.Describable<AbstractUpload>protected com.google.api.services.storage.model.Bucket getOrCreateBucket(com.google.api.services.storage.Storage service,
com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials,
com.google.jenkins.plugins.util.Executor executor,
String bucketName)
throws UploadException
credentials - The credentials with which to fetch/create the bucketbucketName - The top-level bucket name to ensure existsUploadException - if any issues are encounteredpublic static String getRelative(hudson.FilePath include, hudson.FilePath workspace) throws UploadException
include - The file whose relative path we are computingworkspace - The workspace containing the included file.UploadException - when the input is malformedCopyright © 2004-2015. All Rights Reserved.