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

Cannot run shell step if control dir parent is not writable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • durable-task-plugin
    • None
    • Jenkins 2.36
      durable-task-plugin 1.12

      A major part of our build pipeline is that it needs to chdir around our deployment machines and rollout several components. We were using ws/dir steps in our pipeline script to chdir to our target locations before spawning sh() scripts, but after updating to durable-task 1.12 this no longer works.
      The plugin attempts to create directories in unwritable locations.
      I've looked at the code: https://github.com/jenkinsci/durable-task-plugin/blob/master/src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java and understand you don't want to write to files inside the workspace, fair enough I guess, but that's not a concern for us.
      Is there a reason this can't either: a) use the regular tmpdir, or b) allow some kind of config for this?
      The current workaround is to make a dir somewhere we know is writable, chdir to it, then have the spawned shell script chdir back out. And then chdir back out once the `sh()` step is finished.

          [JENKINS-40785] Cannot run shell step if control dir parent is not writable

          Jesse Glick added a comment -

          Could probably do a writability check on the normal location, and if that fails, try falling back to the system temp dir. Beware that there are many other steps which use the workspace temp directory for various purposes which will continue to fail if it is not writable. The intention is that a workspace is an area that the Jenkins agent can freely write to.

          Workaround seems right: run the sh step from an actual workspace, but have the shell script cd wherever you like.

          Jesse Glick added a comment - Could probably do a writability check on the normal location, and if that fails, try falling back to the system temp dir. Beware that there are many other steps which use the workspace temp directory for various purposes which will continue to fail if it is not writable. The intention is that a workspace is an area that the Jenkins agent can freely write to. Workaround seems right: run the sh step from an actual workspace, but have the shell script cd wherever you like.

          The intention is that a workspace is an area that the Jenkins agent can freely write to.

          Well that's the thing. You actually mean that the parent directory of a designated workspace is an area that Jenkins needs to write to. So if you set ws('/var/www/my_site') in your pipeline you now need write access to /var/www for the shell step to work. This seems odd to me.
          It's also a bit strange that these directories can't exist in the standard java specified temp location. We purposely set -Djava.io.tmpdir on all of our slave nodes and I would have thought Jenkins would use that. Is there a technical reason the control dir can't be made in the java tmpdir?

          Jarrod Funnell added a comment - The intention is that a workspace is an area that the Jenkins agent can freely write to. Well that's the thing. You actually mean that the parent directory of a designated workspace is an area that Jenkins needs to write to. So if you set ws('/var/www/my_site') in your pipeline you now need write access to /var/www for the shell step to work. This seems odd to me. It's also a bit strange that these directories can't exist in the standard java specified temp location. We purposely set -Djava.io.tmpdir on all of our slave nodes and I would have thought Jenkins would use that. Is there a technical reason the control dir can't be made in the java tmpdir?

            Unassigned Unassigned
            jfunnell Jarrod Funnell
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: