Class AbstractUpload
java.lang.Object
com.google.jenkins.plugins.storage.AbstractUpload
- All Implemented Interfaces:
- ExtensionPoint,- Describable<AbstractUpload>,- Serializable
- Direct Known Subclasses:
- AbstractBucketLifecycleManager,- ClassicUpload,- StdoutUpload
public abstract class AbstractUpload
extends Object
implements Describable<AbstractUpload>, ExtensionPoint, Serializable
This new extension point is used for surfacing different kinds of Google Cloud Storage (GCS)
 uploads. The most obvious implementations are provided as:
- See Also:
- 
- ClassicUpload
- We provide the following hooks for implementations to inject additional functionality: - Required #getDetails: provides detail information for the GCS upload report.
- Required #getInclusions: surfaces the set of UploadSpec for the base class to upload to GCS.
- Optional #forResult: determines the build states for which uploading should be performed.
- Optional #getMetadata: allows the implementation to surface additional metadata on the storage object
- Optional #annotateObject: allows the implementation to ~arbitrarily rewrite parts of the object prior to insertion.
 
- Serialized Form
 
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classThis tuple is used to return the modified workspace and collection ofFilePaths to upload toperform(java.lang.String, hudson.model.AbstractBuild<?, ?>, hudson.model.TaskListener).Nested classes/interfaces inherited from interface hudson.ExtensionPointExtensionPoint.LegacyInstancesAreScopedToHudson
- 
Constructor SummaryConstructorsConstructorDescriptionAbstractUpload(String bucket, UploadModule module) Construct the base upload from a handful of universal properties.
- 
Method SummaryModifier and TypeMethodDescriptionall()Gives all registeredAbstractUploads.protected voidannotateObject(com.google.api.services.storage.model.StorageObject object, TaskListener listener) This hook is intended to give implementations the opportunity to further annotate theStorageObjectwith metadata before uploading it to cloud storage.booleanDetermine whether we should upload the pattern for the given build result.abstract Stringprotected abstract AbstractUpload.UploadSpecgetInclusions(Run<?, ?> run, FilePath workspace, TaskListener listener) Implementations override this interface in order to surface the set ofFilePaths the core logic should upload.getMetadata(Run<?, ?> run) Retrieves the metadata to attach to the storage object.protected UploadModuleprotected com.google.api.services.storage.model.BucketgetOrCreateBucket(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.booleanbooleanbooleanfinal voidperform(String credentialsId, AbstractBuild<?, ?> build, TaskListener listener) This method allows the old signature for compatibility reasons.final voidperform(String credentialsId, Run<?, ?> run, FilePath workspace, TaskListener listener) The main action entry point of this extension.voidsetForFailedJobs(boolean forFailedJobs) voidsetPathPrefix(String pathPrefix) voidsetSharedPublicly(boolean sharedPublicly) voidsetShowInline(boolean showInline) 
- 
Constructor Details- 
AbstractUploadConstruct the base upload from a handful of universal properties.- Parameters:
- bucket- The unresolved name of the storage bucket within which to store the resulting objects.
- module- An- UploadModuleto use for execution.
 
 
- 
- 
Method Details- 
performpublic final void perform(String credentialsId, AbstractBuild<?, ?> build, TaskListener listener) throws UploadException, IOExceptionThis method allows the old signature for compatibility reasons. Callsperform(String, Run, FilePath, TaskListener).- Parameters:
- credentialsId- The unique ID for the credentials we are using to authenticate with GCS.
- build- Current build being run.
- listener- Listener for events of this job.
- Throws:
- UploadException- If there was an issue uploading/accessing the GCS API.
- IOException- If there was issue authenticating with credentialsId.
 
- 
performpublic final void perform(String credentialsId, Run<?, ?> run, FilePath workspace, TaskListener listener) throws UploadException, IOExceptionThe main action entry point of this extension. This uploads the contents included by the implementation to our resolved storage bucket.- Parameters:
- credentialsId- The unique ID for the credentials we are using to authenticate with GCS.
- run- Current job being run.
- workspace- Workspace of node running the job.
- listener- Listener for events of this job.
- Throws:
- UploadException- If there was an issue uploading/accessing the GCS API.
- IOException- If there was issue authenticating with credentialsId.
 
- 
getInclusions@Nullable protected abstract AbstractUpload.UploadSpec getInclusions(Run<?, ?> run, FilePath workspace, TaskListener listener) throws UploadExceptionImplementations override this interface in order to surface the set ofFilePaths the core logic should upload.- Parameters:
- run- Current job being run.
- workspace- Workspace of node running the job.
- listener- Listener for events of this job.
- Returns:
- Set of FilePaths to upload.
- Throws:
- UploadException- If there was an issue fetching the inclusions.
- See Also:
 
- 
annotateObjectprotected void annotateObject(com.google.api.services.storage.model.StorageObject object, TaskListener listener) throws UploadException This hook is intended to give implementations the opportunity to further annotate theStorageObjectwith metadata before uploading it to cloud storage.NOTE: The base implementation does not do anything, so calling super.annotateObject()is unnecessary.- Parameters:
- object- GCS object to annotate.
- listener- Listener for events of this job.
- Throws:
- UploadException- If there was an issue annotating the object with metadata.
 
- 
getMetadataRetrieves the metadata to attach to the storage object.NOTE: This can be overriden to surface additional (or less) information. - Parameters:
- run- Current job being run.
- Returns:
- Metadata in key-value form.
 
- 
forResultDetermine whether we should upload the pattern for the given build result.- Parameters:
- result- Result of the build run.
- Returns:
- Whether we should upload the pattern for the given build result.
 
- 
getDetails- Returns:
- Provide detail information summarizing this download for the GCS upload report.
 
- 
getModule- Returns:
- The UploadModulefor providing dependencies.
 
- 
getBucket- Returns:
- The bucket name specified by the user, which potentially contains unresolved symbols, such as $JOB_NAME and $BUILD_NUMBER.
 
- 
setForFailedJobs@DataBoundSetter public void setForFailedJobs(boolean forFailedJobs) - Parameters:
- forFailedJobs- Whether to attempt the upload, even if the job failed.
 
- 
isForFailedJobspublic boolean isForFailedJobs()- Returns:
- Whether to attempt the upload, even if the job failed.
 
- 
setShowInline@DataBoundSetter public void setShowInline(boolean showInline) - Parameters:
- showInline- Set whether to indicate in metadata that the file should be viewable inline in web browsers, rather than requiring it to be downloaded first.
 
- 
isShowInlinepublic boolean isShowInline()- Returns:
- Whether to indicate in metadata that the file should be viewable inline in web browsers, rather than requiring it to be downloaded first.
 
- 
setPathPrefix- Parameters:
- pathPrefix- The path prefix that will be stripped from uploaded files. May be null if no path prefix needs to be stripped.- Filenames that do not start with this prefix will not be modified. Trailing slash is automatically added if it is missing. 
 
- 
getPathPrefix- Returns:
- The path prefix that will be stripped from uploaded files. May be null if no path
     prefix needs to be stripped.
     Filenames that do not start with this prefix will not be modified. Trailing slash is automatically added if it is missing. 
 
- 
allGives all registeredAbstractUploads. See: https://wiki.jenkins-ci.org/display/JENKINS/Defining+a+new+extension+point- Returns:
- All registered AbstractUploads.
 
- 
getDescriptor- Specified by:
- getDescriptorin interface- Describable<AbstractUpload>
 
- 
getOrCreateBucketprotected 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 Fetches or creates an instance of the bucket with the given name with the specified storage service.- Parameters:
- service- Handle to the GCS API.
- credentials- The credentials with which to fetch/create the bucket
- executor- Helper class to make calls to the GCS API.
- bucketName- The top-level bucket name to ensure exists
- Returns:
- an instance of the named bucket, created or retrieved.
- Throws:
- UploadException- if any issues are encountered
 
 
-