LoginSignup
1
0

More than 5 years have passed since last update.

mvn sonar:sonarでSCMプロバイダを変更(指定) or SCM連携を無効化する

Last updated at Posted at 2017-06-11

mvnコマンドを使用してSonarQubeにメトリクス情報を送信する場合は、mvnコマンドのゴールに「sonar:sonar」を指定します。その際に、SCM連携のプロバイダを変更(指定)したり、SCM連携自体を無効化するができます。

動作検証バージョン

SCMプロバイダの変更(指定)

$ mvn sonar:sonar -Dsonar.scm.provider=tfvc

上記は、SCMとしてTeam Foundation Version Control(TFVC)を使用する場合の設定例です。
ちなみに・・・SonarQubeにTFVC用のプラグインをインストールしておかないと以下のようなエラーになります。(デフォルトだと、GitとSVNがサポートされているみたいです)

...
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project todo: SCM provider was set to "tfvc" but no SCM provider found for this key. Supported SCM providers are git,svn -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
...

SCM連携の無効化

$ mvn sonar:sonar -Dsonar.scm.disabled=true

上記はMavneコマンド側で無効化していますが、「Administrationメニュー > Configuration > General Settings > SCM」の「Disable the SCM Sensor」をONにすることで無効化することもできます。

まとめ

なんでこんなこと調べたかというと・・・なんらかの理由でSCM連携のプロバイダがGitになっており、Team Foundation Version Control(TFVC)」を使用しているプロジェクトに対して「mvn sonar:sonar」を行ったところ以下のようなエラーが発生したためです。

...
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project todo: /Users/xxx/tfvc/MyFirstProject/todo doesn't seem to be contained in a Git repository -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
...

なんでSCM連携のプロバイダがGitになっていたかは不明ですが・・・ビルドにJenkinsを使っていたので、Jenkins側で何か指定しちゃっているのかもしれません。

1
0
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
1
0