Thursday, February 9, 2012

Jenkins: Change Workspaces and Build Directory Locations

Have you ever wanted to change the location of the workspace directory of a Jenkins job? Not enough space on your hard drive or your hard drive is too slow? Whatever the reason might have been for your wish, there is a simple solution. Every job in Jenkins has a well “hidden”, I mean really not so obvious, setting to modify the Workspace root location of the job. To change this location, you need to configure your job and click on the Advanced… button in the “Advanced Project Options” section.

Advanced Project Options

Once you opened the settings, you will find some more configuration options for your job. Look for the “Use custom workspace” option on the right hand side and check the box.

Specify custom workspace for job

Here is some information that you should consider reading, prior to change the workspace.

Information about custom workspace

Important: The next build will use the new location, but you have to manually relocate all the existing content from the previous location.

Globally Changing the workspace location for all Jobs

In order of changing the workspace for a single job, there is another option in the Jenkins system settings that allows for changing the workspace for every job.
Navigate to Jenkins->Manage Jenkins->Configure System and click on the Advanced Button on the right hand side.

Specify custom workspace and builds directory location

Voilà! This opens up the following options section

Custom workspace and builds directory location
 
Now you can change your workspace and build directory to any other location on your machine. Jenkins provides 3 predefined variables that can be used to specify the new location:
  • ${JENKINS_HOME} — Jenkins home directory
  • ${ITEM_ROOTDIR} — Root directory of a job for which the workspace is allocated
  • ${ITEM_FULLNAME} — ‘/’-separated job name, like “foo/bar”
The default value for the “Workspace Root Directory” is ${ITEM_ROOTDIR}/workspace and for the “Build Record Root Directory” it’s ${ITEM_ROOTDIR}/builds.

Some Notes

Please be aware, that if you change your workspace to a different location, the contents of the “old” workspace directory are not copied over to the new workspace.
Doing this on OSX could require to change the owner of the newly created workspace. So, if you encounter permission issues during your next build, then have a look at the new location.

35 comments:

Trinition said...

I didn't know pointing to a new workspace would be so easy! I should've guessed because everything in Jenkins is pretty slick. And this blog gave me the courage to charge ahead without caution.

Unknown said...

Great to hear that this was helpful to you.

Michael Pemulis said...

TL;DR use ITEM_FULL_NAME instead of ITEM_FULLNAME.

I had some trouble with this on Windows because the build job was a Maven project and ITEM_FULLNAME was expanding to a path with a component named "groupId:artifactId", which Windows rejected (due to the illegal colon character).

Found this issue, the comments of which were helpful: https://issues.jenkins-ci.org/browse/JENKINS-12251.

The advice is to use ITEM_FULL_NAME instead of ITEM_FULLNAME.

Roberto Prevato said...

After changing the workspace and build directories, using the Jenkins interface, my jobs are not starting anymore. They stay in pending state, with message "pending - waiting for next executor". I tried to revert the change to the default value; but it doesn't work. I verified that the number of executors didn't change: it's still 2, like it used to be. I am using Windows; and after changing the configuration, Jenkins created automatically those directories, with links to the previous ones. Can anybody help me with this?

Roberto Prevato said...

I managed to resolve the problem using the Jenkins web interface, by doing the following:
1 Going to the Jenkins configuration and clicking on the button "Reload configuration from disk";
2 Going to the build executor status page; I noticed that the master was in "dead" state; I clicked on its name and it changed to Idle

I am not sure which of the two things resolved the problem; but the problem definitely happened after I changed the configuration.

viral shah said...

I m archiving my builds . is there anyway i can change the location for it ?

Unknown said...

Does anyone know if it is possible to have the Jenkins access its jobs if they're stored in an aws s3 bucket?

Unknown said...

I don't know if there is a way to specify the archive location. Have you had a look at the sources?
I don't think, that there is a way to access the Jenkins job when they are located in S3. Usually jobs have to be located on the local Jenkins install directory.

Prashant Katiyar said...

Nice and helpful blog. Thanks for sharing this valuable knowledge Business Directory Listing India, Local Business Listing.

sra said...

What does this ${ITEM_ROOTDIR}/workspace indicate?I just want to know where this ${ITEM_ROOTDIR}/workspace point outs to specifically.

Promozie said...

Nice Blog,Thanks For Sharing Information.
ABCWorld is Business Centre in Pune Providing fully-furnished and equipped workspace in Pune & commercial office space in pune .

Abcworld said...

ABCWorld is Business Centre in Pune Providing fully-furnished and equipped workspace in Pune & commercial office space in pune .

Unknown said...

Thanks for sharing Good informative blog post on Jenkins. This helpful to me alot and hope the same for jenkins learner.

Best Regards,
DevOps Training in Hyderabad

Promozie said...

Apeejay Business Center is coworking space Providing fully-furnished and equipped coworking space pune & coworking .

Apeejay Business Center said...

Being One of prestigious office space for rent in Pune , Apeejay Business Center offers spacious and ergonomically designed executive office space providers and office space on rent in pune.

AKD said...

Thanks for Hints,
!!! BUT !!
After I followed the instructions and run again the Jenkins I loosed all my Files and Dirs in the custom location.
later I found the following in text:
Important: The next build will use the new location, but you have to manually relocate all the existing content from the previous location.

Please put it at the start of the instructor to avoid such situation.

Now my Question is do someone knows how to get the loosed content from the Custom location?

Apeejay Business Center said...

Being One of prestigious office space for rent in Pune , Apeejay Business Center offers spacious and ergonomically designed executive office space providers and office space on rent in pune.

Unknown said...

Thank you very much for sharing information.

seo said...

office space in Nehru Place
Coworking Space Near Me
flexible office space in South Delhi
shared office space in Delhi
Good article post thanks for sharing.

Bàn Cầu Một Khối Inax said...

Thanks for sharing of u! I very like yourblog (y) (y)

Inax



Rajani said...

Thanks for sharing Very Use ful Blog..
Docker Online Training
Kubernetes Online Training
Kubernetes Training in Hyderabad

ankit said...

I was scrolling the internet like every day, there I found this article which is related to my interest. The way you covered the knowledge about the subject and the 2 BHK flat in kolar road was worth to read, it undoubtedly cleared my vision and thoughts towards B 4 BHK flat inkolar road. Your writing skills and the way you portrayed the examples are very impressive. The knowledge about 3 BHK flat in kolar road
is well covered. Thank you for putting this highly informative article on the internet which is clearing the vision about top builders in Bhopal and who are making an impact in the real estate sector by building such amazing townships.

Danishsingh said...

Nice Blog Thanks for Sharing.
data selling companies
b2b database providers in india
traders directory
database provider
b2b data companies
b2b data providers

Rajani said...

Great Blog.very interesting and informative Blog...
Docker Training in Hyderabad
Docker and Kubernetes Online Training

Rajani said...

Thank you!! This is very useful article.
E- Learning Training Portal
Portal- ELearning

Vivek_Tank said...

Thanks for the information. It's very useful. If any business looking for best web design & PSG Grant eCommerce website developer in Singapore, check our website now for the best web design packages.

Cassandra Jones said...

Thanks for the information. It's very useful. If any one is looking for the best piano teacher in Singapore, check out Adeline Piano Studio, perfect destination for private piano lessons for kids & adults in Singapore.

piano lesson for kids
piano classes for kids
piano lessons for adults singapore
home piano lessons singapore

Bhanu Sree said...

Thank you for sharing very useful blog!!!!
Microsoft Azure DevOps training hyderabad
Microsoft Azure DevOps Training

Rajani said...

Nice Blog!! Thanks for the information.
DevOps Training
DevOps Online Training

un known said...

I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously in their life, he/she can earn his living by doing blogging.thank you for thizs article. devops online training

svrtechnologies said...

I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic. devops training

logodesignersingapore said...

Nice Information. Thanks for sharing this Post. Are you looking for web design and logo design for your company or business please contact Subraa your freelance website designer and logo designer in Singapore. Structure your business website and get your logo FREE.

Click the below links know more the offers:

Logo Design
Logo Design Singapore
Logo Designer Singapore
Web Designer Singapore
Digital Marketing Agency in Singapore
Flyer Design Singapore
Name Card Design Singapore

Rajani said...

Hi nice article, i really impressed on your course content.This is helpful to all.........
DevOps Training
DevOps Training institute in Ameerpet
DevOps Classroom Training in Hyderabad

Alfred Avina said...

The main motive of the Big data consulting services is to spread the knowledge so that they can give more big data engineers to the world.

steve said...

Top Web design and Development company in Brampton
Best Website development service company in Toronto
Webaxis is Canada’s top digital marketing and SEO service organization. Search has advanced and the calculation has changed so we refreshed our self and made a specialty in Digital World. When Considering the best SEO organization in Canada, we are one of the main and the best players in the SEO service division