-
Improvement
-
Resolution: Unresolved
-
Minor
It would be nice if variables could be interpolated into the strings for the filters.
Currently, the filter strings are in quotes. Without quotes they could just be a string which contains a regular expression subject to variable interpolation:
def arch = 'bar' def myregex = '.*\\/foobar-\${arch}\\/' ... recordIssues filters: [excludeFile(myregex)], tools: [gcc4()]
The backslash in front of ${arch} escapes the $ from the RE. if one wanted it escaped from variable interpolation one would need to add another backslash such as
${arch}
Being able to define a list of excludeFile() s in a single variable would be even more useful though. not sure how that could work though.
[JENKINS-55574] interpolate variables in filters strings
Description |
Original:
It would be nice if variables could be interpolated into the strings for the filters. Currently, the filter strings are in quotes. Without quotes they could just be a string which contains a regular expression subject to variable interpolation: {noformat} def arch = 'bar' def myregex = '.*\\/foobar-\${arch}\\/' ... recordIssues filters: [excludeFile(myregex)], tools: [gcc4()] {noformat} The backslash in front of {{$\{arch\}}} escapes the {{$}} from the RE. if one wanted it escaped from variable interpolation one would need to add another backslash such as {{\\$\{arch\}}} Being able to define a list of {{excludeFile()}}s in a single variable would be even more useful though. not sure how that could work though. |
New:
It would be nice if variables could be interpolated into the strings for the filters. Currently, the filter strings are in quotes. Without quotes they could just be a string which contains a regular expression subject to variable interpolation: {noformat} def arch = 'bar' def myregex = '.*\\/foobar-\${arch}\\/' ... recordIssues filters: [excludeFile(myregex)], tools: [gcc4()] {noformat} The backslash in front of {{$\{arch\}}} escapes the {{$}} from the RE. if one wanted it escaped from variable interpolation one would need to add another backslash such as {{\\$\{arch\}}} Being able to define a list of {{excludeFile()}} s in a single variable would be even more useful though. not sure how that could work though. |
Rank | New: Ranked higher |
Rank | New: Ranked higher |
Rank | New: Ranked higher |
Assignee | Original: Ulli Hafner [ drulli ] | |
Labels | New: help-wanted |
Rank | New: Ranked lower |
Can't you use Groovy's string interpolation instead? I believe this should work already:
Here though, string interpolation would happen before the regular expression is parsed. So if arch can contain regular expression metacharacters but you want to match them as literal characters instead, then you might have to quote arch before inserting it to the regular expression:
I did not test any of this, though.