Class CNFileRelease
- java.lang.Object
-
- hudson.tasks.BuildStepCompatibilityLayer
-
- hudson.tasks.Publisher
-
- hudson.tasks.Notifier
-
- hudson.plugins.collabnet.AbstractTeamForgeNotifier
-
- hudson.plugins.collabnet.filerelease.CNFileRelease
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<Publisher>
,BuildStep
public class CNFileRelease extends AbstractTeamForgeNotifier
Jenkins plugin to update files from the Jenkins workspace to the CollabNet File Release System.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CNFileRelease.DescriptorImpl
The CNFileRelease 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 CNFileRelease(ConnectionFactory connectionFactory, String project, String pkg, String release, boolean overwrite, FilePattern[] filePatterns)
Creates a new CNFileRelease object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CnfrResultAction
createAction(int numUploaded, CTFRelease release)
Get the ResultAction for this build.FilePattern[]
getFilePatterns()
static String
getMimeType(FilePath f)
Get the mimetype for the file.String
getPkg()
CTFProject
getProjectObject()
Get the project id for the project name.String
getRelease()
CTFRelease
getReleaseObject(String expandedRelease)
Get the releaseId from the project/package/release names.BuildStepMonitor
getRequiredMonitorService()
boolean
isOverwrite()
void
logoff()
Log out of the collabnet server.boolean
perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener)
The function does the work of uploading files for the release.int
uploadFiles(AbstractBuild<?,?> build, CTFRelease release)
Upload the files which match the file patterns to the given releaseId.-
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
-
CNFileRelease
@DataBoundConstructor public CNFileRelease(ConnectionFactory connectionFactory, String project, String pkg, String release, boolean overwrite, FilePattern[] filePatterns)
Creates a new CNFileRelease object.- Parameters:
project
- where the files will be uploaded. The project contains the package.pkg
- 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 Jenkins workspace that match these ant-style patterns will be uploaded to the CollabNet server.
-
-
Method Detail
-
getPkg
public String getPkg()
- Returns:
- the package of the release where the files are uploaded.
-
getRelease
public String getRelease()
- Returns:
- the release where the files are uploaded.
-
isOverwrite
public boolean isOverwrite()
- Returns:
- whether or not existing files should be overwritten.
-
getFilePatterns
public FilePattern[] getFilePatterns()
- Returns:
- the ant-style file patterns.
-
getRequiredMonitorService
public BuildStepMonitor getRequiredMonitorService()
-
perform
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException
The function does the work of uploading files for the release.- 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
-
createAction
public CnfrResultAction createAction(int numUploaded, CTFRelease release)
Get the ResultAction for this build.- Parameters:
numUploaded
- count- Returns:
- CnfrResultAction.
-
uploadFiles
public int uploadFiles(AbstractBuild<?,?> build, CTFRelease release) throws IOException, InterruptedException
Upload the files which match the file patterns to the given releaseId.- Parameters:
build
- current Jenkins build.release
- where the files will be uploaded.- Returns:
- the number of files successfully uploaded.
- Throws:
IOException
- If any problem occurs when upload filesInterruptedException
- If interrupted when upload files
-
getMimeType
public static String getMimeType(FilePath 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.
-
getReleaseObject
public CTFRelease getReleaseObject(String expandedRelease) throws IOException
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.
- Throws:
IOException
-
getProjectObject
public CTFProject getProjectObject() throws IOException
Get the project id for the project name.- Returns:
- the matching project id, or null if none is found.
- Throws:
IOException
-
-