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

Expose workspace path in environment for "prepare environment" scripts

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • envinject-plugin
    • None
    • LTS 1.625.3

      We use the "Prepare an environment for the run" option to run scripts prior to SCM checkout. However, the WORKSPACE environment variable is not set when those scripts run and I cannot find any way to discover what the workspace will eventually be. For example, if the project is set to allow concurrent builds and the workspace will have "@3" appended to the path, that information is inaccessible. This means our scripts that sanitize the git folders on the slave have to make some dangerous assumptions about where to run.

      I'm not very familiar with the Jenkins code, but from what I can tell the workspace is "leased" in AbstractBuild$AbstractBuildExecution.run() just before the call to prepareWorkspace(). If the WORKSPACE variable were added to the environment at that point, I think it would be visible from any scripts running before SCM checkout.

      Would it be possible to add this?

          [JENKINS-32103] Expose workspace path in environment for "prepare environment" scripts

          Daniel Beck added a comment -

          Should be easy enough for the EnvInject plugin to provide this variable for its scripts.

          Daniel Beck added a comment - Should be easy enough for the EnvInject plugin to provide this variable for its scripts.

          Oleg Nenashev added a comment -

          Unfortunately I will not have time to work on EnvInject issues for a while. I decided to unassign all issues so that somebody can take them and finalize.

          Context: The plugin has been waiting for adoption for ~2 years. During all this time I was trying to keep this plugin afloat by reviewing the incoming pull requests, fixing defects and keeping the codebase up to date to simplify the handover. But I have not been using this plugin on my own so that such maintenance was a bit lame. I invite all active users to contribute to the plugin by taking ownership of this plugin and of EnvInject API. I am happy to provide any required knowledge transfers and do some assistance during the first months of maintenance

          Oleg Nenashev added a comment - Unfortunately I will not have time to work on EnvInject issues for a while. I decided to unassign all issues so that somebody can take them and finalize. Context: The plugin has been waiting for adoption for ~2 years. During all this time I was trying to keep this plugin afloat by reviewing the incoming pull requests, fixing defects and keeping the codebase up to date to simplify the handover. But I have not been using this plugin on my own so that such maintenance was a bit lame. I invite all active users to contribute to the plugin by taking ownership of this plugin and of EnvInject API. I am happy to provide any required knowledge transfers and do some assistance during the first months of maintenance

            Unassigned Unassigned
            samatwork Sam Clippinger
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: