phicdy devlog

Androidアプリ開発やその他技術系の記事をたまに書きます

AndroidとかiOSとかモバイル多め。その他技術的なことも書いていきます。

JenkinsのJUnitでNoClassDefFoundError

JUnitの結果のXMLファイルがなぜかNoClassDefFoundErrorで読めなかったが、解決したのでメモ。

環境

エラーと原因

エラーは以下の通り。

Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information
Recording test results
ERROR: Publisher hudson.tasks.junit.JUnitResultArchiver aborted due to exception
java.lang.NoClassDefFoundError: hudson/tasks/junit/JUnitParser$ParseResultCallable
     at hudson.tasks.junit.JUnitParser.parseResult(JUnitParser.java:90)
     at hudson.tasks.junit.JUnitResultArchiver.parse(JUnitResultArchiver.java:120)
     at hudson.tasks.junit.JUnitResultArchiver.perform(JUnitResultArchiver.java:137)
     at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:74)
     at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
     at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
     at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
     at hudson.model.Build$BuildExecution.post2(Build.java:183)
     at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
     at hudson.model.Run.execute(Run.java:1770)
     at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
     at hudson.model.ResourceController.execute(ResourceController.java:89)
     at hudson.model.Executor.run(Executor.java:240)

 

調べた結果以下のページで解決した。 

[#JENKINS-26060] Using Jenkins 1.583. Today updated plugins, junit publisher now crashes. - Jenkins JIRA

The problem is that JUnit 1.3 is actually incompatible with Jenkins before 1.587 except 1.580.1 LTS. Unfortunately this cannot be expressed through dependencies, and to make it available to LTS users, it'll also be made available to users on weeklies >1.580.


どうもJenkinsのバージョンが1.587より古く、JUnitプラグインのバージョンが1.3だと不具合が出てしまうらしい。 

私の環境ではJUnitプラグインのバージョンは1.5だったが、同様の問題が発生したので、1.3以降なら起きるのかもしれない(未検証)。


解決方法

Workarounds:
・Downgrade JUnit to 1.2
・Downgrade/cross-grade Jenkins to 1.580.1 LTS
・Upgrade Jenkins to 1.587 or higher
As this only affects older weekly releases between 1.580 and 1.586, it's not worth the effort to fix. The general expectation is that users keep their instance fairly close to the current release when using the weeklies.  


JUnitのバージョンを下げるか、Jenkinsのバージョンを1.580.1にするか1.587以上にすればいいとのことなので、Jenkinsのバージョンを最新版にして解決。

# 一応バックアップ
$sudo mv /usr/share/jenkins/jenkins.war /usr/share/jenkins/jenkins.war.1.581
# Jenkinsの設定画面からダウンロード
$sudo cp /home/hoge/Download/jenkins.war /usr/share/jenkins/
# 再起動
$sudo /etc/init.d/jenkins restart


というかJenkinsの管理画面でアップデートしろとずっと出ていたのを無視していたのがよくなかったな。。。