首页 > 解决方案 > AWS 代码管道与 sonarcloud 的集成

问题描述

我对 Sonarcloud 很陌生。以前从未在生产中使用过它。最近,我接到了一项任务,将 snorcloud 集成到 AWS 代码管道中。我正在通过代码管道部署 PHP 应用程序。我已经按照一些教程来实现这一点。面对 20 多个问题,我能够解决 19 个问题:slight_smile:但停留在我无法在谷歌上找到任何帮助的地步。以下是来自 AWS codebuild 的错误日志:

21:16:18.118 WARN: Failed to resolve 13 include/require statements like 'Amazon/MarketplaceWebService/Client.php' from 'classes', 'Amazon/MarketplaceWebService/Model/CancelFeedSubmissionsRequest.php' from 'classes', 'Amazon/MarketplaceWebService/Model/GetFeedSubmissionListRequest.php' from 'classes', 'Amazon/MarketplaceWebService/Model/GetFeedSubmissionResultRequest.php' from 'classes', 'Amazon/MarketplaceWebService/Model/IdList.php' from 'classes', 'Amazon/MarketplaceWebService/Model/SubmitFeedRequest.php' from 'classes', 'Amazon/MarketplaceWebServiceSellers/Client.php' from 'classes', 'Amazon/MarketplaceWebServiceSellers/Model/ListMarketplaceParticipationsRequest.php' from 'classes', 'class-wc-settings-advanced.php' from 'views', 'live_activity.php' from 'common'
864 21:16:21.036 INFO: 13513/13514 files analyzed, current file: wp-content/plugins/woo-permalink-manager/index.php
865 21:16:24.575 INFO: 13514/13514 source files have been analyzed
866 21:16:24.577 INFO: No PHPUnit test report provided (see 'sonar.php.tests.reportPath' property)
867 21:16:24.578 INFO: No PHPUnit coverage reports provided (see 'sonar.php.coverage.reportPaths' property)
868 21:16:24.578 INFO: Sensor PHP sensor [php] (done) time=1529254ms
869 21:16:24.578 INFO: Sensor Analyzer for "php.ini" files [php]
870 21:16:24.624 DEBUG: 'php.ini' generated metadata with charset 'UTF-8'
871 21:16:24.680 DEBUG: 'shop-06-jul/php.ini' generated metadata with charset 'UTF-8'
872 21:16:24.777 INFO: Sensor Analyzer for "php.ini" files [php] (done) time=199ms
873 21:16:24.777 INFO: Sensor CFamily [cpp]
874 21:16:24.781 INFO: CFamily plugin version: 6.20.0.31240
875 21:16:24.781 ERROR:
876
877 The only way to get an accurate analysis of C/C++/Objective-C files is by using the SonarSource build-wrapper
878 and setting the property "sonar.cfamily.build-wrapper-output", but it was not specified.
879
880 If you don't want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:
881
882 sonar.c.file.suffixes=-
883 sonar.cpp.file.suffixes=-
884 sonar.objc.file.suffixes=-
885
886
887 21:16:24.793 WARN: Failed to close server
888 java.net.ConnectException: Failed to connect to /127.0.0.1:42759
889 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:249)
890 at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:167)
891 at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
892 at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
893 at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
894 at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
895 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
896 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
897 at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
898 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
899 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
900 at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
901 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
902 at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
903 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
904 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
905 at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:264)
906 at okhttp3.RealCall.execute(RealCall.java:93)
907 at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:226)
908 at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.clean(EslintBridgeServerImpl.java:311)
909 at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.stop(EslintBridgeServerImpl.java:336)
910 at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.stop(StartableCloseableSafeLifecyleStrategy.java:38)
911 at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.stop(AbstractInjectionFactory.java:88)
912 at org.picocontainer.behaviors.AbstractBehavior.stop(AbstractBehavior.java:179)
913 at org.picocontainer.behaviors.Stored$RealComponentLifecycle.stop(Stored.java:141)
914 at org.picocontainer.behaviors.Stored.stop(Stored.java:118)
915 at org.picocontainer.DefaultPicoContainer.stopAdapters(DefaultPicoContainer.java:1048)
916 at org.picocontainer.DefaultPicoContainer.stop(DefaultPicoContainer.java:803)
917 at org.sonar.core.platform.ComponentContainer.stopComponents(ComponentContainer.java:152)
918 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:111)
919 at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
920 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
921 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
922 at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
923 at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
924 at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
925 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
926 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
927 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
928 at java.base/java.lang.reflect.Method.invoke(Unknown Source)
929 at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
930 at com.sun.proxy.$Proxy0.execute(Unknown Source)
931 at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
932 at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
933 at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
934 at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
935 at org.sonarsource.scanner.cli.Main.main(Main.java:61)
936 Caused by: java.net.ConnectException: Connection refused (Connection refused)
937 at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
938 at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
939 at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
940 at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
941 at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
942 at java.base/java.net.Socket.connect(Unknown Source)
943 at okhttp3.internal.platform.Platform.connectSocket(Platform.java:130)
944 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:247)
945 ... 46 common frames omitted
946
947 21:16:25.055 DEBUG: stylelint-bridge server will shutdown
948 21:16:30.083 INFO: ------------------------------------------------------------------------
949 21:16:30.083 INFO: EXECUTION FAILURE
950 21:16:30.083 INFO: ------------------------------------------------------------------------
951 21:16:30.083 INFO: Total time: 35:23.431s
952 21:16:30.364 INFO: Final Memory: 153M/514M
953 21:16:30.364 INFO: ------------------------------------------------------------------------
954 21:16:30.364 ERROR: Error during SonarScanner execution
955 java.lang.UnsupportedOperationException:
956
957 The only way to get an accurate analys`enter code here`is of C/C++/Objective-C files is by using the SonarSource build-wrapper
958 and setting the property "sonar.cfamily.build-wrapper-output", but it was not specified.
959
960 If you don't want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:
961
962 sonar.c.file.suffixes=-
963 sonar.cpp.file.suffixes=-
964 sonar.objc.file.suffixes=-
965
966
967 at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:208)
968 at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:175)
969 at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:45)
970 at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
971 at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:51)
972 at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:68)
973 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
974 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
975 at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:442)
976 at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:438)
977 at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:396)
978 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
979 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
980 at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
981 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
982 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
983 at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
984 at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
985 at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
986 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
987 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
988 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
989 at java.base/java.lang.reflect.Method.invoke(Unknown Source)
990 at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
991 at com.sun.proxy.$Proxy0.execute(Unknown Source)
992 at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
993 at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
994 at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
995 at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
996 at org.sonarsource.scanner.cli.Main.main(Main.java:61)
997
998 [Container] 2021/05/20 21:16:30 Command did not exit successfully sonar-scanner -Dsonar.organization=integratechfze -Dsonar.projectKey=mohsin-123 -Dsonar.sources=. -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=************************* -X exit status 1
999 [Container] 2021/05/20 21:16:30 Phase complete: PRE_BUILD State: FAILED
1000 [Container] 2021/05/20 21:16:30 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: sonar-scanner -Dsonar.organization=************** -Dsonar.projectKey=************** -Dsonar.sources=. -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=************************* -X. Reason: exit status 1

在此处输入代码有人可以帮我解决这些错误吗?非常感谢您提前。

标签: phpaws-codebuildsonarcloud

解决方案


请检查您的 buildspec.yml 文件和源代码。日志显示:

887 21:16:24.793 WARN: Failed to close server 888 java.net.ConnectException: Failed to connect to /127.0.0.1:42759

看起来您在localhost某处的代码中使用了 SonarScanner 无法连接到该地址。


推荐阅读