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

          Sam Clippinger created issue -
          Daniel Beck made changes -
          Component/s New: envinject-plugin [ 15893 ]
          Component/s Original: core [ 15593 ]
          Assignee New: Oleg Nenashev [ oleg_nenashev ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 167586 ] New: JNJira + In-Review [ 182796 ]
          Oleg Nenashev made changes -
          Assignee Original: Oleg Nenashev [ oleg_nenashev ]

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

              Created:
              Updated: