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 UploadModule |
module
The module to use for providing dependencies.
|
Constructor and Description |
---|
AbstractUpload(String bucketNameWithVars,
boolean sharedPublicly,
boolean forFailedJobs,
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 |
getBucketNameWithVars()
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.
|
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 bucketNameWithVars, boolean sharedPublicly, boolean forFailedJobs, @Nullable UploadModule module)
bucketNameWithVars
- 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 outcomepublic 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 getBucketNameWithVars()
public boolean isSharedPublicly()
public boolean isForFailedJobs()
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-2014. All Rights Reserved.