カテゴリー別アーカイブ: jenkins

jenkinsへplugin追加(phpcs)

■phpcs

コーディング規約チェック

■Plugin追加

SnapCrab_NoName_2014-7-16_6-18-47_No-00

■設定

ビルド後の追加

「Checkstyle警告の集計」

SnapCrab_NoName_2014-7-16_6-5-58_No-00


reports/phpcs.xml

SnapCrab_NoName_2014-7-16_6-3-55_No-00

「保存」

■実行結果

ビルドを実行すると

SnapCrab_NoName_2014-7-16_6-12-9_No-00

Checkstyleの結果のレポートメニュ(アイコン)が追加になります

jenkinsへpluginを追加する(phpmd)

■phpmd
バグの可能性をチェックします

SnapCrab_NoName_2014-7-16_5-14-42_No-00

 

■Plugin組み込み

Jnkins>Jnkinsの管理>プラグインの管理>

利用可能タブ切り替え
右上「フィルタ」PDM
により選択し、追加を行います

Plugin「PDM Plugin」を追加します

■設定

タスク選択

設定>ビルド後の処理追加
「PDM警告の集計」

SnapCrab_NoName_2014-7-16_5-32-41_No-00
PDM警告集計

集計するファイル

reports/pmd.xml

SnapCrab_NoName_2014-7-16_5-24-50_No-00

「保存」

となります

■実行結果

SnapCrab_NoName_2014-7-16_5-42-24_No-00

PDM警告が追加になります

jenkinsへのplugin

jenkinsへpluginを追加してみます

<?xml version="1.0" encoding="utf-8" ?>
<project name= "BuildTest" basedir= "." default= "main">

<target name="main" depends= "init,phpmd,phpcs,phpcpd,phpunit,phpdoc"></target>
    <!-- init -->
    <target name="init" >
        <delete dir= "./reports" includeemptydirs= "true" />
        <mkdir dir= "./reports" />
    </target>
  <!-- phpmd -->
  <target name="phpcs">
    <exec executable= "phpcs" output= "reports/phpcs.xml">
     <arg line= "--report=checkstyle C:\\xampp\\htdocs\\test" />
    </exec>
  </target>
  <target name="phpmd">
   <phpmd rulesets="codesize,unusedcode,design,naming">
   <fileset dir="C:\\xampp\\htdocs\\test">
   <include name="*.php"/>
   <exclude name="*Test.php"/>
   </fileset>
   <formatter type="xml" outfile="reports/pmd.xml"/>
    </phpmd>
  </target>
  
<!-- phpcpd -->
  <target name="phpcpd">
    <phpcpd>
      <fileset dir="C:\\xampp\\htdocs\\test">
       <include name="*.php"/>
      </fileset>
      <formatter type= "pmd" outfile= "reports/phpcpd.xml" />
    </phpcpd>
  </target>  
  
  <target name="phpunit">
   <coverage-setup database="coverage/coverage.db">
        <fileset dir="C:\\xampp\\htdocs\\test">
          <exclude name="*Test.php"/>
        </fileset>
    </coverage-setup>
   <phpunit codecoverage="true">
     <formatter type="xml" outfile="reports/phpunit.xml"/>
     <formatter type="clover" outfile="coverage/clover.xml"/>
      <batchtest>
        <fileset dir="C:\\xampp\\htdocs\\test">
          <include name="*Test.php"/>
        </fileset>
      </batchtest>
   </phpunit>
   <coverage-report outfile="clover.xml">
     <report todir="clover" />
   </coverage-report>
 </target>
 <target name="phpdoc">
  <exec command="phpdoc -d C:\\xampp\\htdocs\\test -t phpdoc"/> 
  </target> 
</project>
  • phpmd
  • phpcs
  • phpcpd
  • phpunit
  • phpdoc

■phpmd
バグの可能性をチェックします
■phpcs
コーディング規約違反をチェックします
■phpcpd
ソースに重複コード(コピペ)があるか調べます
■phpunit
単体テストを行います
■phpdoc
ドキュメントを作成します
となっています