hudson.plugins.collabnet.documentuploader
Class CNDocumentUploader

java.lang.Object
  extended by hudson.tasks.BuildStepCompatibilityLayer
      extended by hudson.tasks.Publisher
          extended by hudson.tasks.Notifier
              extended by hudson.plugins.collabnet.documentuploader.CNDocumentUploader
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Describable<hudson.tasks.Publisher>, hudson.tasks.BuildStep

public class CNDocumentUploader
extends hudson.tasks.Notifier

Hudson plugin to upload the Hudson build log to the CollabNet Documents.


Nested Class Summary
static class CNDocumentUploader.DescriptorImpl
          The CNDocumentUploader Descriptor class.
 
Nested classes/interfaces inherited from class hudson.tasks.Publisher
hudson.tasks.Publisher.DescriptorExtensionListImpl
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
hudson.tasks.BuildStep.PublisherList
 
Field Summary
 
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
 
Constructor Summary
CNDocumentUploader(java.lang.String url, java.lang.String username, java.lang.String password, java.lang.String project, java.lang.String uploadPath, java.lang.String description, java.lang.String[] filePatterns, boolean includeBuildLog, boolean override_auth)
          Creates a new CNDocumentUploader object.
 
Method Summary
 java.lang.String getCollabNetUrl()
           
 java.lang.String getDescription()
           
 java.lang.String[] getFilePatterns()
           
static java.lang.String getMimeType(java.io.File f)
          Get the mimetype for the file.
static java.lang.String getMimeType(hudson.FilePath filePath)
          Get the mimetype for the file.
 java.lang.String getPassword()
           
 java.lang.String getProject()
           
 java.lang.String getProjectId()
          Get the project id for the project name.
 java.lang.String[] getProjects()
           
 hudson.tasks.BuildStepMonitor getRequiredMonitorService()
           
static TeamForgeShare.TeamForgeShareDescriptor getTeamForgeShareDescriptor()
           
 java.lang.String getUploadPath()
           
 java.lang.String getUsername()
           
 boolean includeBuildLog()
           
 void logoff()
          Log out of the collabnet server.
 boolean overrideAuth()
           
 boolean perform(hudson.model.AbstractBuild<?,?> build, hudson.Launcher launcher, hudson.model.BuildListener listener)
          The function does the work of uploading the build log.
 int uploadFiles(java.lang.String folderId, hudson.model.AbstractBuild<?,?> build)
          Upload files matching the file patterns to the Document Service.
 
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, 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, prebuild
 

Constructor Detail

CNDocumentUploader

public CNDocumentUploader(java.lang.String url,
                          java.lang.String username,
                          java.lang.String password,
                          java.lang.String project,
                          java.lang.String uploadPath,
                          java.lang.String description,
                          java.lang.String[] filePatterns,
                          boolean includeBuildLog,
                          boolean override_auth)
Creates a new CNDocumentUploader object.

Parameters:
url - for the CollabNet server, i.e. http://forge.collab.net
username - used to log into the CollabNet server.
password - for the logging-in user.
project - where the build log will be uploaded.
uploadPath - on the CollabNet server, where the build log should be uploaded.
description -
filePatterns -
includeBuildLog -
override_auth -
Method Detail

overrideAuth

public boolean overrideAuth()
Returns:
whether or not auth is overriden

getCollabNetUrl

public java.lang.String getCollabNetUrl()
Returns:
the url for the CollabNet server.

getUsername

public java.lang.String getUsername()
Returns:
the username used for logging in.

getPassword

public java.lang.String getPassword()
Returns:
the password used for logging in.

getProject

public java.lang.String getProject()
Returns:
the project where the build log is uploaded.

getUploadPath

public java.lang.String getUploadPath()
Returns:
the path where the build log is uploaded.

getDescription

public java.lang.String getDescription()
Returns:
the description of the uploaded files.

getFilePatterns

public java.lang.String[] getFilePatterns()
Returns:
the ant-style file patterns.

includeBuildLog

public boolean includeBuildLog()
Returns:
true if the build log should be uploaded.

getTeamForgeShareDescriptor

public static TeamForgeShare.TeamForgeShareDescriptor getTeamForgeShareDescriptor()
Returns:
the TeamForge share descriptor.

getProjects

public java.lang.String[] getProjects()
Returns:
the list of all possible projects, given the login data.

getRequiredMonitorService

public hudson.tasks.BuildStepMonitor getRequiredMonitorService()

perform

public boolean perform(hudson.model.AbstractBuild<?,?> build,
                       hudson.Launcher launcher,
                       hudson.model.BuildListener listener)
                throws java.io.IOException,
                       java.lang.InterruptedException
The function does the work of uploading the build log.

Specified by:
perform in interface hudson.tasks.BuildStep
Overrides:
perform in class hudson.tasks.BuildStepCompatibilityLayer
Parameters:
build - current Hudson 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:
java.io.IOException
java.lang.InterruptedException

uploadFiles

public int uploadFiles(java.lang.String folderId,
                       hudson.model.AbstractBuild<?,?> build)
                throws java.io.IOException,
                       java.lang.InterruptedException
Upload files matching the file patterns to the Document Service.

Parameters:
folderId - folder where the files should be uploaded.
build - the current Hudson build.
Returns:
the number of files successfully uploaded.
Throws:
java.io.IOException
java.lang.InterruptedException

getMimeType

public static java.lang.String getMimeType(hudson.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 java.lang.String getMimeType(java.io.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.


getProjectId

public java.lang.String getProjectId()
Get the project id for the project name.

Returns:
the matching project id, or null if none is found.


Copyright © 2010. All Rights Reserved.