2012/03/26

jenkins LTS 1.424.6 and java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;

While updating the parent version of JobConfigHistory+Plugin from Jenkins LTS version 1.424.2 to 1.424.6 I encountered
the following:


Using mvn dependency:tree, I saw that org.kohsuke.stapler:stapler:1.172 depends on
com.google.guava:guava:r06, this version does not include the symbol.
Version 1.424.6 of the WAR provides com.google.guava:guava:jar:11.0.1, which includes this symbol.
See Update to LTS 1.424.6 for the fix.

2012/03/25

Restarter script for jenkins

Restarter script for Jenkins

  • I am fighting with my Jenkins instance being down every other day.
  • Getting bored of sshing to the host and restart the instance, I wrote a small restarter script.
#!/usr/bin/python
"""
Simple restarter for jenkins - not a real Tanuki wrapper :-).
- Install to /usr/local/bin and make the script executable.
- Then create a cron entry to execute the script every 10 minutes:
cat << EOF > /etc/cron.d/restartjenkins
*/10 * * * * root /usr/local/bin/restartjenkins.py 2>&1 | logger -t restartjenkins
EOF
"""
import os
import sys
import urllib2
SERVICE_TO_RESTART = "/etc/init.d/jenkins restart"
URL_TO_CHECK = os.getenv("URL_TO_CHECK", "http://127.0.0.1:8000/hudson/")
def restart():
os.system(SERVICE_TO_RESTART)
if __name__ == "__main__":
try:
urllib2.urlopen(URL_TO_CHECK)
open("/tmp/%s.timestamp" % os.path.basename(sys.argv[0]), "w").write(URL_TO_CHECK)
except urllib2.URLError, e:
error = sys.exc_info()
error_message = "%s\n%s" % (error[0], error[1])
sys.stderr.write(error_message)
restart()