2020-11-13
背景:服务器上集成了sonar-maven-plugin 插件
pom文件的配置如下
<profiles> <profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <!-- Optional URL to server. Default value is http://localhost:9000 --> <sonar.host.url> http://localhost:9000 </sonar.host.url> </properties> </profile> </profiles> <pluginManagement> <plugins> <plugin> <groupId>org.sonarsource.scanner.maven</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>3.7.0.1746</version> </plugin> </plugins> </pluginManagement>
出现问题:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project com-tamu: You're not authorized to run analysis. Please contact the project administrator. -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :com-ta
解决办法:
输入 http://localhost:9000/account/security/ 这个地址点击自己的头像 --》点击My Account-->Security -->获取token 如下图
将自己的token 放到配置文件里
<profiles> <profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <!-- Optional URL to server. Default value is http://localhost:9000 --> <sonar.host.url> http://101.132.36.20:9000 </sonar.host.url> <!--<sonar.login>--> <!--3bd36278a3b15604791278be47eca6ae29be4af7--> <!--</sonar.login>--> </properties> </profile> </profiles>
就可以解决上面那个问题了。