hudson.plugins.collabnet.filerelease
Class CNFileRelease

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

public class CNFileRelease
extends hudson.tasks.Notifier
implements java.io.Serializable

Hudson plugin to update files from the Hudson workspace to the CollabNet File Release System.

See Also:
Serialized Form

Nested Class Summary
static class CNFileRelease.DescriptorImpl
          The CNFileRelease 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
CNFileRelease(java.lang.String url, java.lang.String username, java.lang.String password, java.lang.String project, java.lang.String rpackage, java.lang.String release, boolean overwrite, java.lang.String[] filePatterns, boolean override_auth)
          Creates a new CNFileRelease object.
 
Method Summary
 CnfrResultAction createAction(int numUploaded, java.lang.String releaseId)
          Get the ResultAction for this build.
 java.lang.String getCollabNetUrl()
           
 java.lang.String[] getFilePatterns()
           
static java.lang.String getMimeType(java.io.File f)
          Get the mimetype for the file.
 java.lang.String getPackage()
           
 java.lang.String getPackageId(java.lang.String projectId)
          Get the package id.
 java.lang.String[] getPackages()
           
 java.lang.String getPassword()
           
 java.lang.String getProject()
           
 java.lang.String getProjectId()
          Get the project id for the project name.
 java.lang.String[] getProjects()
           
 java.lang.String getRelease()
           
 java.lang.String getReleaseId()
          Get the releaseId from the project/package/release names.
 java.lang.String getReleaseId(java.lang.String packageId)
          Get the release id.
 java.lang.String[] getReleases()
           
 hudson.tasks.BuildStepMonitor getRequiredMonitorService()
           
static TeamForgeShare.TeamForgeShareDescriptor getTeamForgeShareDescriptor()
           
 java.lang.String getUsername()
           
 void logoff()
          Log out of the collabnet server.
 boolean overrideAuth()
           
 boolean overwrite()
           
 boolean perform(hudson.model.AbstractBuild<?,?> build, hudson.Launcher launcher, hudson.model.BuildListener listener)
          The function does the work of uploading files for the release.
 int uploadFiles(hudson.model.AbstractBuild<?,?> build, java.lang.String releaseId)
          Upload the files which match the file patterns to the given releaseId.
 
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

CNFileRelease

public CNFileRelease(java.lang.String url,
                     java.lang.String username,
                     java.lang.String password,
                     java.lang.String project,
                     java.lang.String rpackage,
                     java.lang.String release,
                     boolean overwrite,
                     java.lang.String[] filePatterns,
                     boolean override_auth)
Creates a new CNFileRelease 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 files will be uploaded. The project contains the package.
rpackage - where the files will be uploaded. The package contains the release.
release - where the files will be uploaded.
overwrite - whether or not to overwrite existing files.
filePatterns - Any files in the Hudson workspace that match these ant-style patterns will be uploaded to the CollabNet server.
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 files are uploaded.

getPackage

public java.lang.String getPackage()
Returns:
the package of the release where the files are uploaded.

getRelease

public java.lang.String getRelease()
Returns:
the release where the files are uploaded.

overwrite

public boolean overwrite()
Returns:
whether or not existing files should be overwritten.

getFilePatterns

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

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.

getPackages

public java.lang.String[] getPackages()
Returns:
the list of all possible packages, given the login data and the project.

getReleases

public java.lang.String[] getReleases()
Returns:
the list of all possible releases, given the login data, the project and the package.

getRequiredMonitorService

public hudson.tasks.BuildStepMonitor getRequiredMonitorService()
Specified by:
getRequiredMonitorService in interface hudson.tasks.BuildStep

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 files for the release.

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

createAction

public CnfrResultAction createAction(int numUploaded,
                                     java.lang.String releaseId)
Get the ResultAction for this build.

Parameters:
numUploaded -
Returns:
CnfrResultAction.

uploadFiles

public int uploadFiles(hudson.model.AbstractBuild<?,?> build,
                       java.lang.String releaseId)
                throws java.io.IOException,
                       java.lang.InterruptedException
Upload the files which match the file patterns to the given releaseId.

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

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.


getReleaseId

public java.lang.String getReleaseId()
Get the releaseId from the project/package/release names. Returns null if somewhere along the way one of these IDs cannot be found.

Returns:
the id for the release.

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.

getPackageId

public java.lang.String getPackageId(java.lang.String projectId)
Get the package id.

Parameters:
projectId - the id of the project which contains this package.
Returns:
the package id, or null if none is found.

getReleaseId

public java.lang.String getReleaseId(java.lang.String packageId)
Get the release id.

Parameters:
packageId - the id of the package which contains this release.
Returns:
the release id, or null if none is found.


Copyright © 2010. All Rights Reserved.