-
Bug
-
Resolution: Unresolved
-
Minor
-
None
I've been working on a patch for ws-cleanup-plugin to make it possible to use "Clean workspace before build" in a (declarative) pipeline. Apologies if I have misunderstood things, but I haven't done that much development of Jenkins Plugins before.
The code in question was a BuildWrapper, but is now SimpleBuildWrapper, to make it compatible with declarative pipelines.
https://github.com/jenkinsci/ws-cleanup-plugin/pull/49
When used in a non-pipeline job the wrapper is executed during the preCheckout phase IIUC. That means that it is executed before the job checks out code from SCM. When used in a pipeline job the wrapper is executed after the default checkout from SCM. This can be seen in the logs.
It took a while for me to understand that the method runPreCheckout() is only being evaluated for non-pipeline builds. Is there a technical reason for this? If not, would it be possible to change this so that runPreCheckout() is evaluated for pipeline builds as well?
I have managed to work around this by modifying the declarative pipeline to look like this:
pipeline { agent any options { skipDefaultCheckout(true) } stages { stage('Build') { steps { preBuildCleanWs { checkout scm echo "Building ${env.JOB_NAME}..." } } } } }
That however doesn't feel intuitive and, as I said in the beginning, this plugin behaves differently in pipeline and non-pipeline jobs by default.
- relates to
-
JENKINS-61856 Add the ability to "Delete workspace before build starts" in a declarative pipeline
- Closed