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,
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.Run<?,?> run,
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.Run<?,?> run)
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() |
boolean |
isForFailedJobs() |
boolean |
isSharedPublicly() |
boolean |
isShowInline() |
void |
perform(com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials,
hudson.model.AbstractBuild<?,?> build,
hudson.model.TaskListener listener)
Allow old signature for compatibility.
|
void |
perform(com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials,
hudson.model.Run<?,?> run,
hudson.FilePath workspace,
hudson.model.TaskListener listener)
The main action entrypoint of this extension.
|
void |
setForFailedJobs(boolean forFailedJobs)
Whether to attempt the upload, even if the job failed.
|
void |
setPathPrefix(String pathPrefix)
The path prefix that will be stripped from uploaded files.
|
void |
setSharedPublicly(boolean sharedPublicly)
Whether to surface the file being uploaded to anyone with the link.
|
void |
setShowInline(boolean showInline)
Whether to indicate in metadata that the file should be viewable inline
in web browsers, rather than requiring it to be downloaded first.
|
protected static final int MAX_REMOTE_CREDENTIAL_EXPIRED_RETRIES
protected final UploadModule module
public AbstractUpload(String bucket, @Nullable UploadModule module)
bucket
- The unresolved name of the storage bucket within which to
store the resulting objects.module
- An UploadModule
to use for execution.public final void perform(com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials, hudson.model.AbstractBuild<?,?> build, hudson.model.TaskListener listener) throws UploadException
UploadException
public final void perform(com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials, hudson.model.Run<?,?> run, hudson.FilePath workspace, hudson.model.TaskListener listener) throws UploadException
UploadException
@Nullable protected abstract AbstractUpload.UploadSpec getInclusions(hudson.model.Run<?,?> run, 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.Run<?,?> run)
public boolean forResult(hudson.model.Result result)
public String getBucket()
@DataBoundSetter public void setSharedPublicly(boolean sharedPublicly)
public boolean isSharedPublicly()
@DataBoundSetter public void setForFailedJobs(boolean forFailedJobs)
public boolean isForFailedJobs()
@DataBoundSetter public void setShowInline(boolean showInline)
public boolean isShowInline()
@DataBoundSetter public void setPathPrefix(@Nullable String pathPrefix)
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 encounteredCopyright © 2016–2017. All rights reserved.