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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DownloadStep.DescriptorImpl
Descriptor for the DownloadStepprotected static class
DownloadStep.StorageObjectId
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
Constructors Constructor Description DownloadStep(String credentialsId, String bucketUri, String localDirectory)
DataBoundConstructor for DownloadStep.DownloadStep(String credentialsId, String bucketUri, String localDirectory, UploadModule module)
Constructor for DownloadStep.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getBucketUri()
com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials
getCredentials()
String
getCredentialsId()
DownloadStep.DescriptorImpl
getDescriptor()
String
getLocalDirectory()
protected UploadModule
getModule()
String
getPathPrefix()
BuildStepMonitor
getRequiredMonitorService()
void
perform(Run<?,?> run, FilePath workspace, Launcher launcher, TaskListener listener)
The main entry point of this extension.void
setPathPrefix(String pathPrefix)
static String[]
split(String uri)
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 Detail
-
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 Detail
-
getBucketUri
public String getBucketUri()
- Returns:
- The bucket uri specified by the user, which potentially contains unresolved symbols, such as $JOB_NAME and $BUILD_NUMBER.
-
getLocalDirectory
public String 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
@DataBoundSetter public void setPathPrefix(@Nullable String pathPrefix)
- 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
@Nullable public String 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
protected UploadModule getModule()
- Returns:
- The UploadModule used for providing dependencies.
-
getCredentialsId
public String 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
public BuildStepMonitor 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, InterruptedException
The 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
public static String[] split(String uri) throws AbortException
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
public DownloadStep.DescriptorImpl getDescriptor()
- Specified by:
getDescriptor
in interfaceDescribable<Builder>
- Overrides:
getDescriptor
in classBuilder
-
-