1

I love groovy. It is very powerful script, and we use it everywhere. Recently on Jenkins server where we are trying to get some files that resides on the virtual drive, created by subst command. The problem is that it seems that groovy does not supports virtual drives, but I did not find any confirmation on this. Is this true, is there any workaround for this?

Here is the sample code we use:

import groovy.io.FileType

def list = []
//the original file path for T: is C:\Users\MyUser\workspace\MyProject\src\test\data
def dir = new File("T:" + "\\")
dir.eachFile (FileType.FILES) { file ->
  list << file
}

list.each{
  println "${it}"
}

The results we got is:

[EnvInject] - Evaluating the Groovy script content [EnvInject] - [ERROR] - Problems occurs on injecting env vars defined in the build wrapper: org.jenkinsci.lib.envinject.EnvInjectException: Failed to evaluate the script. java.io.FileNotFoundException: T:. See system log for more info

Any help is appreciated.

Gico
  • 1,086
  • 1
  • 11
  • 28
  • 1
    I struggled with something like this in the past, apparently "virtual drive mappings" are not necessarily visible to all users. How did you set that virtual drive up, and with what users and permissions is Jenkins running? (if you specify that, maybe it will prompt the right experts to come forward with insights) – Hugues M. May 10 '17 at 06:57
  • Hi Hugues Moreau 9. Thanx for feedback. It is interesting hint. I am running Jenkins with the my own user. What is interesting, I tried now the same script under SoapUI and it worked. That mean's the Groovy can handle the virtual drives, but it can not handle them under Jenkins. I will try to investigate more this part. – Gico May 10 '17 at 07:10
  • Does Jenkins run as a service? That also matters apparently – Hugues M. May 10 '17 at 07:13
  • Yes. Jenkins is running as a service with my account windows credentials. – Gico May 10 '17 at 07:25
  • 1
    So maybe the appropriate question is [this](http://stackoverflow.com/q/182750/6730571). In any case it's not a Groovy issue. – Hugues M. May 10 '17 at 07:39
  • You are right Hugues this is exactly what I was looking for! We should mark my question as a duplicate. – Gico May 10 '17 at 07:50
  • I upvoted your answer because it offers a proper solution for a specific manifestation of the more general problem I linked. Your specific issue might be common (so I won't flag it as duplicate myself) – Hugues M. May 10 '17 at 07:53

1 Answers1

2

I found the answer by myself, but @Hugues Moreau 9 input was the one that lead me to the answer.

It was a permission issue. Jenkins is running under my default account, but the problem was caused by the Apache (httpd.exe). httpd.exe was running as a system account and it did not had an access to T:. What I did is I download the PSEXEC.EXE from https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx and by this tool I opened a command line as SYSTEM user:

PSEXEC -i -s -d CMD

After that I create a subst directory T: for SYSTEM user. Now the Jenkins and the Apache have access to virtual drive.

As Hugues point out more precise description and question is here: https://stackoverflow.com/questions/182750/map-a-network-drive-to-be-used-by-a-service

Community
  • 1
  • 1
Gico
  • 1,086
  • 1
  • 11
  • 28