hudson.plugins.clearcase
Class AbstractClearCaseScm

java.lang.Object
  extended by hudson.scm.SCM
      extended by hudson.plugins.clearcase.AbstractClearCaseScm
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Describable<hudson.scm.SCM>
Direct Known Subclasses:
ClearCaseSCM, ClearCaseUcmSCM

public abstract class AbstractClearCaseScm
extends hudson.scm.SCM

Abstract class for ClearCase SCM. The class contains the logic around checkout and polling, the deriving classes only have to implement the specific checkout and polling logic.


Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
static java.lang.String CLEARCASE_VIEWNAME_ENVSTR
           
static java.lang.String CLEARCASE_VIEWPATH_ENVSTR
           
static java.lang.String CLEARCASE_VIEWTAG_ENVSTR
           
 
Fields inherited from class hudson.scm.SCM
PERMISSIONS, TAG
 
Constructor Summary
AbstractClearCaseScm(java.lang.String viewName, java.lang.String mkviewOptionalParam, boolean filterOutDestroySubBranchEvent, boolean useUpdate, boolean rmviewonrename, java.lang.String excludedRegions, boolean useDynamicView, java.lang.String viewDrive, java.lang.String loadRules, java.lang.String multiSitePollBuffer, boolean createDynView, java.lang.String winDynStorageDir, java.lang.String unixDynStorageDir, boolean freezeCode, boolean recreateView, java.lang.String viewPath)
           
 
Method Summary
 void buildEnvVars(hudson.model.AbstractBuild<?,?> build, java.util.Map<java.lang.String,java.lang.String> env)
          Adds the env variable for the ClearCase SCMs.
abstract  hudson.scm.SCMRevisionState calcRevisionsFromPoll(hudson.model.AbstractBuild<?,?> build, hudson.Launcher launcher, hudson.model.TaskListener taskListener)
           
 boolean checkout(hudson.model.AbstractBuild build, hudson.Launcher launcher, hudson.FilePath workspace, hudson.model.BuildListener listener, java.io.File changelogFile)
           
protected  hudson.scm.PollingResult compareRemoteRevisionWith(hudson.model.AbstractProject<?,?> project, hudson.Launcher launcher, hudson.FilePath workspace, hudson.model.TaskListener listener, hudson.scm.SCMRevisionState baseline)
           
 Filter configureFilters(hudson.util.VariableResolver<java.lang.String> variableResolver, hudson.model.AbstractBuild build, hudson.Launcher launcher)
           
protected abstract  CheckOutAction createCheckOutAction(hudson.util.VariableResolver<java.lang.String> variableResolver, ClearToolLauncher launcher, hudson.model.AbstractBuild<?,?> build)
          Create a CheckOutAction that will be used by the checkout method.
protected  ClearTool createClearTool(hudson.util.VariableResolver<java.lang.String> variableResolver, ClearToolLauncher launcher)
           
 ClearToolLauncher createClearToolLauncher(hudson.model.TaskListener listener, hudson.FilePath workspace, hudson.Launcher launcher)
          Creates a Hudson clear tool launcher.
protected abstract  HistoryAction createHistoryAction(hudson.util.VariableResolver<java.lang.String> variableResolver, ClearToolLauncher launcher, hudson.model.AbstractBuild<?,?> build)
          Create a HistoryAction that will be used by the pollChanges() and checkout() method.
protected abstract  SaveChangeLogAction createSaveChangeLogAction(ClearToolLauncher launcher)
          Create a SaveChangeLog action that is used to save a change log
 java.lang.String generateNormalizedViewName(hudson.model.AbstractBuild<?,?> build)
           
 java.lang.String generateNormalizedViewName(hudson.util.VariableResolver<java.lang.String> variableResolver)
           
 java.lang.String generateNormalizedViewName(hudson.util.VariableResolver<java.lang.String> variableResolver, java.lang.String modViewName)
           Returns a normalized view name that will be used in cleartool commands.
 java.lang.String[] getBranchNames()
          Deprecated. use getBranchNames(VariableResolver) instead
abstract  java.lang.String[] getBranchNames(hudson.util.VariableResolver<java.lang.String> variableResolver)
          Return string array containing the branch names that should be used when polling for changes.
 hudson.model.Computer getBuildComputer(hudson.model.AbstractBuild<?,?> build)
          Returns the computer a given build ran on.
protected  java.util.Date getBuildTime(hudson.model.Run<?,?> lastBuild)
           
 hudson.model.Computer getCurrentComputer()
          Returns the current computer - used in constructor for BuildVariableResolver in place of direct call to Computer.currentComputer() so we can mock it in unit tests.
 java.lang.String getExcludedRegions()
           
 java.lang.String[] getExcludedRegionsNormalized()
           
 java.lang.String getLoadRules()
           
 java.lang.String getMkviewOptionalParam()
          Returns the user configured optional params that will be used in when creating a new view.
 hudson.FilePath getModuleRoot(hudson.FilePath workspace)
           
 hudson.FilePath getModuleRoot(hudson.FilePath workspace, hudson.model.AbstractBuild build)
           
 int getMultiSitePollBuffer()
           
 java.lang.String getNormalizedUnixDynStorageDir(hudson.util.VariableResolver<java.lang.String> variableResolver)
           
protected  java.lang.String getNormalizedViewName()
           
protected  java.lang.String getNormalizedViewPath()
           
 java.lang.String getNormalizedWinDynStorageDir(hudson.util.VariableResolver<java.lang.String> variableResolver)
           
 java.lang.String getUnixDynStorageDir()
           
 java.lang.String getViewDrive()
           
 java.lang.String getViewName()
           
 java.lang.String getViewName(hudson.util.VariableResolver<java.lang.String> variableResolver)
           
 java.lang.String getViewPath()
           
 java.lang.String getViewPath(hudson.util.VariableResolver<java.lang.String> variableResolver)
           
 java.lang.String[] getViewPaths(hudson.util.VariableResolver<java.lang.String> variableResolver, hudson.model.AbstractBuild build, hudson.Launcher launcher)
          Return string array containing the paths in the view that should be used when polling for changes.
static java.lang.String getViewPathsRegexp(java.lang.String[] loadRules, boolean isUnix)
           
 java.lang.String getWinDynStorageDir()
           
 boolean isCreateDynView()
           
 boolean isFilteringOutDestroySubBranchEvent()
           Returns if the "Destroyed branch" event should be filtered out or not.
For more information about the boolean, see the full discussion at Nabble.
protected abstract  boolean isFirstBuild(hudson.scm.SCMRevisionState baseline)
           
 boolean isFreezeCode()
           
 boolean isRecreateView()
           
 boolean isRemoveViewOnRename()
           
 boolean isUseDynamicView()
           
 boolean isUseUpdate()
           
 boolean processWorkspaceBeforeDeletion(hudson.model.AbstractProject<?,?> project, hudson.FilePath workspace, hudson.model.Node node)
           
 boolean requiresWorkspaceForPolling()
           
protected  void setNormalizedViewName(java.lang.String normalizedViewName)
           
protected  void setNormalizedViewPath(java.lang.String normalizedViewPath)
           
 boolean supportsPolling()
           
 
Methods inherited from class hudson.scm.SCM
_calcRevisionsFromBuild, _for, all, calcRevisionsFromBuild, createChangeLogParser, createEmptyChangeLog, getApi, getBrowser, getDescriptor, getEffectiveBrowser, getModuleRoots, getType, nullify, poll, pollChanges
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLEARCASE_VIEWTAG_ENVSTR

public static final java.lang.String CLEARCASE_VIEWTAG_ENVSTR
See Also:
Constant Field Values

CLEARCASE_VIEWNAME_ENVSTR

public static final java.lang.String CLEARCASE_VIEWNAME_ENVSTR
See Also:
Constant Field Values

CLEARCASE_VIEWPATH_ENVSTR

public static final java.lang.String CLEARCASE_VIEWPATH_ENVSTR
See Also:
Constant Field Values
Constructor Detail

AbstractClearCaseScm

public AbstractClearCaseScm(java.lang.String viewName,
                            java.lang.String mkviewOptionalParam,
                            boolean filterOutDestroySubBranchEvent,
                            boolean useUpdate,
                            boolean rmviewonrename,
                            java.lang.String excludedRegions,
                            boolean useDynamicView,
                            java.lang.String viewDrive,
                            java.lang.String loadRules,
                            java.lang.String multiSitePollBuffer,
                            boolean createDynView,
                            java.lang.String winDynStorageDir,
                            java.lang.String unixDynStorageDir,
                            boolean freezeCode,
                            boolean recreateView,
                            java.lang.String viewPath)
Method Detail

setNormalizedViewName

protected void setNormalizedViewName(java.lang.String normalizedViewName)

getNormalizedViewName

protected java.lang.String getNormalizedViewName()

setNormalizedViewPath

protected void setNormalizedViewPath(java.lang.String normalizedViewPath)

getNormalizedViewPath

protected java.lang.String getNormalizedViewPath()

createCheckOutAction

protected abstract CheckOutAction createCheckOutAction(hudson.util.VariableResolver<java.lang.String> variableResolver,
                                                       ClearToolLauncher launcher,
                                                       hudson.model.AbstractBuild<?,?> build)
                                                throws java.io.IOException,
                                                       java.lang.InterruptedException
Create a CheckOutAction that will be used by the checkout method.

Parameters:
launcher - the command line launcher
Returns:
an action that can check out code from a ClearCase repository.
Throws:
java.lang.InterruptedException
java.io.IOException

createHistoryAction

protected abstract HistoryAction createHistoryAction(hudson.util.VariableResolver<java.lang.String> variableResolver,
                                                     ClearToolLauncher launcher,
                                                     hudson.model.AbstractBuild<?,?> build)
                                              throws java.io.IOException,
                                                     java.lang.InterruptedException
Create a HistoryAction that will be used by the pollChanges() and checkout() method.

Parameters:
variableResolver -
useDynamicView -
launcher - the command line launcher
Returns:
an action that can poll if there are any changes a ClearCase repository.
Throws:
java.lang.InterruptedException
java.io.IOException

createSaveChangeLogAction

protected abstract SaveChangeLogAction createSaveChangeLogAction(ClearToolLauncher launcher)
Create a SaveChangeLog action that is used to save a change log

Parameters:
launcher - the command line launcher
Returns:
an action that can save a change log to the Hudson changlog file

getBranchNames

@Deprecated
public java.lang.String[] getBranchNames()
Deprecated. use getBranchNames(VariableResolver) instead

Return string array containing the branch names that should be used when polling for changes.

Returns:
a string array, can not be empty

getBranchNames

public abstract java.lang.String[] getBranchNames(hudson.util.VariableResolver<java.lang.String> variableResolver)
Return string array containing the branch names that should be used when polling for changes.

Returns:
a string array, can not be empty

getViewPaths

public java.lang.String[] getViewPaths(hudson.util.VariableResolver<java.lang.String> variableResolver,
                                       hudson.model.AbstractBuild build,
                                       hudson.Launcher launcher)
                                throws java.io.IOException,
                                       java.lang.InterruptedException
Return string array containing the paths in the view that should be used when polling for changes.

Parameters:
variableResolver - TODO
build - TODO
launcher - TODO
Returns:
string array that will be used by the lshistory command and for constructing the config spec, etc.
Throws:
java.lang.InterruptedException
java.io.IOException

isUseDynamicView

public boolean isUseDynamicView()

getMultiSitePollBuffer

public int getMultiSitePollBuffer()

getViewDrive

public java.lang.String getViewDrive()

getLoadRules

public java.lang.String getLoadRules()

isCreateDynView

public boolean isCreateDynView()

supportsPolling

public boolean supportsPolling()
Overrides:
supportsPolling in class hudson.scm.SCM

requiresWorkspaceForPolling

public boolean requiresWorkspaceForPolling()
Overrides:
requiresWorkspaceForPolling in class hudson.scm.SCM

getModuleRoot

public hudson.FilePath getModuleRoot(hudson.FilePath workspace)
Overrides:
getModuleRoot in class hudson.scm.SCM

getModuleRoot

public hudson.FilePath getModuleRoot(hudson.FilePath workspace,
                                     hudson.model.AbstractBuild build)

getViewName

public java.lang.String getViewName()

getViewName

public java.lang.String getViewName(hudson.util.VariableResolver<java.lang.String> variableResolver)

getWinDynStorageDir

public java.lang.String getWinDynStorageDir()

getNormalizedWinDynStorageDir

public java.lang.String getNormalizedWinDynStorageDir(hudson.util.VariableResolver<java.lang.String> variableResolver)

getUnixDynStorageDir

public java.lang.String getUnixDynStorageDir()

getNormalizedUnixDynStorageDir

public java.lang.String getNormalizedUnixDynStorageDir(hudson.util.VariableResolver<java.lang.String> variableResolver)

isFreezeCode

public boolean isFreezeCode()

isRecreateView

public boolean isRecreateView()

getCurrentComputer

public hudson.model.Computer getCurrentComputer()
Returns the current computer - used in constructor for BuildVariableResolver in place of direct call to Computer.currentComputer() so we can mock it in unit tests.


getBuildComputer

public hudson.model.Computer getBuildComputer(hudson.model.AbstractBuild<?,?> build)
Returns the computer a given build ran on. We wrap this here for mocking purposes.


generateNormalizedViewName

public java.lang.String generateNormalizedViewName(hudson.model.AbstractBuild<?,?> build)
Parameters:
build - the project to get the name from
Returns:
a string containing no invalid chars.
See Also:
AbstractClearCaseScm#generateNormalizedViewName(BuildVariableResolver, String)

generateNormalizedViewName

public java.lang.String generateNormalizedViewName(hudson.util.VariableResolver<java.lang.String> variableResolver,
                                                   java.lang.String modViewName)

Returns a normalized view name that will be used in cleartool commands.

It will replace : This way it will be easier to add new jobs without trying to find an unique view name. It will also replace invalid chars from a view name.

Parameters:
build - the project to get the name from
Returns:
a string containing no invalid chars.

generateNormalizedViewName

public java.lang.String generateNormalizedViewName(hudson.util.VariableResolver<java.lang.String> variableResolver)
Parameters:
variableResolver - An initialized build variable resolver.
Returns:
a string containing no invalid chars.
See Also:
AbstractClearCaseScm#generateNormalizedViewName(BuildVariableResolver, String)

getMkviewOptionalParam

public java.lang.String getMkviewOptionalParam()
Returns the user configured optional params that will be used in when creating a new view.

Returns:
string containing optional mkview parameters.

isFilteringOutDestroySubBranchEvent

public boolean isFilteringOutDestroySubBranchEvent()

Returns if the "Destroyed branch" event should be filtered out or not.
For more information about the boolean, see the full discussion at Nabble.

"Usually, CC admins have a CC trigger, fires on an uncheckout event, that destroys empty branches."

Returns:
true if the "Destroyed branch" event should be filtered out or not; false otherwise

buildEnvVars

public void buildEnvVars(hudson.model.AbstractBuild<?,?> build,
                         java.util.Map<java.lang.String,java.lang.String> env)
Adds the env variable for the ClearCase SCMs.

Overrides:
buildEnvVars in class hudson.scm.SCM

checkout

public boolean checkout(hudson.model.AbstractBuild build,
                        hudson.Launcher launcher,
                        hudson.FilePath workspace,
                        hudson.model.BuildListener listener,
                        java.io.File changelogFile)
                 throws java.io.IOException,
                        java.lang.InterruptedException
Specified by:
checkout in class hudson.scm.SCM
Throws:
java.io.IOException
java.lang.InterruptedException

compareRemoteRevisionWith

protected hudson.scm.PollingResult compareRemoteRevisionWith(hudson.model.AbstractProject<?,?> project,
                                                             hudson.Launcher launcher,
                                                             hudson.FilePath workspace,
                                                             hudson.model.TaskListener listener,
                                                             hudson.scm.SCMRevisionState baseline)
                                                      throws java.io.IOException,
                                                             java.lang.InterruptedException
Specified by:
compareRemoteRevisionWith in class hudson.scm.SCM
Throws:
java.io.IOException
java.lang.InterruptedException

isFirstBuild

protected abstract boolean isFirstBuild(hudson.scm.SCMRevisionState baseline)

calcRevisionsFromPoll

public abstract hudson.scm.SCMRevisionState calcRevisionsFromPoll(hudson.model.AbstractBuild<?,?> build,
                                                                  hudson.Launcher launcher,
                                                                  hudson.model.TaskListener taskListener)
                                                           throws java.io.IOException,
                                                                  java.lang.InterruptedException
Throws:
java.io.IOException
java.lang.InterruptedException

getBuildTime

protected java.util.Date getBuildTime(hudson.model.Run<?,?> lastBuild)

createClearToolLauncher

public ClearToolLauncher createClearToolLauncher(hudson.model.TaskListener listener,
                                                 hudson.FilePath workspace,
                                                 hudson.Launcher launcher)
Creates a Hudson clear tool launcher.

Parameters:
listener - listener to write command output to
workspace - the workspace for the job
launcher - actual launcher to launch commands with
Returns:
a clear tool launcher that uses Hudson for launching commands

createClearTool

protected ClearTool createClearTool(hudson.util.VariableResolver<java.lang.String> variableResolver,
                                    ClearToolLauncher launcher)

processWorkspaceBeforeDeletion

public boolean processWorkspaceBeforeDeletion(hudson.model.AbstractProject<?,?> project,
                                              hudson.FilePath workspace,
                                              hudson.model.Node node)
                                       throws java.io.IOException,
                                              java.lang.InterruptedException
Overrides:
processWorkspaceBeforeDeletion in class hudson.scm.SCM
Throws:
java.io.IOException
java.lang.InterruptedException

isUseUpdate

public boolean isUseUpdate()

isRemoveViewOnRename

public boolean isRemoveViewOnRename()

getExcludedRegions

public java.lang.String getExcludedRegions()

getExcludedRegionsNormalized

public java.lang.String[] getExcludedRegionsNormalized()

configureFilters

public Filter configureFilters(hudson.util.VariableResolver<java.lang.String> variableResolver,
                               hudson.model.AbstractBuild build,
                               hudson.Launcher launcher)
                        throws java.io.IOException,
                               java.lang.InterruptedException
Throws:
java.io.IOException
java.lang.InterruptedException

getViewPathsRegexp

public static java.lang.String getViewPathsRegexp(java.lang.String[] loadRules,
                                                  boolean isUnix)

getViewPath

public java.lang.String getViewPath()

getViewPath

public java.lang.String getViewPath(hudson.util.VariableResolver<java.lang.String> variableResolver)


Copyright © 2011. All Rights Reserved.