Class DownloadStep
java.lang.Object
hudson.tasks.BuildStepCompatibilityLayer
hudson.tasks.Builder
com.google.jenkins.plugins.storage.DownloadStep
- All Implemented Interfaces:
ExtensionPoint
,Describable<Builder>
,BuildStep
,Serializable
,SimpleBuildStep
@RequiresDomain(StorageScopeRequirement.class)
public class DownloadStep
extends Builder
implements SimpleBuildStep, Serializable
A step to allow Download from Google Cloud Storage as a Build step and in pipeline.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Descriptor for the DownloadStepprotected static class
A class to store StorageObject information in a serializable manner.Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherList
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
Nested classes/interfaces inherited from interface jenkins.tasks.SimpleBuildStep
SimpleBuildStep.LastBuildAction, SimpleBuildStep.LastBuildActionFactory
-
Field Summary
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
-
Constructor Summary
ConstructorsConstructorDescriptionDownloadStep
(String credentialsId, String bucketUri, String localDirectory) DataBoundConstructor for DownloadStep.DownloadStep
(String credentialsId, String bucketUri, String localDirectory, UploadModule module) Constructor for DownloadStep. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials
protected UploadModule
void
perform
(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) The main entry point of this extension.void
setPathPrefix
(String pathPrefix) static String[]
Split the string on wildcards ("*").Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectAction, getProjectActions, perform, perform, prebuild
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface hudson.tasks.BuildStep
getProjectAction, getProjectActions, perform, prebuild
Methods inherited from interface jenkins.tasks.SimpleBuildStep
perform, perform, requiresWorkspace
-
Constructor Details
-
DownloadStep
@DataBoundConstructor public DownloadStep(String credentialsId, String bucketUri, String localDirectory) DataBoundConstructor for DownloadStep.- Parameters:
credentialsId
- The unique ID for the credentials we are using to authenticate with GCS.bucketUri
- Name of the GCS bucket. e.g. gs://MY_BUCKET_NAMElocalDirectory
- Path of the local directory in Jenkins to download the file to.
-
DownloadStep
public DownloadStep(String credentialsId, String bucketUri, String localDirectory, @Nullable UploadModule module) Constructor for DownloadStep.- Parameters:
credentialsId
- The unique ID for the credentials we are using to authenticate with GCS.bucketUri
- Name of the GCS bucket. e.g. gs://MY_BUCKET_NAMElocalDirectory
- Path of the local directory in Jenkins to download the file to.module
- AnUploadModule
to use for execution.
-
-
Method Details
-
getBucketUri
- Returns:
- The bucket uri specified by the user, which potentially contains unresolved symbols, such as $JOB_NAME and $BUILD_NUMBER.
-
getLocalDirectory
- Returns:
- The local directory in the Jenkins workspace that will receive the files. This might contain unresolved symbols, such as $JOB_NAME and $BUILD_NUMBER.
-
setPathPrefix
- Parameters:
pathPrefix
- The path prefix that will be stripped from downloaded 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 downloaded 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.
-
getModule
- Returns:
- The UploadModule used for providing dependencies.
-
getCredentialsId
- Returns:
- The unique ID for the credentials we are using to authenticate with GCS.
-
getCredentials
public com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials getCredentials()- Returns:
- The credentials we are using to authenticate with GCS.
-
getRequiredMonitorService
- Specified by:
getRequiredMonitorService
in interfaceBuildStep
- Overrides:
getRequiredMonitorService
in classBuilder
-
perform
public void perform(@NonNull Run<?, ?> run, @NonNull FilePath workspace, @NonNull Launcher launcher, @NonNull TaskListener listener) throws IOException, InterruptedExceptionThe main entry point of this extension. Downloads the resolved GCS objects from the resolved GCS bucket to a local directory.- Specified by:
perform
in interfaceSimpleBuildStep
- Parameters:
run
- Current job being run.workspace
- Workspace of node running the job.launcher
-Launcher
for this job.listener
- Listener for events of this job.- Throws:
IOException
- If there was an issue parsing the bucket URI.InterruptedException
- If there was an issue initiating downloads at workspace or expanding variables in the pathPrefix.
-
split
Split the string on wildcards ("*").String.split removes trailing empty strings, for example, "a", "a*" and "a**" and would produce the same result, so that method is not suitable.
- Parameters:
uri
- URI supplied to be split.- Returns:
- URI split by "*" wildcard.
- Throws:
AbortException
- If there is more than one wild card character in the provided string.
-
getDescriptor
- Specified by:
getDescriptor
in interfaceDescribable<Builder>
- Overrides:
getDescriptor
in classBuilder
-