Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clean a particular directory before each build starts in jenkins?

I am using jenkins with hudson cli through java. I want clean a particular directory before each build. Any idea ? I have provided the maven command clean package which clean target folder for each build. What i want is i want to clean some other directory before each build. How to do this ?

In jenkins i specified URL of maven project , Which ll download files to workspace when building. When i give clean package command, it clears target folder every time when building. There is another folder parallel to target folder. i want to clear that folder which is inside maven project.

like image 891
Muthu Avatar asked Mar 07 '12 10:03

Muthu


People also ask

How do I clean up my Jenkins build?

To clean up the workspace before build: Under Build Environment, check the box that says Delete workspace before build starts. To clean up the workspace after the build: Under the heading Post-build Actions select Delete workspace when build is done from the Add Post-build Actions drop down menu.

What is delete workspace before build starts?

The plugin provides a build wrapper (Delete workspace before build starts) and a post build step (Delete workspace when build is done). These steps allow you to configure which files will be deleted and in what circumstances. The post build step can also take the build status into account.

What is cleanWs () in Jenkins?

cleanWs : Delete workspace when build is done.


3 Answers

If you are running version 1.433 or higher, use the Pre Steps / Post Steps in the project configuration section, located above and below the Build section, respectively.

Otherwise, install the M2 Extra Steps Plugin.

You can configure the maven-clean-plugin to handle the cleaning.

If you can't modify your pom.xml, as stated below, you can also use this plugin.

like image 71
bvulaj Avatar answered Nov 04 '22 22:11

bvulaj


You can use the Workspace Cleanup Plugin to do exactly that.

like image 42
Christopher Orr Avatar answered Nov 04 '22 22:11

Christopher Orr


You can add a JOB to clean the directory you want before each build. I have used ANT for this, no idea about MAVEN. This will not be machine dependent as well.

like image 31
0o'-Varun-'o0 Avatar answered Nov 05 '22 00:11

0o'-Varun-'o0