Jenkins使用groovy生成下拉数据
方法一
test.py内容
mm="%s,%s,%s"%("aabbcc1",333,"cccc")
print(mm)
def retobj2 = "/usr/bin/python /data/script/test.py".execute().text.readLines()
retobj2.each{println it}
def retobj2 = "/usr/bin/python /tmp/11.py".execute().text.readLines()
return retobj2
方法二
test.py内容
jj = json.dumps({"name":"fulei.sssyang","age":"18"})
print(jj)
def respText = "/usr/local/python3/bin/python3 /data/script/py/test.py".execute().text
def slurper = new groovy.json.JsonSlurper()
def branchs = slurper.parseText(respText) //parseText将json字符串转换为Map对象;JsonOutput类用于将Groovy对象转换为JSON字符串
方法三
python返回\n换行的字符串
"".execute().text.readLines()
方法4)
def html = "http://xxxxxx".toURL().text
def list = html.readLines()