[JIRA] (JENKINS-55574) interpolate variables in filters strings

2 views
Skip to first unread message

brian.murrell@intel.com (JIRA)

unread,
Jan 14, 2019, 7:19:02 AM1/14/19
to jenkinsc...@googlegroups.com
Brian J Murrell created an issue
 
Jenkins / Improvement JENKINS-55574
interpolate variables in filters strings
Issue Type: Improvement Improvement
Assignee: Ulli Hafner
Components: warnings-ng-plugin
Created: 2019-01-14 12:18
Priority: Minor Minor
Reporter: Brian J Murrell

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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

ullrich.hafner@gmail.com (JIRA)

unread,
Jan 14, 2019, 4:56:02 PM1/14/19
to jenkinsc...@googlegroups.com
Ulli Hafner updated an issue
Change By: Ulli Hafner
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.

ullrich.hafner@gmail.com (JIRA)

unread,
Feb 13, 2019, 7:24:02 AM2/13/19
to jenkinsc...@googlegroups.com
Ulli Hafner assigned an issue to Unassigned
Change By: Ulli Hafner
Labels: help-wanted
Assignee: Ulli Hafner

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Mar 5, 2020, 2:10:02 AM3/5/20
to jenkinsc...@googlegroups.com
Kalle Niemitalo commented on Improvement JENKINS-55574
 
Re: interpolate variables in filters strings

Can't you use Groovy's string interpolation instead? I believe this should work already:

def arch = 'bar'
def myregex = ".*\\/foobar-${arch}\\/"
recordIssues filters: [excludeFile(myregex)], tools: [gcc4()]
 
                                                            

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:

def myregex = ".*\\/foobar-${java.util.regex.Pattern.quote(arch)}\\/"

I did not test any of this, though.

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages