JenkinsでAnt実行し、checkstyleを実行する

JenkinsでAnt実行し、checkstyleを実行する

Jenkinsの新規ジョブ作成で、ビルドやCheckstyleをAntでビルドします。

以下はcompileしてからcheckstyleを実行する例です。

Jenkins\workspace\プロジェクト名\配下にbuild.xmlを配置します。

「ビルド後の処理」でCheckstyle警告の集計を選択します。

修正するファイル配置場所を適当に記述します。xml形式にします。

workspace\プロジェクト名\がデフォルト位置になります。

checkstyleのbuild.xmlの例です。

<taskdef resource="checkstyletask.properties"
classpath="${lib.dir}/checkstyle-all-4.4.jar" />

<target name="checkstyle" description="Run checkstyle">
<!-- checkstyle定義ファイル -->
<checkstyle config="${checkstyle.conf.dir}/confrage.checkstyle.xml" failOnViolation="false">
<fileset dir="${compile.src}" includes="**/*.java" />
<property key="checkstyle.header.file" value="${checkstyle.conf.dir}/java.header" />
<property key="checkstyle.suppressions.file" value="${checkstyle.conf.dir}/suppressions.xml" />
<property key="checkstyle.importcontrol.file" value="${checkstyle.conf.dir}/import-control.xml" />
<formatter type="xml" toFile="${checkstyle.output.dir}/checkstyle_report.xml" />
</checkstyle>
</target>

checkstyletask.propertiesは、checkstyle-all-4.4.jarファイル内に存在するファイルです。これをresourceで指定する必要があります。

「Checkstyle警告」というリンクが表示されるのでクリックすると、「Checkstyle警告の推移」が表示されます。

コメント

タイトルとURLをコピーしました