Showing posts with label knowhow. Show all posts
Showing posts with label knowhow. Show all posts

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.

Thursday, October 8, 2009

Never use System.exit(1) in a groovy script

I wrote a small groovy script to to do some maintenance tasks on my machine. At some point the logic got a little bit more complicated and I decided to write some simple testcases. I executed the testscript and was really surprised about the output: the test should fail but it didn‘t! Now I tried to nail it down with limiting the scope to a very simple method call but the result was exactly the same. Hm, I thought it must have something todo with log4j that I used to write everything into the logfile. So I removed the log4j dependency and started the tests again. To my surprise the result didn‘t change at all. There was no output from junit on the console. I started to look a little bit closer at the class and walked through the constructor call to the method that I called during my test. Bang! There is was! In the constructor I checked for the existence of a certain resource (in this case a mounted volume). If the volume wasn‘t mounted I terminated the script with System.exit(1). I guess this was a really bad idea. Now I changed it to throw new RuntimeException(‘Volume not mounted‘) and everything is fine again.
Lesson learned: Never call System.exit(1) in constructor calls!

Tuesday, February 17, 2009

Tabbed Browsing mit Tabhunter

Ich hab mich in den letzten Jahren an den Gebrauch der Tabs in allen möglichen Applikationen so sehr gewöhnt, dass ich mich manchmal dabei ertappe, wie ich die übliche Tastenkombination ⌘+T (zumindest auf dem Mac) drücke und nichts passiert. Fast alle verwendeten Applikationen (zumindest mit Multi Dokument Fähigkeit) unterstützen Tabs. Besonders häufig verwende ich die Tabs aber in Firefox. Ich hab immer so zwischen 30 und 50 Tabs geöffnet. Das Navigieren zwischen den Tabs wir hier auch immer durch den Gebrauch der Maus begleitet. Da ich aber viel lieber mit der Tastatur arbeite, habe ich nach einem Firefox Add-On gesucht um die Tabs per Shortcut auszuwählen oder zumindest einen Tab zu suchen und ihn auszuwählen.
Tada! Gesucht und gefunden: Tabhunter ist meine Rettung. Einfach installieren und los geht's.
Der Shortcut ⌘^T öffnet ein kleines Fenster mit der Liste aller Tabs. Einfach etwas aus dem Title der geöffneten Seite tippen und schon reduziert sich die Trefferliste. Sollte der gesuchte Tab dabei sein, dann reicht das betätigen der Return Taste um diesen Tab anzuspringen. Das ist ein echter Timesaver.