Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have Jenkins not clean a git workspace

Our Jenkins job that builds our project triggers on changes in the master of several GIT repositories. When it starts building it cleans the workspace of all the repo checkouts. We want to use the job only for clean build on request and by default for incremental builds. Some of our generated code is (still) generated inside the checkout, is therefor cleaned and therefor required to be regenerated and built each run. This takes quite a bit of time we would like to get rid of.

Note the last line of this part of the build log:

Started by user jenkins
Building on master
Checkout:WORK_PLATFORM3_REL_BUILD / /home/jenkins/data/WORK_PLATFORM3_REL_BUILD - hudson.remoting.LocalChannel@116fc35
Using strategy: Default
Last Built Revision: Revision 5479a644c63e128efb4fa61c00b4a708d8ae594f (origin/master)
Checkout:xxxxxx / /home/jenkins/data/WORK_PLATFORM3_REL_BUILD/xxxxxxx - hudson.remoting.LocalChannel@116fc35
Fetching changes from 1 remote Git repository
Fetching upstream changes from ssh://[email protected]:29418/xxxxxxx
Commencing build of Revision 5479a644c63e128efb4fa61c00b4a708d8ae594f (origin/master)
Checking out Revision 5479a644c63e128efb4fa61c00b4a708d8ae594f (origin/master)
Cleaning workspace

I cannot find a setting in the job's configuration to disable this "cleaning workspace" nor any global setting to change this.

Is there a solution?

BTW, we're running Jenkins 1.410 (off topic: will upgrading to latest version be a trivial task?)

like image 415
Katjoek Avatar asked Jul 14 '13 07:07

Katjoek


People also ask

Does Jenkins clean workspace?

Now you can configure an existing job in Jenkins to use the Cleanup job you just created. Open Configuration of an existing job and add a post-build action to trigger the above created new clean-up job. So, after Job A executes and builds, Job B (clean up its own workspace) will run automatically.

How do you preserve Jenkins workspace?

You could simply archive the complete workspace at the end of a build. It would then get deleted when the job is deleted. To do this: Add post-build action -> "Archive the artifacts"

What does wipe out current workspace to Jenkins?

There is a way to clean up a workspace in Jenkins. You need to install the Workspace Cleanup Plugin. This plugin can clean up the workspace before build or after a build. Under Build Environment, check the box that says Delete workspace before build starts.

Is it safe to delete workspace in Jenkins?

Delete TFS Workspaces in Jenkins Job Then it is safe to call the post-build command “Delete workspace” which is deleting the files physically. However, you will notice that by default you cannot insert post build Windows batch commands. To be able to do so, you need to install a new plugin- Post-Build Script Plug-in.


1 Answers

There is a check box 'clean after checkout' if you click the second 'Advanced' button under 'source code management' -> 'Git' settings in job configure page. Make sure this checkbox is not ticked for your case.

like image 98
harish Avatar answered Sep 21 '22 02:09

harish