LoginSignup
2
2

More than 5 years have passed since last update.

CircleCI2.0でPHPCPDを動かしたらエラーで中断される問題

Posted at

はじめに

PHPプロジェクトのCIをJenkinsからCircleCI(2.0)に乗り換えました。マネージドサービス最高!
その際に、Jenkins時代に動かしていたPHP CodeSniffer(PHPCS)やPHP Mess Detector(PHPMD)を動かしたのですが、PHP Copy/Paste Detector(PHPCPD)がExit code: 1を返してくるため、ビルドが失敗になってしまったのを解決しました。

ビルドエラーの図。Exit code: 1(右上)
builderror.PNG

結論

コマンドに || true を追加

.circleci/config.yml
- run:
  name: Run PHP-CPD
  working_directory: src
  command: ./vendor/bin/phpcpd app --log-pmd=/output/phpcpd.result.xml || true

成功の図
success.PNG

経緯

はじめに、PHPMDに存在する --ignore-violations-on-exitオプションが使えるだろうと思い調べたところ、公式GitHubのIssueが見つかりました。
Option to exit with a zero code even if any violations are found. #148

質問者
CIで不便だからphpmdの--ignore-violations-on-exitみたいなやつ追加してくれないか
回答
役に立つとはおもわない

と、オプションによる解決はできませんでしたが、会話の中で出てきた「これで解決できるよ」という回答に救われたのでした。

shell
$ phpcpd ... || true 

その他参考にしたページ

Identifying Exit Codes and their meanings
https://support.circleci.com/hc/en-us/articles/360002341673-Identifying-Exit-Codes-and-their-meanings

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2