When you check a literal string within a list or array, it works well. But when you check a concat string within a list or array, it returns incorrect result.
And when compare the literal string and concat string directly, they are considered identical.
I failed at Jenkins pipeline with these code and I was tried on Groovy 1.8.9 directly, the result was the same.
In this code, issue_file = "issue-${signal_dc_key}.json", then contains returns false
def issued_list = ["names":["issue-something-DC-VV.json","issue-else-DC-VV.json"]]
def signal_dc_key = "something-DC-VV"
def issue_file = "issue-${signal_dc_key}.json"
println issue_file // issue-something-DC-VV.json
println issue_file == "issue-something-DC-VV.json" // true
println issue_file == "issue-${signal_dc_key}.json" // true
println issued_list["names"].contains("${issue_file}") // false
println issued_list["names"].contains(issue_file) // false
println issued_list["names"].contains("issue-something-DC-VV.json") // true
In this code, issue_file = "issue-something-DC-VV.json", contains returns true.
def issued_list = ["names":["issue-something-DC-VV.json","issue-else-DC-VV.json"]]
def signal_dc_key = "something-DC-VV"
def issue_file = "issue-something-DC-VV.json"
println issue_file // issue-something-DC-VV.json
println issue_file == "issue-something-DC-VV.json" // true
println issue_file == "issue-${signal_dc_key}.json" // true
println issued_list["names"].contains("${issue_file}") // false
println issued_list["names"].contains(issue_file) // true
println issued_list["names"].contains("issue-something-DC-VV.json") // true