我定义了以下映射
def e_environments = [["demo1@mystuff.com":"file1"], ["demo2@mystuff.com":"file1"], ["insurance1@mystuff.com":"file2"], ["insurance2@mystuff.com":"file2"]]
是否有一种方法可以从变量值中用相同的文件名替换URL。例如
def demo_env = ["demo1@mystuff.com","demo2@mystuff.com"]
def insurance_env= ["insurance1@mystuff.com","insurance2@mystuff.com"]
def def e_environments = [[${demo_env}:"file1"], [${insurance_env}:"file2"]]
答案 0 :(得分:0)
我希望您在问到这里之前必须已经做出了一些努力。
def e_environments = [ "demo1@mystuff.com":"file1", "demo2@mystuff.com":"file1" , "insurance1@mystuff.com":"file2" ,"insurance2@mystuff.com":"file2" ]
def temp = []
e_environments.keySet().each{
temp.add(e_environments[it])
}
temp.unique().each{ val ->
println e_environments.findAll{it.value==val}
}