Class CNDocumentUploader
- java.lang.Object
-
- hudson.tasks.BuildStepCompatibilityLayer
-
- hudson.tasks.Publisher
-
- hudson.tasks.Notifier
-
- hudson.plugins.collabnet.AbstractTeamForgeNotifier
-
- hudson.plugins.collabnet.documentuploader.CNDocumentUploader
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<Publisher>
,BuildStep
public class CNDocumentUploader extends AbstractTeamForgeNotifier
Jenkins plugin to upload the Jenkins build log to the CollabNet Documents.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CNDocumentUploader.DescriptorImpl
The CNDocumentUploader Descriptor class.-
Nested classes/interfaces inherited from class hudson.tasks.Publisher
Publisher.DescriptorExtensionListImpl
-
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherList
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
-
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
-
-
Constructor Summary
Constructors Constructor Description CNDocumentUploader(ConnectionFactory connectionFactory, String project, String uploadPath, String description, FilePattern[] filePatterns, boolean includeBuildLog)
Creates a new CNDocumentUploader object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getDescription()
FilePattern[]
getFilePatterns()
boolean
getIncludeBuildLog()
static String
getMimeType(FilePath filePath)
Get the mimetype for the file.static String
getMimeType(File f)
Get the mimetype for the file.BuildStepMonitor
getRequiredMonitorService()
String
getUploadPath()
void
logoff()
Log out of the collabnet server.boolean
perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener)
The function does the work of uploading the build log.int
uploadFiles(CTFDocumentFolder folder, AbstractBuild<?,?> build, BuildListener listener)
Upload files matching the file patterns to the Document Service.-
Methods inherited from class hudson.plugins.collabnet.AbstractTeamForgeNotifier
connect, getCollabNetUrl, getConnectionFactory, getPassword, getProject, getTeamForgeShareDescriptor, getUsername, overrideAuth
-
Methods inherited from class hudson.tasks.Notifier
getDescriptor
-
Methods inherited from class hudson.tasks.Publisher
all, getProjectAction, needsToRunAfterFinalized, prebuild
-
Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectActions, perform, prebuild
-
-
-
-
Constructor Detail
-
CNDocumentUploader
@DataBoundConstructor public CNDocumentUploader(ConnectionFactory connectionFactory, String project, String uploadPath, String description, FilePattern[] filePatterns, boolean includeBuildLog)
Creates a new CNDocumentUploader object.- Parameters:
connectionFactory
- connectionFactoryproject
- where the build log will be uploaded.uploadPath
- on the CollabNet server, where the build log should be uploaded.description
- the description of the documentfilePatterns
- array of FilePattern objectsincludeBuildLog
- boolean flag
-
-
Method Detail
-
getUploadPath
public String getUploadPath()
- Returns:
- the path where the build log is uploaded.
-
getDescription
public String getDescription()
- Returns:
- the description of the uploaded files.
-
getFilePatterns
public FilePattern[] getFilePatterns()
- Returns:
- the ant-style file patterns.
-
getIncludeBuildLog
public boolean getIncludeBuildLog()
- Returns:
- true if the build log should be uploaded.
-
getRequiredMonitorService
public BuildStepMonitor getRequiredMonitorService()
-
perform
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException
The function does the work of uploading the build log.- Specified by:
perform
in interfaceBuildStep
- Overrides:
perform
in classBuildStepCompatibilityLayer
- Parameters:
build
- current Jenkins build.launcher
- unused.listener
- receives events that happen during a build. We use it for logging.- Returns:
- true if successful, false if a critical error occurred.
- Throws:
IOException
InterruptedException
-
uploadFiles
public int uploadFiles(CTFDocumentFolder folder, AbstractBuild<?,?> build, BuildListener listener) throws IOException, InterruptedException
Upload files matching the file patterns to the Document Service.- Parameters:
folder
- folder where the files should be uploaded.build
- the current Jenkins build.- Returns:
- the number of files successfully uploaded.
- Throws:
IOException
InterruptedException
-
getMimeType
public static String getMimeType(FilePath filePath)
Get the mimetype for the file.- Parameters:
filePath
- The filePath to return the mimetype for.- Returns:
- the string representing the mimetype of the file.
-
getMimeType
public static String getMimeType(File f)
Get the mimetype for the file.- Parameters:
f
- The file to return the mimetype for.- Returns:
- the string representing the mimetype of the file.
-
logoff
public void logoff()
Log out of the collabnet server. Invalidates the cna object.
-
-