有没有办法在jenkins管道中用另一个变量值替换映射值?

问题描述 投票:0回答:1

我定义了以下映射

def e_environments = [["[email protected]":"file1"], ["[email protected]":"file1"], ["[email protected]":"file2"], ["[email protected]":"file2"]]

有没有办法从一个变量值中替换出相同文件名的URL。例如

def demo_env = ["[email protected]","[email protected]"]
def insurance_env= ["[email protected]","[email protected]"]
def def e_environments = [[${demo_env}:"file1"], [${insurance_env}:"file2"]]
jenkins jenkins-pipeline
1个回答
0
投票

我希望你在这里问之前,一定要从你的方面做一些努力。这里有你要努力的地方。

def e_environments = [ "[email protected]":"file1", "[email protected]":"file1" ,  "[email protected]":"file2" ,"[email protected]":"file2" ]
def temp = []
e_environments.keySet().each{
  temp.add(e_environments[it])
}
temp.unique().each{ val ->  
  println e_environments.findAll{it.value==val}
}
  1. 从地图上拿到了所有的钥匙
  2. 创建一个独特的清单
  3. 还有一点凹凸不平的魔力,让你去解决和想办法。
© www.soinside.com 2019 - 2024. All rights reserved.