Docker pipeline: cleanWs

Hi,

It seems cleanWs and preBuildCleanup don’t work very well with docker containers (in pipelines).

I tried each of those commands to preclean the workspace before a build.

cleanWs removes the directory entirely. That disrupts the docker mount volume, somehow.

preBuildCleanup resulted in the following stages not continuing: “Stage skipped due to earlier failure(s)”.

Fix: a simple shell command such as rm -rf * .* ought to effectively do the job. Right?

Should the cleanWs functions be improved to detect they are running in a docker container?

Finally, if you google the following error, now you’ve got a result:

OCI runtime exec failed: exec failed: unable to start container process: current working directory is outside of container mount namespace root – possible container breakout detected: unknown

Jenkins 2.462.2


I should mention, the reason I posted this was so that if someone encounters exactly the above error, “OCI runtime exec failed:”, they will find a result. It was caused by cleanWs removing the directory, and then docker fails because the directory is completely missing. I searched for that error in connection with Jenkins, and didn’t find any results. So not asking for assistance, or reporting a bug, or anything else.

As an after thought though: if there could be error checking that catches this problem, at the level of the pipeline plugin, or the cleanws function, or even at the top level of the Jenkins code itself, it could notice the user is doing something that is not recommended, and then in the job log output, surrounded by a lot of whitespace to highlight the warning message, tell the user they are doing something that is not recommended. That could be generalized to other sanity checks of pipelines jobs like a linter. who knows. :slight_smile: