Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-63597

Double-quoted string literals perceived as String instead of as GString

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Fixed but Unreleased (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Component/s: pipeline
    • Labels:
      None
    • Environment:
      Jenkins 2.252.
    • Similar Issues:

      Description

      I declared the following var module in a shared pipeline library:

      {{call(
      GString msbuildloc,
      GString arguments,
      GString projloc,
      GString projfile)}}

      and invoke it from a declarative piplene with the following arguments:

      {{gt_msbuild(
      "C:
      Program Files (x86)\\MSBuild\\14.0\\Bin
      ",
      "${MSBUILD_PARAMS} /p:Configuration=Debug;Platform=AnyCPU;DotNetVer=${DotNetVer}",
      "$ProjDir",
      "Common.Encrypter.csproj")}}

      The invocation fails with the following error:

      {{No signature of method: gt_msbuild.call() is applicable for argument types:
      ( java.lang.String,
      org.codehaus.groovy.runtime.GStringImpl,
      org.codehaus.groovy.runtime.GStringImpl,
      java.lang.String)}}

      As you see, the percevied argument type of a double-quoted string depends on whether it contains actual interpolation or not. This is counterintuitive, incompatible with Groovy, and hard to work with. So much so that I consider it bug. Double-quoted string literals should treated consistently.

        Attachments

          Activity

          Hide
          ant_222 Anton Shepelev added a comment -

          I am sorry for the ruined code formatting. I used the "Preformatted text" option in the visual editor, but it did not seem to work, and there was no preview for me to notice it. Here is the properly formatted code.

          Show
          ant_222 Anton Shepelev added a comment - I am sorry for the ruined code formatting. I used the "Preformatted text" option in the visual editor, but it did not seem to work, and there was no preview for me to notice it. Here is the properly formatted code.
          Hide
          ant_222 Anton Shepelev added a comment -

          The problem was caused by a mistake in my script: I forgot to prepent call with def.

          Show
          ant_222 Anton Shepelev added a comment - The problem was caused by a mistake in my script: I forgot to prepent call with def.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ant_222 Anton Shepelev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: