From 9df685c2baa04218339e8fa08363b7a91514e848 Mon Sep 17 00:00:00 2001 From: kkuehne Date: Tue, 1 Apr 2014 10:47:32 +0200 Subject: [PATCH 1/6] moduleRoot now handles the load rules path to return the root of the checkout --- .../clearcase/AbstractClearCaseScm.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java b/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java index e6167cb8..db1db018 100644 --- a/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java +++ b/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java @@ -180,7 +180,7 @@ private static final class IsUnix implements Callable { IsUnix() { } - @Override + public Boolean call() throws IOException { return File.pathSeparatorChar == ':'; } @@ -224,6 +224,7 @@ public Boolean call() throws IOException { private String viewDrive; private String viewName; private String viewPath; + private String[] loadRules; private ViewStorage viewStorage; @Deprecated private transient ViewStorageFactory viewStorageFactory; @@ -408,6 +409,7 @@ public Filter configureFilters(VariableResolver variableResolver, Abstra String filterRegexp = ""; String[] viewPaths = getViewPaths(variableResolver, build, launcher, false); + loadRules = viewPaths; if (viewPaths != null) { filterRegexp = getViewPathsRegexp(viewPaths, launcher.isUnix()); } @@ -562,13 +564,16 @@ public FilePath getModuleRoot(FilePath workspace) { @Override public FilePath getModuleRoot(FilePath workspace, AbstractBuild build) { + return getModuleRoot(workspace, build, loadRules); + } + public FilePath getModuleRoot(FilePath workspace, AbstractBuild build, String[] loadRules) { if (useDynamicView) { String normViewName = getNormalizedViewName(); - return new FilePath(workspace.getChannel(), viewDrive).child(normViewName); + return new FilePath(workspace.getChannel(), viewDrive).child(normViewName).child(loadRules[0]); } String normViewPath = getNormalizedViewPath(); if (normViewPath != null) { - return workspace.child(normViewPath); + return workspace.child(normViewPath).child(loadRules[0]); } if (build == null) { normViewPath = getViewPath(); @@ -576,12 +581,12 @@ public FilePath getModuleRoot(FilePath workspace, AbstractBuild build) { normViewPath = getViewPath(new BuildVariableResolver(build)); } if (normViewPath != null) { - return workspace.child(normViewPath); + return workspace.child(normViewPath).child(loadRules[0]); } // Should never happen, because viewName must not be null, and if viewpath is null, then it is made equal to viewName throw new IllegalStateException("View path name cannot be null. There is a bug inside AbstractClearCaseScm."); } - + public int getMultiSitePollBuffer() { return multiSitePollBuffer; @@ -618,8 +623,7 @@ public String getViewPath(VariableResolver variableResolver) { } return normalized; } - - /** + /** * Return string array containing the paths in the view that should be used when polling for changes. * * @param variableResolver From 10d537cf3296fa67136b80d38e2ed85c65df2747 Mon Sep 17 00:00:00 2001 From: kkuehne Date: Tue, 1 Apr 2014 15:39:08 +0200 Subject: [PATCH 2/6] intoduced loadRulesForModuleRoot to expand the moduleRoot path --- .../plugins/clearcase/AbstractClearCaseScm.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java b/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java index db1db018..f9125d88 100644 --- a/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java +++ b/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java @@ -203,6 +203,7 @@ public Boolean call() throws IOException { private boolean filteringOutDestroySubBranchEvent; private boolean freezeCode; private String loadRules; + private String[] loadRulesForModuleRoot; private String loadRulesForPolling; private String mkviewOptionalParam; private int multiSitePollBuffer; @@ -224,7 +225,6 @@ public Boolean call() throws IOException { private String viewDrive; private String viewName; private String viewPath; - private String[] loadRules; private ViewStorage viewStorage; @Deprecated private transient ViewStorageFactory viewStorageFactory; @@ -301,7 +301,7 @@ public void buildEnvVars(AbstractBuild build, Map env) { } else { String workspace = env.get("WORKSPACE"); if (workspace != null) { - env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath); + env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath + PathUtil.fileSepForOS(isUnix) + loadRulesForModuleRoot[0]); } } } @@ -409,7 +409,7 @@ public Filter configureFilters(VariableResolver variableResolver, Abstra String filterRegexp = ""; String[] viewPaths = getViewPaths(variableResolver, build, launcher, false); - loadRules = viewPaths; + loadRulesForModuleRoot = viewPaths; if (viewPaths != null) { filterRegexp = getViewPathsRegexp(viewPaths, launcher.isUnix()); } @@ -564,16 +564,16 @@ public FilePath getModuleRoot(FilePath workspace) { @Override public FilePath getModuleRoot(FilePath workspace, AbstractBuild build) { - return getModuleRoot(workspace, build, loadRules); + return getModuleRoot(workspace, build, loadRulesForModuleRoot); } - public FilePath getModuleRoot(FilePath workspace, AbstractBuild build, String[] loadRules) { + public FilePath getModuleRoot(FilePath workspace, AbstractBuild build, String[] loadRulesForModuleRoot) { if (useDynamicView) { String normViewName = getNormalizedViewName(); - return new FilePath(workspace.getChannel(), viewDrive).child(normViewName).child(loadRules[0]); + return new FilePath(workspace.getChannel(), viewDrive).child(normViewName).child(loadRulesForModuleRoot[0]); } String normViewPath = getNormalizedViewPath(); if (normViewPath != null) { - return workspace.child(normViewPath).child(loadRules[0]); + return workspace.child(normViewPath).child(loadRulesForModuleRoot[0]); } if (build == null) { normViewPath = getViewPath(); @@ -581,7 +581,7 @@ public FilePath getModuleRoot(FilePath workspace, AbstractBuild build, String[] normViewPath = getViewPath(new BuildVariableResolver(build)); } if (normViewPath != null) { - return workspace.child(normViewPath).child(loadRules[0]); + return workspace.child(normViewPath).child(loadRulesForModuleRoot[0]); } // Should never happen, because viewName must not be null, and if viewpath is null, then it is made equal to viewName throw new IllegalStateException("View path name cannot be null. There is a bug inside AbstractClearCaseScm."); From 804b33ed1e5bb4edf9b418039b6979166f46a7e7 Mon Sep 17 00:00:00 2001 From: kkuehne Date: Wed, 2 Apr 2014 09:52:50 +0200 Subject: [PATCH 3/6] fixed Unit Tests and CRLF/LF --- .../clearcase/AbstractClearCaseScm.java | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java b/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java index f9125d88..575b1400 100644 --- a/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java +++ b/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java @@ -203,7 +203,7 @@ public Boolean call() throws IOException { private boolean filteringOutDestroySubBranchEvent; private boolean freezeCode; private String loadRules; - private String[] loadRulesForModuleRoot; + private String[] loadRulesForModuleRoot={""}; private String loadRulesForPolling; private String mkviewOptionalParam; private int multiSitePollBuffer; @@ -285,7 +285,7 @@ public AbstractClearCaseScm(final String viewName, final String mkviewOptionalPa */ @Override public void buildEnvVars(AbstractBuild build, Map env) { - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") VariableResolver.Union variableResolver = new VariableResolver.Union(new BuildVariableResolver(build, true), new VariableResolver.ByMap(env)); String normalizedViewName = getViewName(variableResolver); @@ -301,7 +301,9 @@ public void buildEnvVars(AbstractBuild build, Map env) { } else { String workspace = env.get("WORKSPACE"); if (workspace != null) { - env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath + PathUtil.fileSepForOS(isUnix) + loadRulesForModuleRoot[0]); + env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath); + +// env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath + PathUtil.fileSepForOS(isUnix) + loadRulesForModuleRoot[0]); } } } @@ -556,24 +558,37 @@ public String getLoadRulesForPolling() { public String getMkviewOptionalParam() { return mkviewOptionalParam; } - + @Override public FilePath getModuleRoot(FilePath workspace) { - return getModuleRoot(workspace, null); + return getModuleRoot(workspace, null); } @Override public FilePath getModuleRoot(FilePath workspace, AbstractBuild build) { - return getModuleRoot(workspace, build, loadRulesForModuleRoot); + if (loadRulesForModuleRoot.length == 0) { + return getModuleRoot(workspace, build, null); + } else { + return getModuleRoot(workspace, build, loadRulesForModuleRoot); + } } public FilePath getModuleRoot(FilePath workspace, AbstractBuild build, String[] loadRulesForModuleRoot) { if (useDynamicView) { - String normViewName = getNormalizedViewName(); - return new FilePath(workspace.getChannel(), viewDrive).child(normViewName).child(loadRulesForModuleRoot[0]); + String normViewName = getNormalizedViewName(); + if (loadRulesForModuleRoot == null){ + return new FilePath(workspace.getChannel(), viewDrive).child(normViewName); + } + else { + return new FilePath(workspace.getChannel(), viewDrive).child(normViewName).child(loadRulesForModuleRoot[0]); + } } String normViewPath = getNormalizedViewPath(); if (normViewPath != null) { - return workspace.child(normViewPath).child(loadRulesForModuleRoot[0]); + if (loadRulesForModuleRoot == null){ + return workspace.child(normViewPath); + } else { + return workspace.child(normViewPath).child(loadRulesForModuleRoot[0]); + } } if (build == null) { normViewPath = getViewPath(); @@ -581,7 +596,11 @@ public FilePath getModuleRoot(FilePath workspace, AbstractBuild build, String[] normViewPath = getViewPath(new BuildVariableResolver(build)); } if (normViewPath != null) { - return workspace.child(normViewPath).child(loadRulesForModuleRoot[0]); + if (loadRulesForModuleRoot == null){ + return workspace.child(normViewPath); + } else { + return workspace.child(normViewPath).child(loadRulesForModuleRoot[0]); + } } // Should never happen, because viewName must not be null, and if viewpath is null, then it is made equal to viewName throw new IllegalStateException("View path name cannot be null. There is a bug inside AbstractClearCaseScm."); From 2b09c7bb58c1ddedad7b5c8e07b751ba65db5f79 Mon Sep 17 00:00:00 2001 From: kkuehne Date: Wed, 2 Apr 2014 11:16:12 +0200 Subject: [PATCH 4/6] CLEARCASE_VIEWPATH env variable now also include the load rules in the path --- .../hudson/plugins/clearcase/AbstractClearCaseScm.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java b/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java index 575b1400..2614ccab 100644 --- a/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java +++ b/src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java @@ -203,7 +203,7 @@ public Boolean call() throws IOException { private boolean filteringOutDestroySubBranchEvent; private boolean freezeCode; private String loadRules; - private String[] loadRulesForModuleRoot={""}; + private String[] loadRulesForModuleRoot = {}; private String loadRulesForPolling; private String mkviewOptionalParam; private int multiSitePollBuffer; @@ -301,9 +301,11 @@ public void buildEnvVars(AbstractBuild build, Map env) { } else { String workspace = env.get("WORKSPACE"); if (workspace != null) { - env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath); - -// env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath + PathUtil.fileSepForOS(isUnix) + loadRulesForModuleRoot[0]); + if ( loadRulesForModuleRoot.length == 0 ) { + env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath); + } else { + env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath + PathUtil.fileSepForOS(isUnix) + loadRulesForModuleRoot[0]); + } } } } From 11f06b83b14039ea63e051b77826cb6ea70b8abb Mon Sep 17 00:00:00 2001 From: kkuehne Date: Thu, 3 Apr 2014 15:53:19 +0200 Subject: [PATCH 5/6] [JENKINS-18364] Described the new behaviour in loadrules.html --- src/main/webapp/loadrules.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/webapp/loadrules.html b/src/main/webapp/loadrules.html index 3564d07b..b0c16c40 100644 --- a/src/main/webapp/loadrules.html +++ b/src/main/webapp/loadrules.html @@ -30,6 +30,10 @@ directories and files to load from the VOB. Multiple load rules can be specified on multiple lines.

+

+ The load rule specified in the first line determines the path to the checked-out root directory. + This is usually where pom.xml, build.xml and so on exists. +

An individual load rule can specify a file or a directory. A load rule that specifies a directory loads the directory and all its contents (files and subdirectories). A load rule that From 87c2980dd882870c724d13080494eddd98a92c70 Mon Sep 17 00:00:00 2001 From: kkuehne Date: Thu, 3 Apr 2014 16:59:00 +0200 Subject: [PATCH 6/6] [JENKINS-18364] enhanced the help text in loadrules.html --- src/main/webapp/loadrules.html | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/loadrules.html b/src/main/webapp/loadrules.html index b0c16c40..7f70c270 100644 --- a/src/main/webapp/loadrules.html +++ b/src/main/webapp/loadrules.html @@ -30,16 +30,13 @@ directories and files to load from the VOB. Multiple load rules can be specified on multiple lines.

-

- The load rule specified in the first line determines the path to the checked-out root directory. - This is usually where pom.xml, build.xml and so on exists. -

An individual load rule can specify a file or a directory. A load rule that specifies a directory loads the directory and all its contents (files and subdirectories). A load rule that specifies a file loads only the specified file. To load all resources in a VOB or a component, - create a load rule that specifies the root directory of the - VOB or component. + create a load rule that specifies the root directory of the VOB or component. + The load rule placed in the first line is to determine this checked-out root directory + (usually where pom.xml, build.xml and so on exists).

For dynamic views, the load rules will be used to determine the