Skip to content

Commit 480ae1a

Browse files
committed
[JENKINS-53840] Normalize workspace to Windows separators when it is going to be compared
1 parent 5c9ad57 commit 480ae1a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/ScriptRequestGenerator.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ScriptRequestGenerator implements Closeable {
5050
URL[] urlRoots = ([createWorkspaceUrl(filePath.parent)] + classpath) as URL[]
5151
ScriptRequest request = new ScriptRequest(
5252
readFile(filePath), urlRoots, ignoreExisting, getAbsolutePath(filePath),
53-
getAbsolutePath(workspace)
53+
FilenameUtils.normalize(getAbsolutePath(workspace))
5454
)
5555
scriptRequests.add(request)
5656
}
@@ -95,7 +95,9 @@ class ScriptRequestGenerator implements Closeable {
9595
}
9696

9797
private URL createWorkspaceUrl(FilePath filePath) {
98-
String relativePath = getAbsolutePath(filePath) - getAbsolutePath(workspace)
98+
// workspace and filePath may have differing separators in their common base
99+
String normalizedWorkspace = FilenameUtils.normalize(getAbsolutePath(workspace))
100+
String relativePath = getAbsolutePath(filePath) - normalizedWorkspace
99101
relativePath = relativePath.replaceAll('\\\\', '/') // normalize for Windows
100102
String slash = filePath.directory ? '/' : ''
101103
new URL(createWorkspaceUrl(), "$relativePath$slash")

0 commit comments

Comments
 (0)