@@ -8,6 +8,8 @@ import javaposse.jobdsl.dsl.DslException
88import javaposse.jobdsl.dsl.ScriptRequest
99import org.junit.ClassRule
1010import org.jvnet.hudson.test.JenkinsRule
11+ import hudson.FilePath
12+ import spock.lang.Requires
1113import spock.lang.Shared
1214import spock.lang.Specification
1315import spock.lang.Unroll
@@ -402,4 +404,26 @@ class ScriptRequestGeneratorSpec extends Specification {
402404 then :
403405 requests. empty
404406 }
407+
408+ @Requires ({ os.isWindows() })
409+ def 'allow differing separators in base path of workspace and target (on Windows )' () {
410+ setup:
411+ EnvVars env = new EnvVars()
412+ // input a workspace that has forward slash separators where the target will get backward slashes
413+ String crookedRemote = build.workspace.remote.replace(' \\' , ' / ' )
414+ FilePath customWorkspace = new FilePath(new FilePath(new File(' ' )), crookedRemote)
415+ ScriptRequestGenerator generator = new ScriptRequestGenerator(customWorkspace, env)
416+
417+ when:
418+ List<ScriptRequest> requests = generator.getScriptRequests(' a. groovy' , false, null, false, null).toList()
419+
420+ then:
421+ requests.size() == 1
422+ requests[0].body == SCRIPT_A
423+ requests[0].urlRoots.length == 1
424+ requests[0].urlRoots[0].toString() == ' workspace :/ '
425+ !requests[0].ignoreExisting
426+ requests[0].scriptPath == getAbsolutePath(build.workspace.child(' a. groovy' ))
427+ requests[0].relativeScriptPath == ' a. groovy'
428+ }
405429}
0 commit comments