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 FormModifier and Type | Class and Description |
---|---|
protected static class |
AbstractUpload.UploadSpec
This tuple is used to return the modified workspace and collection of
FilePath s to upload to perform(com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials, hudson.model.AbstractBuild<?, ?>, hudson.model.TaskListener) . |
Modifier and Type | Field and Description |
---|---|
protected static int |
MAX_REMOTE_CREDENTIAL_EXPIRED_RETRIES |
protected UploadModule |
module
The module to use for providing dependencies.
|
Constructor and Description |
---|
AbstractUpload(String bucket,
boolean sharedPublicly,
boolean forFailedJobs,
boolean showInline,
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
FilePath s 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.
|
protected String |
getStrippedFilename(String filename)
If a path prefix to strip has been specified, and the input string
starts with that prefix, returns the portion of the input after that
prefix.
|
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.
|
boolean |
isShowInline()
Whether to indicate in metadata that the file should be viewable inline
in web browsers, rather than requiring it to be downloaded first.
|
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 static final int MAX_REMOTE_CREDENTIAL_EXPIRED_RETRIES
protected final UploadModule module
public AbstractUpload(String bucket, boolean sharedPublicly, boolean forFailedJobs, boolean showInline, @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 outcomeshowInline
- Whether to indicate in metadata that the file should be
viewable inline in web browsers, rather than requiring it to be downloaded
first.pathPrefix
- 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
FilePath
s the core logic should upload.UploadException
for 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.UploadException
protected Map<String,String> getMetadata(hudson.model.AbstractBuild<?,?> build)
public boolean forResult(hudson.model.Result result)
public String getBucket()
public boolean isSharedPublicly()
public boolean isForFailedJobs()
public boolean isShowInline()
@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 encounteredprotected String getStrippedFilename(String filename)
public 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 © 2016–2017. All rights reserved.