April 24, 2013

Jenkins Multijob Plugin - Missing Slashes while traversing down

This article talks about the Missing Slashes (\\) while traversing from high-level to low-level jobs in a Jenkins Multijob project.

Lets assume a scenario where we have two free style jobs (low-level) jobA and jobB, which copies a set of files from Source to Destination path. And a Parent job (Multijob) parentA which calls jobA and jobB with Source and Destination path as parameter.

While passing Source and Destination dir from parentA to jobA and jobB, two slashes gets stripped off due to the Jenkins regular expression behaviour.

Input Entered for parentA:
Source: \\\\serverone\\\\pathone
Destination: d:\\\\temp\\\\testdir

As Received in jobA and jobB:
Source: \\serverone\\pathone
Destination: d:\\temp\\testdir

Here is the pictorial representation of our discussion..

For every higher level you add before parentA, multiply the number of slashes in that particular level by 2.
grantparentA -> parentA -> jobA   =>   8 -> 4 -> 2

You might wonder that we may have to add 8 slashes for the UNC Path (Source: \\\\serverone\\\\pathone) but your jenkins does not work if you do so. To explain further about UNC Path => When we supply 4 slashes to the parent job, child job will get value  \\serverone\pathone  not \\serverone\\pathone (which Jenkins expects).
Hence we are using 4 slashes from parent jobs instead of 8.

No comments:

Post a Comment