Top Topic ?

Hudson upgrade 1.339 to 1.348

Posted in cie by Ladislav Prskavec on March 3, 2010

We try upgrade Hudson 1.339 to 1.342 and more and we have problems with Section View plugin.


[!] Error
org.jvnet.hudson.reactor.ReactorException: hudson.util.IOException2:
Unable to read /srv/tomcat/.hudson/config.xml
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:246)
at hudson.model.Hudson.executeReactor(Hudson.java:666)
at hudson.model.Hudson.(Hudson.java:585)
at hudson.WebAppMain$2.run(WebAppMain.java:224)
Caused by: hudson.util.IOException2: Unable to read
/srv/tomcat/.hudson/config.xml
at hudson.XmlFile.unmarshal(XmlFile.java:154)
at hudson.model.Hudson$11.run(Hudson.java:2095)
at
org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:146)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
at hudson.model.Hudson$3.runTask(Hudson.java:648)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoSuchFieldError: DESCRIPTOR
at hudson.plugins.sectioned_view.ListViewSection.(ListViewSection.java:37)
at
...

Solution is so complicated.

  1. Stop using Section View plugin
  2. Stop Hudson
  3. Backup /user/.hudson/config.xml file
  4. Delete config.xml
  5. Make upgrade to last Hudson war
  6. Start Hudson
  7. Upgrade Section view plugin
  8. Start using Section View Plugin
  9. Stop hudson
  10. Restore config.xml from backup
  11. Start Hudson

All working! Good luck!

Advertisements

PHP CodeBrowser and Hudson integration

Posted in qa by Ladislav Prskavec on December 10, 2009

I read about PHP_CodeBrowser and their html reports are nice.

How can add this reports to Hudson ?

Use HTML Publisher Plugin!

It’s easy, add to your build script new target phpcb in this style:

<target name="phpcb">
<exec executable="phpcb" dir="${basedir}/source">
<arg line="--log reports/logs/
--source source/
--output reports/phpcb/" />
</exec>
</target>

Don’t forget install HTML Publisher Plugin and make in job settings to directory with reports:

Reports are done:

Tagged with: , , ,

Backup jobs for Hudson

Posted in php by Ladislav Prskavec on November 11, 2009

Hudson has new version every week. Before migration I recommend backup jobs and plugins. For backup you can used my hudson-manager. It’s Ant script with some targets. Source you can see at http://gist.github.com/231775.

In manager.properties you set directories and days after delete old backups.

To run backup use cron with this parameters:

05 10,15 * * 1-5 /usr/bin/ant -f /srv/hudson/hudson-manager/manager.xml backupOnlyJobs
05 19 * * 1-5 /usr/bin/ant -f /srv/hudson/hudson-manager/manager.xml backup

Bigger backup i make one per day and minor backup (jobs only) twice per day. In full backup are stored plugins and jobs. Sometimes you can after upgrade plugins and backup is useful.

Tagged with: ,

PHP Class for Hudson

Posted in php by Ladislav Prskavec on April 29, 2009

I make php class for work with Hudson (http://code.google.com/p/php4hudson/). Is useful for save all jobs configs and deploy jobs on another server or some multichanges in jobs. Useful is easy and some example is in wiki.

Save all config.xml


/**
* Retrive all config.xml and save into directory
*/
require_once ("src/phphudson.php");
$hudson = new PhpHudson('http://localhost:8080/');
// save all jobs config into temp
$hudson->getAllConfigs("/tmp/hudson/");

Recreate all jobs


/**
* Read all config.xml from directory and create jobs in Hudson
*/
require_once ("src/phphudson.php");
$hudson = new PhpHudson('http://localhost:8080/');
$dir = '/tmp/hudson/';
if ($handle = opendir($dir)) {
echo "Directory handle: $handle\n";
echo "Files:\n";
while (false !== ($file = readdir($handle))) {
echo "$file\n";
$hudson->createJob(basename(str_replace("-config.xml", "", $file)), file_get_contents($dir . $file));
}
closedir($handle);
}

Tagged with:

PHP and Hudson

Posted in php by Ladislav Prskavec on February 26, 2009

Hudson is extensible continuous integration engine used for Java projects. It’s architecture can be used for others languages as PHP too.

Install

  1. download war file
  2. run direct in console java -jar hudson.war (free port 8080 andJDK 1.5+)
  3. or make install to servlet server (Tomcat, Jetty, JBoss, …)
  4. after that go http://localhost:8080
  5. plugins recommended for php

Build

For build can use phing (example) or ant.

<?xml version="1.0" encoding="UTF-8"?>
<project name="start_page" basedir="." default="main">
<!-- $Id: build.xml 102 2009-02-26 14:39:10Z abtris $ -->
<property name="tmp" value="/tmp" />
<property name="wsname" value="source" />
<property name="package"  value="${phing.project.name}" override="true" />
<property name="builddir" value="${tmp}/build/${phing.project.name}" override="true" />
<property name="srcdir"   value="./src/" override="true" />

<!-- Main Target -->
<target name="main" description="main target">

<!-- Create dirs -->
<mkdir dir="${builddir}/reports"/>
<mkdir dir="${builddir}/reports/coverage"/>

<!-- PHP API Documentation -->
<phpdoc title="API Documentation"
destdir="${builddir}/apidocs"
sourcecode="yes"
defaultpackagename="StartPage"
output="HTML:Smarty:PHP">
<fileset dir=".">
<include name="*/*.php" />
</fileset>
</phpdoc>

<!-- PHP CodeSniffer -->
<exec command="phpcs --standard=ZEND --report=checkstyle ${ws}/${wsname}/src/ > ${builddir}/reports/checkstyle.xml" escape="false" />

<!-- PHPUnit -->
<exec command="phpunit --log-xml ${builddir}/reports/phpunit.xml --log-pmd ${builddir}/reports/phpunit.pmd.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/ tests/AllTests.php"/>

</target>
</project>

Example configuration

Project name: StartPage
Source Code Management: Subversion
Repository URL: https://localhost/svn/start_page/trunk
Local module directory (optional): source
Use update: true

Build

Execute shell: phing -f $WORKSPACE/source/build.xml -Dws=$WORKSPACE -Dtmp=$WORKSPACE

Post-build action

Publish Javadoc
Javadoc directory = build/start_page/apidocs/
Retain javadoc for each successful build = false
Publish JUnit test result report
Test report XMLs = build/start_page/reports/phpunit.xml
Publish Checkstyle analysis results
Checkstyle results = build/start_page/reports/checkstyle.xml
Publish PMD analysis results
PMD results = build/start_page/reports/phpunit.pmd.xml
Publish Clover Coverage Report
Clover report directory = build/start_page/reports/coverage/