jenkinsci / docker-plugin

Jenkins cloud plugin that uses Docker
https://plugins.jenkins.io/docker-plugin/
MIT License
489 stars 318 forks source link

Workspace in jenkins ui #906

Open nbraun1 opened 2 years ago

nbraun1 commented 2 years ago

What feature do you want to see added?

I know that this problem is already known but it is still important in my opinion. As described in #583 the feature Remote FS Root Mapping make no sense - i agree with you! But if you remove a feature, you should provide a good alternative to avoid breaking changes. Sure, there are a handful workarounds to visualize the workspace in the jenkins ui but all of these are too complex. I'm not so familiar with the jenkins api but i think there is a way to use a workspace from the jenkins controller filesystem which comes as mount from a docker jenkins agent. So, is this possible to develop and integrate this feature to the docker-plugin?

Upstream changes

No response

pjdarton commented 2 years ago

You are welcome to do so. See https://github.com/jenkinsci/docker-plugin/blob/master/CONTRIBUTING.md for contributing guidelines. If you're interested in developing this plugin, you could even take over maintaining it.

Note that there are some non-trivial technical barriers:

  1. The Jenkins core code assumes that different agents never share a filesystem so it doesn't engage its "make sure these two builds aren't both using the same workspace folder" when builds are running on different agents. If you map multiple agent filesystems into a single place, you're doing to have to figure out a way of preventing two builds from stomping over each others' contents.
  2. Jenkins doesn't do much in the way of workspace-folder garbage-collection. There are plugins which do, but none of them would understand this scheme, so you'd need to implement that too, otherwise you'll fill up the disk and break your world.
  3. I don't think Jenkins understands how a build workspace could be accessible after the agent it ran on no longer exists. I'm not sure how you'd solve that one - you'd need to figure out a way of telling Jenkins "don't access the workspace in the normal way" so you may need to enhance Jenkins' core first.

Note: The docker-plugin's behaviour in this matter is consistent with all the other cloud plugins - once the agent is gone, the build workspaces it contained are gone too. I strongly suspect that what you need first is a non-trivial enhancement to the core Jenkins code to make it possible for plugins like this one (and the other cloud plugins, vSphere, EC2, Azure etc) to provide support for such a feature, and then get it added to those plugins too in order to provide a consistent UX.

Alternatively, you can do what everyone else seems to do and to use the "Archive artefact" build step to rescue the data that you're interested in keeping from the agent's build workspace and store it back on the Jenkins controller.