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

${WORKSPACE} variable doesn't use my specific workspace directory anymore in a build step

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: envinject-plugin
    • Labels:
      None
    • Environment:
      Jenkins on Linux

      Description

      With version 0.26, when I specify a specific project workspace (in project advanced options), if I use $

      {WORKSPACE}

      in a build step (in my case a shell script), the variable is replaced but it is replace by the default workspace value, not the one I specified previously.

      1. envinject_test.xml
        3 kB
        Marcel Huber
      2. envinject_test.xml
        3 kB
        Marcel Huber

        Activity

        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/EnvInjectBuildWrapper.java
        src/main/java/org/jenkinsci/plugins/envinject/EnvInjectBuilder.java
        src/main/java/org/jenkinsci/plugins/envinject/EnvInjectListener.java
        src/main/java/org/jenkinsci/plugins/envinject/EnvInjectLogger.java
        src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectVariableGetter.java
        http://jenkins-ci.org/commit/envinject-plugin/8fdee0a1a42b310b5a1bbfb00f38414fbb001b21
        Log:
        Fixed JENKINS-12027

        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/EnvInjectBuildWrapper.java src/main/java/org/jenkinsci/plugins/envinject/EnvInjectBuilder.java src/main/java/org/jenkinsci/plugins/envinject/EnvInjectListener.java src/main/java/org/jenkinsci/plugins/envinject/EnvInjectLogger.java src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectVariableGetter.java http://jenkins-ci.org/commit/envinject-plugin/8fdee0a1a42b310b5a1bbfb00f38414fbb001b21 Log: Fixed JENKINS-12027
        Hide
        marcelhuber Marcel Huber added a comment -

        There is now a case where $

        {WORKSPACE}

        is not set anymore in the pre-build phase when a referencing variable is used to set a different working directory.
        Please see the attached jenkins envinject_test.xml Job file. It also tests some of the previously filed issues. It would be nice to have some tests for your plugin which could be extended by filed cases.

        I personally need such a thing to be sure not to update to a newer version of the plugin which breaks features I rely on in my build jobs.

        Thanks again for your effort and help.

        Show
        marcelhuber Marcel Huber added a comment - There is now a case where $ {WORKSPACE} is not set anymore in the pre-build phase when a referencing variable is used to set a different working directory. Please see the attached jenkins envinject_test.xml Job file. It also tests some of the previously filed issues. It would be nice to have some tests for your plugin which could be extended by filed cases. I personally need such a thing to be sure not to update to a newer version of the plugin which breaks features I rely on in my build jobs. Thanks again for your effort and help.
        Hide
        marcelhuber Marcel Huber added a comment -

        My little test file used to see if the plugin sets the things my build jobs rely on.

        Show
        marcelhuber Marcel Huber added a comment - My little test file used to see if the plugin sets the things my build jobs rely on.
        Hide
        gbois Gregory Boissinot added a comment - - edited

        In your sample, when you specify PREPARE_WORKSPACE=$

        {WORKSPACE}

        for the 'Prepare an environment' envinject section, what WORKSPACE value do you expect?

        Show
        gbois Gregory Boissinot added a comment - - edited In your sample, when you specify PREPARE_WORKSPACE=$ {WORKSPACE} for the 'Prepare an environment' envinject section, what WORKSPACE value do you expect?
        Hide
        gbois Gregory Boissinot added a comment -

        Any update?
        Could I close the issue?

        Show
        gbois Gregory Boissinot added a comment - Any update? Could I close the issue?
        Hide
        marcelhuber Marcel Huber added a comment -

        Sorry for the delay - I didn't notice your update.
        I expect the WORKSPACE variable to contain the path value to the workspace directory for the current job.
        Maybe the setup I used isn't that straight forward. Also I just realized that my testsetup is not what I expected. I missed the point that setting a custom workspace directory - using a relative path - gets appended to either JENKINS_HOME or the remote root directory for slaves.
        Sorry for the troubles.

        But one last point I almost missed is that setting environment variables using envinject ignores case sensitivity. Using the following example:
        FLAGS=someValue
        flags=someOtherValue

        kills the second variable and only FLAGS will finally be set.

        Show
        marcelhuber Marcel Huber added a comment - Sorry for the delay - I didn't notice your update. I expect the WORKSPACE variable to contain the path value to the workspace directory for the current job. Maybe the setup I used isn't that straight forward. Also I just realized that my testsetup is not what I expected. I missed the point that setting a custom workspace directory - using a relative path - gets appended to either JENKINS_HOME or the remote root directory for slaves. Sorry for the troubles. But one last point I almost missed is that setting environment variables using envinject ignores case sensitivity. Using the following example: FLAGS=someValue flags=someOtherValue kills the second variable and only FLAGS will finally be set.
        Hide
        marcelhuber Marcel Huber added a comment -

        modified testfile which hopefully reflects a better test setup

        Show
        marcelhuber Marcel Huber added a comment - modified testfile which hopefully reflects a better test setup
        Hide
        gbois Gregory Boissinot added a comment -

        Unless I'm mistaken, it works with EnvInject 1.2.
        Please could you try?
        Regarding the uppercase, it is the expected behavior.

        Show
        gbois Gregory Boissinot added a comment - Unless I'm mistaken, it works with EnvInject 1.2. Please could you try? Regarding the uppercase, it is the expected behavior.

          People

          • Assignee:
            gbois Gregory Boissinot
            Reporter:
            korg Philippe Larouche
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: