Skip to content
49 changes: 37 additions & 12 deletions src/main/java/hudson/plugins/clearcase/AbstractClearCaseScm.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private static final class IsUnix implements Callable<Boolean, IOException> {
IsUnix() {
}

@Override

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid these kind of changes, they clutter the diff

public Boolean call() throws IOException {
return File.pathSeparatorChar == ':';
}
Expand All @@ -203,6 +203,7 @@ public Boolean call() throws IOException {
private boolean filteringOutDestroySubBranchEvent;
private boolean freezeCode;
private String loadRules;
private String[] loadRulesForModuleRoot = {};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a build-scoped information, it shouldn't be persisted in the Scm object.

private String loadRulesForPolling;
private String mkviewOptionalParam;
private int multiSitePollBuffer;
Expand Down Expand Up @@ -284,7 +285,7 @@ public AbstractClearCaseScm(final String viewName, final String mkviewOptionalPa
*/
@Override
public void buildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) {
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked")
VariableResolver.Union<String> variableResolver = new VariableResolver.Union<String>(new BuildVariableResolver(build, true),
new VariableResolver.ByMap<String>(env));
String normalizedViewName = getViewName(variableResolver);
Expand All @@ -300,7 +301,11 @@ public void buildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) {
} else {
String workspace = env.get("WORKSPACE");
if (workspace != null) {
env.put(CLEARCASE_VIEWPATH_ENVSTR, workspace + PathUtil.fileSepForOS(isUnix) + normalizedViewPath);
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]);
}
}
}
}
Expand Down Expand Up @@ -408,6 +413,7 @@ public Filter configureFilters(VariableResolver<String> variableResolver, Abstra

String filterRegexp = "";
String[] viewPaths = getViewPaths(variableResolver, build, launcher, false);
loadRulesForModuleRoot = viewPaths;
if (viewPaths != null) {
filterRegexp = getViewPathsRegexp(viewPaths, launcher.isUnix());
}
Expand Down Expand Up @@ -554,34 +560,54 @@ 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) {
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);
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);
if (loadRulesForModuleRoot == null){
return workspace.child(normViewPath);
} else {
return workspace.child(normViewPath).child(loadRulesForModuleRoot[0]);
}
}
if (build == null) {
normViewPath = getViewPath();
} else {
normViewPath = getViewPath(new BuildVariableResolver(build));
}
if (normViewPath != null) {
return workspace.child(normViewPath);
if (loadRulesForModuleRoot == null){
return workspace.child(normViewPath);
} else {
return workspace.child(normViewPath).child(loadRulesForModuleRoot[0]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a major breaking change. All existing jobs that define the relative path in the view to reach the pom.xml for instance will have to be updated.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iam suggesting having a checkbox in the job configuration which explicitly needs to be checked to have the load rule in the path of the module root . This way all the current job configuration will not be affected unless people want to have it.

}
}
// 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;
Expand Down Expand Up @@ -618,8 +644,7 @@ public String getViewPath(VariableResolver<String> variableResolver) {
}
return normalized;
}

/**
/**
* Return string array containing the paths in the view that should be used when polling for changes.
*
* @param variableResolver
Expand Down
5 changes: 3 additions & 2 deletions src/main/webapp/loadrules.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
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 <b>first line</b> is to determine this checked-out root directory
(usually where pom.xml, build.xml and so on exists).
</p>
<p>
For dynamic views, the load rules will be used to determine the
Expand Down