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

Define WORKSPACE_TMP=.../workspace/jobname@tmp

    XMLWordPrintable

Details

    • Jenkins 2.214, workflow-durable-task-step 2.36

    Description

      WorkspaceList.createTempDir (JENKINS-27152) is used by various plugins, and from Pipeline builds you can even use pwd tmp: true to use this location for custom purposes, but this is awkward. In practice many scripts wind up just binding this to a variable (example). We should define it out of the box.

      $WORKSPACE is used for the main workspace (though not frequently needed as this is also the default working directory). $WORKSPACE_TMP seems like an intuitive name for the new property and matches the style of the @tmp suffix. Standard practice in Linux is to allow $TMPDIR to define a temporary directory, but using this variable name would result in a behavioral change for some existing scripts that may be unwanted, for example if /tmp is a RAM filesystem while the Jenkins workspace is persistent; we would like to offer a facility that users can opt in to where it makes sense (for example for project-specific caches) but not where it does not make sense (temporary files that are soon after deleted).

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Link This issue relates to JENKINS-27152 [ JENKINS-27152 ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            jglick Jesse Glick made changes -
            Description {{WorkspaceList.createTempDir}} (JENKINS-27152) is used by various plugins, and from Pipeline builds you can even use {{pwd tmp: true}} to use this location for custom purposes, but this is awkward. In practice many scripts wind up just binding this to a variable ([example|https://github.com/jenkinsci/kubernetes-plugin/blob/281d296f9a5945094a59b0f6f7362cbceede762a/Jenkinsfile#L10]). We should define it out of the box. {{WorkspaceList.createTempDir}} (JENKINS-27152) is used by various plugins, and from Pipeline builds you can even use {{pwd tmp: true}} to use this location for custom purposes, but this is awkward. In practice many scripts wind up just binding this to a variable ([example|https://github.com/jenkinsci/kubernetes-plugin/blob/281d296f9a5945094a59b0f6f7362cbceede762a/Jenkinsfile#L10]). We should define it out of the box.

            {{$WORKSPACE}} is used for the main workspace (though not frequently needed as this is also the default working directory). {{$WORKSPACE_TMP}} seems like an intuitive name for the new property and matches the style of the {{@tmp}} suffix. [Standard practice in Linux|https://en.wikipedia.org/wiki/TMPDIR] is to allow {{$TMPDIR}} to define a temporary directory, but using this variable name would result in a behavioral change for some existing scripts that may be unwanted, for example if {{/tmp}} is a RAM filesystem while the Jenkins workspace is persistent; we would like to offer a facility that users can opt in to where it makes sense (for example for project-specific caches) but not where it does not make sense (temporary files that are soon after deleted).
            jglick Jesse Glick made changes -
            Remote Link This issue links to "jenkins #4414 (Web Link)" [ 24229 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "workflow-durable-task-step #128 (Web Link)" [ 24230 ]
            jglick Jesse Glick made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            oleg_nenashev Oleg Nenashev made changes -
            Released As Jenkins 2.214
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Resolved [ 5 ]
            jglick Jesse Glick made changes -
            Resolution Fixed [ 1 ]
            Status Resolved [ 5 ] In Review [ 10005 ]
            jglick Jesse Glick added a comment -

            Resolved in core for freestyle and similar builds; PR remains open for Pipeline.

            jglick Jesse Glick added a comment - Resolved in core for freestyle and similar builds; PR remains open for Pipeline.
            jglick Jesse Glick made changes -
            Released As Jenkins 2.214 Jenkins 2.214, workflow-durable-task-step 2.36
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Fixed but Unreleased [ 10203 ]
            jglick Jesse Glick made changes -
            Link This issue causes JENKINS-61197 [ JENKINS-61197 ]
            basil Basil Crow added a comment - - edited

            Suppose, in a static agent scenario, that I want to bind TMPDIR to a place where users can indiscriminately write gigabytes of "stuff" that will get automatically cleaned up at the end of the build. Also suppose that all of my jobs have a cleanWs() step in a finally block before any ws or node block goes out of scope. Would you prefer #1 or #2:

            1. Use a withEnv block to bind TMPDIR to the result of e.g. mktemp -d -p "${WORKSPACE}".
            2. Use a withEnv block to bind TMPDIR to WORKSPACE_TMP and then patch cleanWs() to delete all suffix directories (including WORKSPACE_TMP) as some users have suggested in JENKINS-41805 (comment), JENKINS-44909, and JENKINS-50797.

            #1 seems simpler and safer to me, but I thought I'd check to see if you thought there were any arguments for #2.

            basil Basil Crow added a comment - - edited Suppose, in a static agent scenario, that I want to bind TMPDIR to a place where users can indiscriminately write gigabytes of "stuff" that will get automatically cleaned up at the end of the build. Also suppose that all of my jobs have a cleanWs() step in a finally block before any ws or node block goes out of scope. Would you prefer #1 or #2: Use a withEnv block to bind TMPDIR to the result of e.g. mktemp -d -p "${WORKSPACE}" . Use a withEnv block to bind TMPDIR to WORKSPACE_TMP and then patch cleanWs() to delete all suffix directories (including WORKSPACE_TMP ) as some users have suggested in JENKINS-41805 (comment) , JENKINS-44909 , and JENKINS-50797 . #1 seems simpler and safer to me, but I thought I'd check to see if you thought there were any arguments for #2.
            jglick Jesse Glick made changes -
            Status Fixed but Unreleased [ 10203 ] Resolved [ 5 ]
            jglick Jesse Glick added a comment -

            Gigabytes? I would say number 1. $WORKSPACE_TMP is intended for secrets, small text files needed temporarily to implement some step, etc.

            jglick Jesse Glick added a comment - Gigabytes ? I would say number 1. $WORKSPACE_TMP is intended for secrets, small text files needed temporarily to implement some step, etc.

            People

              jglick Jesse Glick
              jglick Jesse Glick
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: