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.
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.
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.
cleanWs : Delete workspace when build is done.
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.
You can use the Workspace Cleanup Plugin to do exactly that.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With