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

Injecting from file removes backslashes on ${WORKSPACE}

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Component/s: envinject-plugin
    • Labels:
      None
    • Environment:
      Windows Server 2003
    • Similar Issues:

      Description

      When using a configuration file, ${WORKSPACE} cannot be used if it contains backslashes.
      Obviously this causes a critical issue on Windows.
      When using the content section it works fine.

      Output shown in the "Injected Environment Variables" Page:
      AAACONTENTVAR D:\jenkins\jobs\TEST_FAIL\workspace
      AAAFILEVAR D:jenkinsjobsTEST_FAILworkspace

      This behavior can be reproduced by doing the following:
      1) Add build step "Execute batch script" and add the following content:
      echo AAAFILEVAR=${WORKSPACE} > temp.config
      2) Add build step "Inject environment variables" and add to properties file path:
      temp.config
      3) Add build step "Inject environment variables" and add to properties content:
      AAACONTENTVAR=${WORKSPACE}
      4) Add build step "Execute batch script" and add the following content:
      @ECHO OFF
      echo AAAFILEVAR = %AAAFILEVAR%
      echo AAACONTENTVAR = %AAACONTENTVAR%

      Console output:
      ------------------------------------------------------------------
      Building on master in workspace D:\jenkins\jobs\TEST_FAIL\workspace
      [workspace] $ cmd /c call C:\WINDOWS\TEMP\hudson6646008055064848449.bat

      D:\jenkins\jobs\TEST_FAIL\workspace>echo AAAFILEVAR=${WORKSPACE} 1>temp.config

      D:\jenkins\jobs\TEST_FAIL\workspace>exit 0
      [EnvInject] - Injecting environment variables from a build step.
      [EnvInject] - Injecting as environment variables the properties file path 'temp.config'
      [EnvInject] - Variables injected successfully.
      [EnvInject] - Injecting environment variables from a build step.
      [EnvInject] - Injecting as environment variables the properties content
      AAACONTENTVAR=${WORKSPACE}

      [EnvInject] - Variables injected successfully.
      [workspace] $ cmd /c call C:\WINDOWS\TEMP\hudson7725197076031217954.bat
      AAAFILEVAR = D:jenkinsjobsTEST_FAILworkspace
      AAACONTENTVAR = D:\jenkins\jobs\TEST_FAIL\workspace
      Finished: SUCCESS
      ------------------------------------------------------------------

        Attachments

          Activity

          Hide
          pixman20 pixman20 added a comment -

          The current workaround appears to be manually defining a custom workspace with /s.

          Show
          pixman20 pixman20 added a comment - The current workaround appears to be manually defining a custom workspace with /s.
          Hide
          gbois Gregory Boissinot added a comment -

          I think the problem is due to this action
          echo AAAFILEVAR=${WORKSPACE} > temp.config

          If you look at the temp.config file content, backslash are missing.
          Therefore, EnvInject is not in charge to fix it.

          Do not hesitate to reopen the issue if I'm wrong

          Show
          gbois Gregory Boissinot added a comment - I think the problem is due to this action echo AAAFILEVAR=${WORKSPACE} > temp.config If you look at the temp.config file content, backslash are missing. Therefore, EnvInject is not in charge to fix it. Do not hesitate to reopen the issue if I'm wrong
          Hide
          pixman20 pixman20 added a comment -

          The example I showed was not actually when I noticed the problem. Our builds all started failing when I updated from version 1.17 to 2.23. When I widdled down the config to a very simply config I came up with that example.
          You can simply create temp.config with SOMEVAR=${WORKSPACE} and if WORKSPACE has backslashes in it SOMEVAR will end up with no directory separators.

          If you are not able to reproduce this let me know what steps (Workspace name and build steps) you are using and I will verify that I still have the issue under those circumstances.

          Thanks for your help!

          Show
          pixman20 pixman20 added a comment - The example I showed was not actually when I noticed the problem. Our builds all started failing when I updated from version 1.17 to 2.23. When I widdled down the config to a very simply config I came up with that example. You can simply create temp.config with SOMEVAR=${WORKSPACE} and if WORKSPACE has backslashes in it SOMEVAR will end up with no directory separators. If you are not able to reproduce this let me know what steps (Workspace name and build steps) you are using and I will verify that I still have the issue under those circumstances. Thanks for your help!
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Gregory Boissinot
          Path:
          src/main/java/org/jenkinsci/plugins/envinject/service/PropertiesLoader.java
          http://jenkins-ci.org/commit/envinject-plugin/3f3ef659f51fc8b4e4004998343d56d24f84100c
          Log:
          Fix JENKINS-12809

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/org/jenkinsci/plugins/envinject/service/PropertiesLoader.java http://jenkins-ci.org/commit/envinject-plugin/3f3ef659f51fc8b4e4004998343d56d24f84100c Log: Fix JENKINS-12809

            People

            • Assignee:
              gbois Gregory Boissinot
              Reporter:
              pixman20 pixman20
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: