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

Environment variable replacement issue on WINDOWS

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Duplicate
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows
    • Similar Issues:

      Description

      The "replaceMacro" method in core/src/main/java/hudson/Util.java doesn't work for Windows vairables.

      I installed the TestSwarm plugin from https://github.com/appendto/jenkins-testswarm. However, the environment vairables that I set in the plugin are not replace correctly. For example, I tried to use %GIT_COMMIT%, or ${GIT_COMMIT}. Either works. The Jenkin-Testswarm plugin correctly called the Util.replaceMacro method in Jenkins to the proper field, but the environment variables are not replaced.

      It seems the regex in the Util is not Windows friendly. If I change the code to the following, it works fine.

      Line 140: private static final Pattern VARIABLE = Pattern.compile("\\$%([A-Za-z0-9_]+|

      {[A-Za-z0-9_]+\\}

      )\\$%)");
      ...
      Line 169: String key = m.group(1);

      I have a folk and the changes to it. I'm not an expert on the other platform, can someone check if this works for both Windows and other platforms?
      https://github.com/xusun/jenkins/commit/b8dee2c710637e718290f93c31d3854099d2d157#comments

      Thanks,
      Xun

        Attachments

          Issue Links

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                Unassigned
                Reporter:
                xusun Xun Sun
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: