-
Bug
-
Resolution: Not A Defect
-
Minor
-
None
-
jenkins - 2.77
Active choice plugin - 2.1
OS - RhEl 6.8
Webbrowser - Chrome
Java - 1.8
Hi
I am trying to extract list of version from perforce and return the list , so that developers can select the version from the output listed as radio button/something
But the return doesnt seem to work , neither does it throw any error
I have added a print statement and it works fine
Printed below ["1610" , "1702" , "1703" , "1710" , "1804" , "1806"]
Code
___________________________________________________
import com.perforce.p4java.server.*
import com.perforce.p4java.impl.generic.core.file.*
import groovyx.net.http.RESTClient
import com.perforce.p4java.core.file.FileSpecBuilder
import com.perforce.p4java.core.file.FileSpecOpStatus
import com.perforce.p4java.core.file.IFileSpec
import com.perforce.p4java.option.server.GetFileContentsOptions
@Grapes([
@Grab(group='com.perforce', module='p4java', version='2013.1.656196' ),
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )])
//import com.perforce.p4java.server.*
//import com.perforce.p4java.impl.generic.core.file.*
//import groovyx.net.http.RESTClient
def server = ServerFactory.getServer( "p4java://XXXX:1666", null)
server.setUserName("username")
server.connect()
server.login("password")
final List<IFileSpec> checkFile = FileSpecBuilder.makeFileSpecList("//depot/Stream_name/Swarm/Stream_Swarm.lst")
final GetFileContentsOptions gfco = new GetFileContentsOptions()
gfco.setNoHeaderLine(true)
gfco.setDontAnnotateFiles(false) // must set this!
InputStream inStream = server.getFileContents(checkFile, gfco)
def verlist = []
inStream.getText("UTF-8").eachLine {
if (it != null) {
if (it.contains("${PRODUCT}")){
String[] tok = it.tokenize("[/\\-]+")
verlist << tok[1]
}
}
}
inStream.close()
def finlstr = verlist.unique().sort().collect{ '"' + it + '"'}.join(",")
def finl = finlstr.split(',')
println "$finl"
try {
return finl
}catch(e){ return [e.toString()] }