Steps To Clean Jenkins Workspace

Step 1 : Go to Jenkins dashboard . Here create a sample freestyle project .

Step 2 : Now write a script which will generate some files in the workspace . (windows users should use windows batch commands and ubuntu users should use shell to write the script )

echo "hello geeks" > file1.txt
echo "Jenkins is easy" > file2.txt
echo "this is a sample job" > file3.txt
echo "this script is used in my w3wiki article"

Step 3 : Now after this build the project by selecting Build Now .

Step 4 : Select workspace to see the files .

Step 5 : Now to clean the workspace select Wipe Out Current Workspace and then click ok .

Now in your workspace you will not see any files . This workspace clean up should be done before performing any new build as to ensure that there is no conflict between present files and old files . Until now we have cleaned workspace manually , now follow the steps below to automate workspace clean up on each new build .

Step 6 : Select configure . Then go to a section called Build Environment . Here select Delete workspace before build starts .

From now, on each new build , the workspace is cleaned up . Basically all the files of old build are deleted .

Step 7 : Now update the script . Here i have only updated the file1.txt contents .

echo "hello geeks. This is an article on How to clean Jenkins Workspace " > file1.txt
echo "Jenkins is easy " > file2.txt
echo "this is a sample job" > file3.txt
echo "this script is used in my w3wiki article"

Step 8 : Now build the project and go to its workspace .

Step 9 : Now click on the file1.txt to see its content . You will see the updated content .

How To Clean Jenkins Workspace?

Jenkins is an open-source tool that is used to automate the build, test, and deploy stages of software. The Jenkins server always creates new workspaces on each new build to store the project code, build artifacts, log files, test files, and temporary files. Here in this guide, I will first discuss what is Jenkins. Then I will discuss Jenkins workspace and why it is important to clean Jenkins workspace. After this, i will guide you through the different steps to clean a Jenkins workspace of a particular Jenkins job.

Similar Reads

What is Jenkins?

Jenkins is an automation tool used for DevOps practice. It automates the build, test, and deploy stages of software development. Jenkins has a very friendly UI. It also provides many plugins to automate various stages. For example, it provides privacy and was plugins for testing purposes. Jenkins accelerates the software development cycle. By automating various stages and tasks, Jenkins helps any software development team to reduce any type of manual errors and improve efficiency. Jenkins is evolving and becoming more reliable with its every new update. In summary, we can say Jenkins has become an essential tool for organizations to improve and accelerate their software development cycles....

Why To Clean Jenkins Workspace?

Jenkins Workspace is a directory on the Jenkins server where the project code and all other dependency files are stored. Whenever users build a new job, the Jenkins server by default makes a new workspace for that job to store the project code fetched from a version control system like Github, Gitlab, etc. It is important to clean Jenkins Workspace for the following reasons :...

Pre-requisites

Before moving to the next section make sure you have installed Jenkins on your system. If Jenkins is not installed, then follow these detailed geeks for geeks articles to install Jenkins on your system....

Steps To Clean Jenkins Workspace

Step 1 : Go to Jenkins dashboard . Here create a sample freestyle project ....

Conclusion

Here in this guide you have first learned what is Jenkins . Then you have learned the various reasons to clean up Jenkins workspace . After this you have created a sample job , where you have used a script to generate some files in the workspace . Then finally you have followed the steps for manual clean up and automatic clean up of Jenkins workspace ....

Clean Jenkins Workspace – FAQ’s

What is Jenkins Workspace ?...