hudson.plugins.copyartifact
Class Copier

java.lang.Object
  extended by hudson.plugins.copyartifact.Copier
All Implemented Interfaces:
hudson.ExtensionPoint, CopyMethod
Direct Known Subclasses:
FilePathCopyMethod, FingerprintingCopyMethod

public abstract class Copier
extends Object
implements CopyMethod, hudson.ExtensionPoint

Extension point for how files are copied. CopyArtifact plugin provides a default implementation using methods available in the Jenkins FilePath class.

A copier instance

1.21 introduced this in place of CopyMethod to allow us to evolve this interface without breaking existing implementations.

Author:
Alan Harder, Kohsuke Kawaguchi
See Also:
"JENKINS-7753"

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Constructor Summary
Copier()
           
 
Method Summary
abstract  Copier clone()
          Creates a clone.
abstract  int copyAll(hudson.FilePath srcDir, String filter, hudson.FilePath targetDir)
          Copy files matching the given file mask to the specified target.
abstract  void copyOne(hudson.FilePath source, hudson.FilePath target)
          Copy a single file.
 void end()
          Ends what's started by the init(Run, AbstractBuild, FilePath, FilePath) method.
static Copier from(CopyMethod legacy)
          Wraps a CopyMethod into Copier for backward compatibility.
 void init(hudson.FilePath srcDir, hudson.FilePath baseTargetDir)
          Deprecated. call/override init(Run, AbstractBuild, FilePath, FilePath) instead.
 void init(hudson.model.Run src, hudson.model.AbstractBuild<?,?> dst, hudson.FilePath srcDir, hudson.FilePath baseTargetDir)
          Called before copy-artifact operation.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Copier

public Copier()
Method Detail

init

public void init(hudson.FilePath srcDir,
                 hudson.FilePath baseTargetDir)
          throws IOException,
                 InterruptedException
Deprecated. call/override init(Run, AbstractBuild, FilePath, FilePath) instead.

Description copied from interface: CopyMethod
Called before copy-artifact operation.

Specified by:
init in interface CopyMethod
Parameters:
srcDir - Source for upcoming file copy
baseTargetDir - Base target dir for upcoming file copy (the copy-artifact build step may later specify a deeper target dir)
Throws:
IOException
InterruptedException

init

public void init(hudson.model.Run src,
                 hudson.model.AbstractBuild<?,?> dst,
                 hudson.FilePath srcDir,
                 hudson.FilePath baseTargetDir)
          throws IOException,
                 InterruptedException
Called before copy-artifact operation.

Parameters:
src - The build record from which we are copying artifacts.
dst - The built into which we are copying artifacts.
srcDir - Source for upcoming file copy
baseTargetDir - Base target dir for upcoming file copy (the copy-artifact build step may later specify a deeper target dir)
Throws:
IOException
InterruptedException

copyAll

public abstract int copyAll(hudson.FilePath srcDir,
                            String filter,
                            hudson.FilePath targetDir)
                     throws IOException,
                            InterruptedException
Copy files matching the given file mask to the specified target.

Specified by:
copyAll in interface CopyMethod
Parameters:
srcDir - Source directory
filter - Ant GLOB pattern
targetDir - Target directory
Returns:
Number of files that were copied
Throws:
IOException
InterruptedException
See Also:
FilePath.copyRecursiveTo(String,FilePath)

copyOne

public abstract void copyOne(hudson.FilePath source,
                             hudson.FilePath target)
                      throws IOException,
                             InterruptedException
Copy a single file.

Specified by:
copyOne in interface CopyMethod
Parameters:
source - Source file
target - Target file (includes filename; this is not the target directory). Directory for target should already exist (copy-artifact build step calls mkdirs).
Throws:
IOException
InterruptedException
See Also:
FilePath.copyTo(FilePath)

end

public void end()
         throws IOException,
                InternalError
Ends what's started by the init(Run, AbstractBuild, FilePath, FilePath) method.

Throws:
IOException
InternalError

clone

public abstract Copier clone()
Creates a clone. This method is only called before the init(Run, AbstractBuild, FilePath, FilePath) method to allow each init-end session to run against different objects, so you need not copy any state that your Copier might maintain. This is a cheap hack to implement a factory withot breaking backward compatibility. If you maintain no state, this method can return this without creating a copy.

Overrides:
clone in class Object

from

public static Copier from(CopyMethod legacy)
Wraps a CopyMethod into Copier for backward compatibility.



Copyright © 2004-2012 Hudson. All Rights Reserved.