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

          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.

          Kalle Niemitalo added a comment - 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.

            Unassigned Unassigned
            brianjmurrell Brian J Murrell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: