0

I tryed to write a groovy script with extened choice parameter:

import jcifs.smb.*

try {
def source = "smb://192.168.1.xx/build/"

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("mydc", "jenkins", "*****");
def dir = new SmbFile(source, auth)
// def dir = new SmbFile(source)

def files = dir.listFiles()
return ["xx"]
def list = []
for (SmbFile f : files)
{
  list << f.getName()
}

list << "xx"
return list
} catch (Exception e1) {
  return [e1.getMessage()]
}

but then I get the exception: Failed to connect: 0.0.0.0<00>/192.168.1.xx . I have open the server's smb1 support.

How can I list the smb folder or file with jenkins parameter choice?

halong
  • 70
  • 6

1 Answers1

0

I find the solution my self:

import groovy.io.FileType

try {
def source = "\\\\192.168.xx.xx\\xx\\xx"
def dir = new File(source)

def list = []
dir.eachFile(FileType.DIRECTORIES) {
  list << it.name
}
return list
} catch (Exception e1) {
  return [e1.getMessage()]
}

maybe I have saw the answer some place, but my java is so poor, I didn't understand. I tried many times to get the solution.

halong
  • 70
  • 6