当前位置: 首页 > news >正文

大学做html个人网站素材代写文章平台

大学做html个人网站素材,代写文章平台,关于建立公司网站的申请,wordpress模板在哪购买基本概述 官网描述: SonarQube 提高您的团队成员的代码质量和安全性#xff0c;使所有开发人员能够编写更干净、更安全的代码。 官网地址: https://www.sonarqube.org/ 帮助文档: https://docs.sonarqube.org/latest/ Q: SonarQube 是什么? 答: SonarQube 是一个开源的代码…基本概述 官网描述: SonarQube 提高您的团队成员的代码质量和安全性使所有开发人员能够编写更干净、更安全的代码。 官网地址: https://www.sonarqube.org/ 帮助文档: https://docs.sonarqube.org/latest/ Q: SonarQube 是什么? 答: SonarQube 是一个开源的代码质量管理平台系统用于检测各类开发语言例如: java、php、python、html、C、C#、Groovy代码中的错误漏洞和代码规范; 并且现在它可以与现有的Gitlab、Jenkins进行集成以便在项目拉取后进行连续的代码质量检查; Q: SonarQube 有何用处? 答: CI/CD integration 和 代码评审反馈; SonarQube 特性 (1) 检查代码是否遵循编程标准如命名规范编写的规范等。(2) 检查设计存在的潜在缺陷SonarQube 通过插件 Findbugs、Checkstyle 等工具检测代码存在的缺陷。(3) 检测代码的重复代码量SonarQube 可以展示项目中存在大量复制粘贴的代码。(4) 检测代码中注释的程度源码注释过多或者太少都不好影响程序的可读可理解性。(5) 检测代码中包、类之间的关系分析类之间的关系是否合理复杂度情况。 SonarQube 版本 Current is 8.6 Community Edition(免费) (在你的CI/CD中采用代码质量的起点) The starting point for adopting code quality in your CI/CDDeveloper Edition(14 day free trial) : (最大的应用程序安全性最大的跨分支和PRs值) Maximum Application Security Maximum value across branches PRsEnterprise Edition :(管理您的应用程序组合在企业级别上保证代码质量和安全性。) Manage your Application Portfolio, enable Code Quality Security at an Enterprise level.Data CenterEdition : (高可用性用于全球部署) High Availability, for global deployments 参考地址: https://www.sonarqube.org/downloads/ SonarQube 组成 SonarQube 平台是由 4 个部分组成: SonarQube ServerSonarQube DatabaseSonarQube PluginsSonarQube Scanner SonarQube 工作流程: SonarQube 在进行代码质量管理时会从下面七个纬度来分析项目的质量Architecture(架构)、Duplications(段重复)、Unit test(单元测试)、Complexity(复杂程度)、Potential Bugs(潜在的BUG)、Codeding Rules(编码规则)、Comments(注解) SonarQube 需要数据库的支持用于存储检测项目后的分析数据同时为了实现可持续监测还需要持续集成工具如Jenkins的支持在构建版本前通过 JenkinsSonar 插件执行项目分析指令最终的结果会通过 SonarQube 服务器的Web 页面展示 下图是使用 SonarQube 做代码持续审查的流程图 本地项目开发推送开发的项目到 SCM (如果 Gitlab/Github)Jenkins采用自定义的Job进行自动构建并执行代码分析检测命令 (Sonar-Scanner)利用SonarQube接口进行分析项目源码(上面的七个维度)并存储到数据库之中SonarQube Web 前台展现代码分析结果给使用者 环境安装 描述: SnoarQube 安装方式有两种您可以使用传统的zip文件安装来评估SonarQube也可以使用我们的Docker映像来启动一个Docker容器 基础环境需求: 处理器 CPU 建议 4~8U内存 RAM 最低 1GM 建议至少 大于等于 4G磁盘空间量将取决于您使用 SonarQube 分析的代码量, 备注读写硬盘性能将对整个 SonarQube 服务器性能产生很大影响。建议 服务器端 与 扫描端都安装 64 位系统Java 版本 : 甲骨文 JRE / Openjdk 建议都使用 Jdk 11如果受环境因素较大扫描端可安装 JDK 8;数据库支持情况: 注意已经缺省弃用 MySQL 数据库 PostgreSQL 9.3–9.6, 10~12 # 必须配置为使用 UTF-8 字符集 MsSQL 2014 ~ 2017 MSSQL 服务器 12~14.0 与捆绑的微软 JDBC 驱动程序。支持快速版。 # 排序规则必须重写 CS 和重音敏感 AS例如Latin1_General_CS_AS), READ_COMMITTED_SNAPSHOT必须在 SonarQube 数据库上设置以避免在重负载下出现潜在的死锁 Oracle XE 版 / 11G / 12 ~ 19 C # 必须配置为使用 UTF8 系列字符集请参阅NLS_CHARACTERSET) , 驱动程序 ojdbc14.jar 不支持驱动程序, 仅支持精简模式不支持 OCI PS : 至sonarqube7.9版本以后就不支持Mysql了本地试用的话可以使用它内置的数据库系统运行内存一定要3G以上否则在启动项目时启动会显示ES失败; PS : 嵌入式数据库应仅用于评估目的, 嵌入式数据库不能伸缩它不支持升级到SonarQube的新版本也不支持将数据从其中迁移到另一个数据库引擎。 环境准备 基础配置 (0) 字体 描述: 生成执行报告要求在托管 SonarQube 的服务器上安装字体。在 Windows 服务器上这是给定的。但是Linux 服务器的情况并非总是如此。 应确保以下事项 Fontconfig安装在托管 SonarQube 的服务器上在SonarQube服务器上安装了 FreeType 字体包。确切的可用包将因分发而异但常用的包是libfreetype6(https://www.freetype.org/) (1) Linux上虚拟缓存与IO设置 # Linux 推荐配置 vm.max_map_count 大于或等于 524288 fs.file-max 大于或等于 131072 运行 SonarQube 的用户至少可以打开 131072 个文件描述符 运行 SonarQube 的用户至少可以打开 8192 个线程# 查看vm.max_map_count、fs.file-max、文件描述符、线程 sysctl vm.max_map_count sysctl fs.file-max ulimit -n ulimit -u# 临时配置按照需求调整 sysctl -w vm.max_map_count524288 sysctl -w fs.file-max131072 ulimit -n 131072 ulimit -u 8192 # 永久配置 更新 /etc/sysctl.d/99-sonarqube.conf 或 /etc/sysctl.conf # 指定用户 /etc/security/limits.d/99-sonarqube.conf or /etc/security/limits.conf sonarqube - nofile 131072 sonarqube - nproc 8192 PS : 如果使用systemd启动 SonarQube则必须在 [服务]部分中的单元文件中指定这些限制 [Service] ... LimitNOFILE131072 LimitNPROC8192 (2) seccomp过滤器 描述: 默认情况下弹性搜索使用seccomp 筛选器,在大多数发行版上此功能在内核中激活; 针对于 Linux 6 发行版此功能被停用。如果使用没有此功能的发行版并且无法升级到已激活 seccomp 的较新版本则必须通过更新 $SONARQUBEHOME/conf/sonar.properties 显式停用此安全层sonar.search.javaAdditionalOpts # 检查 seccomp 在您的内核上是否可用正常状态下应该是如下; $ grep SECCOMP /boot/config-$(uname -r) CONFIG_HAVE_ARCH_SECCOMP_FILTERy CONFIG_SECCOMP_FILTERy CONFIG_SECCOMPy# 配置 sonar.search.javaAdditionalOpts-Dbootstrap.system_call_filterfalse 本机安装 描述: 安装SonarQube的本地实例需要下载 SonarQube Zip 文件; Step 1.下载SonarQube社区版zip文件 : https://www.sonarqube.org/downloads/ Step 2.作为一个非root用户解压它比如在C:\sonarqube或/app/sonarqube中。 # 用户与sonarqube目录创建 sudo useradd -m sonarqube # esadmin、sonar sudo mkdir -vp /app/# 将sonarqube压缩包解压到/app/sonarqube sudo unzip sonarqube-8.6.0.39681.zip -d /app/# 创建软连接 /app$ sudo ln -s /app/sonarqube-8.6.0.39681/ /app/sonarqube /app$ ls /app/sonarqube/# bin/ COPYING elasticsearch/ lib/ temp/# conf/ data/ extensions/ logs/ web/ /app$sudo ln -s /app/sonarqube/bin/linux-x86-64/sonar.sh /usr/local/bin/sonar.sh# 权限设置 /app$ sudo chown -R sonarqube:sonarqube /app Step 3.SonarQube 简单配置文件/app/sonarqube/conf/sonar.properties # (1) 修改Sonarqube连接数据库配置文件 sonar.jdbc.usernamesonarqube sonar.jdbc.passwordpassword # #----- PostgreSQL 9.3 or greater sonar.jdbc.urljdbc:postgresql://localhost/sonarqube?currentSchemamy_schema # #----- Oracle 11g/12c/18c/19c sonar.jdbc.urljdbc:oracle:thin:localhost:1521/XE # #----- Microsoft SQLServer 2014/2016/2017 and SQL Azure sonar.jdbc.urljdbc:sqlserver://localhost;databaseNamesonar;integratedSecuritytrue# (2) Web Server JVM 设置 # -Xmx 设置你的应用程序(不是JVM)能够使用的最大内存数(注意不能超过内存数 ) # -Xms 设置程序初始化的时候内存栈的大小 sonar.web.javaOpts-Xmx512m -Xms128m -XX:HeapDumpOnOutOfMemoryError sonar.web.host0.0.0.0 sonar.web.port9000 Step 4.注意必须采用非root用户启动SonarQube服务器:PS:此处采用内置的数据库,如果是正式项目请采用外置数据库 # On Windows, execute: C:\sonarqube\bin\windows-x86-64\StartSonar.bat# On other operating systems, as a non-root user execute: # 启动 su - sonarqube -c /app/sonarqube/bin/linux-x86-64/sonar.sh console# 查看启动状态 su sonar ./bin/linux-x86-64/sonar.sh status# 跟踪日志 su sonar tail -f /usr/local/sonarqube-6.7.5/logs/sonar.log# 如出现以下四行表示启动成功 jvm 1 | 2020.12.30 09:39:42 INFO app[][o.s.a.SchedulerImpl] Process[es] is up jvm 1 | 2020.12.30 09:39:55 INFO app[][o.s.a.SchedulerImpl] Process[web] is up jvm 1 | 2020.12.30 09:39:59 INFO app[][o.s.a.SchedulerImpl] Process[ce] is up jvm 1 | 2020.12.30 09:39:59 INFO app[][o.s.a.SchedulerImpl] SonarQube is up 容器安装 描述: 采用Docker 容器的安装 SonarQube 非常简单访问 Find the Community Edition Docker image on Docker Hub:https://hub.docker.com/_/sonarqube/ Step 1.docker拉取SonarQube镜像以及运行 # 指定版本拉取 docker pull sonarqube:8.6.0-community# 运行 $ docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLEtrue -p 9000:9000 sonarqube:latest Step 2.实例启动并运行后使用系统管理员凭据登录 http://localhost:9000账号密码 admin然后安装参考请看基础使用; K8s集群安装 环境说明 Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focalClient: Docker Engine - CommunityVersion: 20.10.3API version: 1.41Go version: go1.13.15$ kubelet --version Kubernetes v1.19.6SonarQube 版本8.6.1-community # https://hub.docker.com/_/sonarqube Postgrep 版本13.1 # https://registry.hub.docker.com/_/postgres Tips : 本集群中kubernetes底层存储使用的是NFS并且以nfs作为存储创建了storageclass(名称为managed-nfs-storage)便于动态创建pv $ kubectl get storageclasses # alias sc# NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE# managed-nfs-storage (default) fuseim.pri/ifs Delete Immediate false 19d 操作流程 Step 1.环境准备之 PostgreSQL 部署需要将数据库的数据文件持久化因此需要创建对应的pv本次安装通过storageclass创建pv。 描述: SonarQube需要依赖数据库存储数据且SonarQube7.9及其以后版本将不再支持Mysql所以这里推荐设置PostgreSQL作为SonarQube的数据库。 Tips: 由于PostgreSQL只需要集群内部连接因此采用Headless service(无头服务)来创建数据库对应的svc数据库的端口是5432最终的yaml如下 cat PostgreSQL-Deployment.yaml END apiVersion: apps/v1 kind: Deployment metadata:name: postgres-sonarlabels:app: postgres-sonar spec:replicas: 1selector:matchLabels:app: postgres-sonartemplate:metadata:labels:app: postgres-sonarspec:containers:- name: postgres-sonarimage: postgres:13.1-alpineimagePullPolicy: IfNotPresentports:- containerPort: 5432env:- name: POSTGRES_DBvalue: sonarDB- name: POSTGRES_USERvalue: sonarUser- name: POSTGRES_PASSWORD value: WeiyiGeekresources:limits:cpu: 1000mmemory: 2048Mirequests:cpu: 500mmemory: 1024MivolumeMounts:- name: datamountPath: /var/lib/postgresql/datavolumes:- name: datapersistentVolumeClaim:claimName: postgres-data --- apiVersion: v1 kind: PersistentVolumeClaim metadata:name: postgres-data spec:accessModes: [ReadWriteMany]storageClassName: managed-nfs-storageresources:requests:storage: 1Gi --- apiVersion: v1 kind: Service metadata:name: postgres-sonarlabels:app: postgres-sonar spec:clusterIP: Noneports:- port: 5432protocol: TCPtargetPort: 5432selector:app: postgres-sonar END Step 2.执行kubectl apply|create创建资源并检查对应的pvpvc以及日志 ~/k8s/sonarqube$ kubectl create -f PostgreSQL-Deployment.yaml -n devops # deployment.apps/postgres-sonar created # persistentvolumeclaim/postgres-data created # service/postgres-sonar created~/k8s/sonarqube$ kubectl get pvc,deployment,svc -n devops | grep postgres# persistentvolumeclaim/postgres-data Bound pvc-5d6936c4-2999-4f86-8248-8ad784899801 1Gi RWX managed-nfs-storage 71s# deployment.apps/postgres-sonar 1/1 1 1 71s# service/postgres-sonar ClusterIP None none 5432/TCP 71s Step 3.SonarQube 部署的资源清单 cat sonarqube-deployment.yaml END apiVersion: apps/v1 kind: Deployment metadata:name: sonarqubelabels:app: sonarqube spec:replicas: 1selector:matchLabels:app: sonarqubetemplate:metadata:labels:app: sonarqubespec:initContainers:- name: init-sysctlimage: busyboximagePullPolicy: IfNotPresentcommand: [sysctl, -w, vm.max_map_count262144]securityContext:privileged: truecontainers:- name: sonarqubeimage: sonarqube:8.6.1-communityports:- containerPort: 9000env:- name: SONARQUBE_JDBC_USERNAMEvalue: sonarUser- name: SONARQUBE_JDBC_PASSWORDvalue: WeiyiGeek- name: SONARQUBE_JDBC_URLvalue: jdbc:postgresql://postgres-sonar:5432/sonarDBlivenessProbe:httpGet:path: /sessions/newport: 9000initialDelaySeconds: 60periodSeconds: 30readinessProbe:httpGet:path: /sessions/newport: 9000initialDelaySeconds: 60periodSeconds: 30failureThreshold: 6resources:limits:cpu: 2000mmemory: 2048Mirequests:cpu: 1000mmemory: 1024MivolumeMounts:- mountPath: /opt/sonarqube/confname: datasubPath: conf- mountPath: /opt/sonarqube/dataname: datasubPath: data- mountPath: /opt/sonarqube/extensionsname: datasubPath: extensionsvolumes:- name: datapersistentVolumeClaim:claimName: sonarqube-data --- apiVersion: v1 kind: PersistentVolumeClaim metadata:name: sonarqube-data spec:accessModes:- ReadWriteManystorageClassName: managed-nfs-storageresources:requests:storage: 10Gi --- apiVersion: v1 kind: Service metadata:name: sonarqubelabels:app: sonarqube spec:type: NodePortports:- name: sonarqubeport: 9000targetPort: 9000nodePort: 30002protocol: TCPselector:app: sonarqube END Tips: 通过官方的sonar镜像部署通过环境变量指定连接数据库的地址信息同样通过storageclass来提供存储卷通过NodePort方式暴露服务。 Tips: 与常规部署不同的是这里对sonar通过init container进行了初始化执行修改了容器的vm.max_map_count根据内存大小提供; # 修改此权限需要授权能执行系统命令 securityContext:privileged: true# 例如在Linux操作系统下可以在主机上以root用户运行以下命令来设置当前会话的推荐值: # For example, on Linux, you can set the recommended values for the current session by running the following commands as root on the host: sysctl -w vm.max_map_count262144 sysctl -w fs.file-max65536 ulimit -n 65536 ulimit -u 4096 Step 4.执行部署sonarqube并查看部署状态 ~/k8s/sonarqube$ kubectl create -f sonarqube-deployment.yaml -n devops# deployment.apps/sonarqube created# persistentvolumeclaim/sonarqube-data created# service/sonarqube created~/k8s/sonarqube$ kubectl get deployment,pvc,svc -n devops | grep sonarqube# deployment.apps/sonarqube 0/1 1 0 4m57s# persistentvolumeclaim/sonarqube-data Bound pvc-5695d2d5-e769-43f4-a91d-7ff0f5ab0b8b 10Gi RWX managed-nfs-storage 4m57s# service/sonarqube NodePort 10.100.233.217 none 9000:30002/TCP 4m57s Step 5.访问SonarQube UI: http://192.168.12.107:30002/sessions/new?return_to%2F 基础使用 1.初始化配置 Step 1.访问 http://10.10.107.217:9000/ 输入初始密码(admin/admin), 更新初始密码; Step 2.界面汉化插件操作步骤:Administration - Markplace - Plugins - 搜索 Chinese - 安装 Chinese Pack Localization - 重启 Server - 刷新页面 重新登陆 PS 官方地址中文包下载地址https://github.com/SonarQubeCommunity/sonar-l10n-zh/releases Step 3.安装代码检测插件默认已经安装了C Java Python PHP js等质量分析工具并且可以根据项目自行安装其它的代码检测语言比如 Go; Step 4.离线安装插件由于SonarQube安装可能需要很长的时间所以可以选择之前已经安装过的插件直接导入到Plugins目录, 然后重新服务后即可在应用中心查看已安装过的插件; # Plugins 目录 ~$ ls /app/sonarqube/extensions/plugins/ README.txt sonar-l10n-zh-plugin-8.5.jar# 将下载的插件解压到Plugins目录之中并授予相应的权限; tar xf sonar_plugins.tar.gz -C /usr/local/sonarqube/extensions/plugins/ sudo shown -R sonarqube.sonarqube /usr/local/sonarqube/extensions/plugins/ ls /app/sonarqube/extensions/plugins/ # README.txt sonar-l10n-zh-plugin-8.5.jar sonar-pmd-plugin-3.2.1.jar Step 5.如果在客户端需要分析HTML、PHP、Python等项目,则需要安装一个sonar-scanner(https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/)的工具; # Client端下载解压 wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.5.0.2216.zip # 2020-12-31 02:34:47 (517 KB/s) - ‘sonar-scanner-cli-4.5.0.2216.zip’ saved [589153/589153] unzip sonar-scanner-cli-4.5.0.2216.zip -d sonar-scanner-cli ~/sonar/sonar-scanner-4.5.0.2216$ ls # bin conf lib# 软连接 sudo ln -s /home/weiyigeek/sonar/sonar-scanner-4.5.0.2216/bin/sonar-scanner /usr/local/bin/ sonar-scanner -v # INFO: Scanner configuration file: /home/weiyigeek/sonar/sonar-scanner-4.5.0.2216/conf/sonar-scanner.properties # INFO: Project root configuration file: NONE # INFO: SonarScanner 4.5.0.2216 # INFO: Java 1.8.0_211 Oracle Corporation (64-bit) # INFO: Linux 5.4.0-46-generic amd64# 客户端 sonar-scanner 基础配置 ## 域名解析 sudo tee -a /etc/hosts EOF 10.10.107.217 sonar.weiyigeek.top EOF 2.静态项目分析实践 描述: 前面已经对SonarQube进行了一个简单的配置, 接下来我们将建立一个代码项目并进行分析; Step 1.创建项目与令牌(Token), 首页创建新项目 - 手工设置(项目标识/显示名) - 创建一个令牌 - 输入HelloWorld - 获得Token:helloWorld: 1b0b037f06e7990c360d62ce9151aaf978cec155 PS : 此时需要设置服务端开启认证(缺省是开启的)配置 - Force user authentication|强制用户使用认证 - 标识: sonar.forceAuthentication Step 2.在我们客户端机器拉取我们的静态Blog页面代码并进行质量分析; ~/code$ git clone gitgitlab.weiyigeek.top:ci-cd/blog.git ~/code/blog$ git config --list # core.repositoryformatversion0 # core.filemodetrue # core.barefalse # core.logallrefupdatestrue # remote.origin.urlgitgitlab.weiyigeek.top:ci-cd/blog.git # remote.origin.fetchrefs/heads/*:refs/remotes/origin/* Step 3.客户端 sonar-scanner.properties 全局参数设置,在之后的使用sonar-scanner命令时便可不输入以下参数; $ nano ~/sonar/sonar-scanner-4.5.0.2216/conf/sonar-scanner.properties #----- Default SonarQube server sonar.host.urlhttp://sonar.weiyigeek.top:9000#----- Token Configure sonar.login1b0b037f06e7990c360d62ce9151aaf978cec155#----- Default source code encoding sonar.sourceEncodingUTF-8 Step 4.开始在客户端进行代码的质量扫描 # 项目扫描 sonar-scanner -Dsonar.projectnameHello-World-Blog -Dsonar.projectKeyHello-World -Dsonar.sources.# INFO: CPD Executor CPD calculation finished (done) | time270833ms# INFO: Analysis report generated in 10280ms, dir size159 MB# INFO: Analysis report compressed in 44023ms, zip size39 MB# INFO: Analysis report uploaded in 1574ms# INFO: ANALYSIS SUCCESSFUL, you can browse http://sonarqube.weiyigeek.top/dashboard?idhtml# INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report# INFO: More about the report processing at http://sonarqube.weiyigeek.top/api/ce/task?idAXa2xmjzr2pPEzGrpOUX# INFO: Analysis total time: 6:52.709 s# INFO: ------------------------------------------------------------------------# INFO: EXECUTION SUCCESS # 分析扫描完成# INFO: ------------------------------------------------------------------------# INFO: Total time: 6:54.148s# INFO: Final Memory: 16M/423M# INFO: ------------------------------------------------------------------------ 3.Java项目分析实践 描述: Java 项目可以通过Maven进行代码质检而无需使用Sonar-Scanner工具(但是扫描出的结果比官方的工具较少)只需要安装Maven即可 Step 1.Linux 下 Maven 安装 apt install maven yum install maven Step 2.手动从Gitlab仓库获取Java代码进入项目目录并使用MVN进行代码质量扫描 ~/code/$ git clone gitgitlab.weiyigeek.top:ci-cd/java-maven.git ~/code/java-maven$ git config --list # core.repositoryformatversion0 # core.filemodetrue # core.barefalse # core.logallrefupdatestrue # remote.origin.urlgitgitlab.weiyigeek.top:ci-cd/java-maven.git # remote.origin.fetchrefs/heads/*:refs/remotes/origin/* # branch.master.remoteorigin # branch.master.mergerefs/heads/master Step 3.在 Maven 配置文件进行变量的定义配置只需要输入一条命令即可; # 方式1 mvn sonar:sonar -Dsonar.host.urlhttp://sonar.weiyigeek.top:9000 -Dsonar.login1b0b037f06e7990c360d62ce9151aaf978cec155 # [INFO] Scanning for projects... # Downloading from weiyigeek-maven: http://maven.weiyigeek.top:8081/repository/maven-public/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom # .... # [INFO] ANALYSIS SUCCESSFUL, you can browse http://sonarqube.weiyigeek.top/dashboard?idcom.weiyigeek.main%3Ahello-world # [INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report # [INFO] More about the report processing at http://sonarqube.weiyigeek.top/api/ce/task?idAXa2595Cr2pPEzGrpOUp # [INFO] Analysis total time: 7.113 s # [INFO] ------------------------------------------------------------------------ # [INFO] BUILD SUCCESS # [INFO] ------------------------------------------------------------------------ # [INFO] Total time: 27.219 s # [INFO] Finished at: 2020-12-31T03:46:57Z # [INFO] ------------------------------------------------------------------------# 方式2.在 Maven 配置文件 文件中定义Token后 mvn sonar:sonar# 方式3.采用 Sonar-scanner 方式进行扫描该Maven项目 sonar-scanner -Dsonar.projectNameJava-maven -Dsonar.projectKeyHello-World -Dsonar.sources. -Dsonar.java.binariestarget/# INFO: ANALYSIS SUCCESSFUL, you can browse http://sonarqube.weiyigeek.top/dashboard?idHello-World# INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report# INFO: More about the report processing at http://sonarqube.weiyigeek.top/api/ce/task?idAXa3PxQNr2pPEzGrpOU1# INFO: Analysis total time: 3.467 s# INFO: ------------------------------------------------------------------------# INFO: EXECUTION SUCCESS# INFO: ------------------------------------------------------------------------# INFO: Total time: 4.293s# INFO: Final Memory: 18M/163M# INFO: ------------------------------------------------------------------------ Step 4.查看 SonarQube 分析后的结果 插件收集 (1) sonar-pdf-report (质量分析报告插件): https://github.com/SonarQubeCommunity/sonar-pdf-report # Git拉取编译 git clone https://github.com/SonarQubeCommunity/sonar-pdf-report.git mvn clean package -Dmaven.test.skiptrue# [INFO] Replacing /home/weiyigeek/code/sonar-pdf-report/target/sonar-pdfreport-plugin-1.5-SNAPSHOT.jar $ ls -lh /home/weiyigeek/code/sonar-pdf-report/target/# -rw-r--r-- 1 weiyigeek weiyigeek 3.1M Dec 31 02:11 sonar-pdfreport-plugin-1.5-SNAPSHOT.jar 补充说明 (1) 多种构建技术调用检测 使用Maven执行SonarQube扫描 # 使用Maven执行SonarQube分析是非常简单的。只需要在你的项目目录下执行如下命令。 mvn sonar:sonar \-Dsonar.projectKeyJenkis \-Dsonar.host.urlhttp://sonar.weiyigeek.top:9000 \-Dsonar.login755eeb453cb28f96aa9d4ea14334da7287c2e840 使用Gradle执行SonarQube扫描 # (1) 使用Gradle执行SonarQube分析是非常简单的。只需要在你的codebuild.gradle/code文件中声明codeorg.sonarqube/code插件 plugins {id org.sonarqube version 3.0 }# (2) 然后执行如下命令 ./gradlew sonarqube \-Dsonar.projectKeyJenkis \-Dsonar.host.urlhttp://sonar.weiyigeek.top:9000 \-Dsonar.login755eeb453cb28f96aa9d4ea14334da7287c2e840 PS : 你需要查找当前版本的Gradle插件(http://sonar.weiyigeek.top:9000/documentation/analysis/scan/sonarscanner-for-gradle/) 使用MSBuild扫描器执行SonarQube扫描 # (1) 下载并解压SonarQube MSBuild扫描器将可执行程序的目录添加至code%PATH%/code环境变量 # http://sonar.weiyigeek.top:9000/documentation/analysis/scan/sonarscanner-for-msbuild/# (2) 使用MSBuild执行SonarQube分析是非常简单的。只需要在你的项目目录下执行如下命令。 SonarScanner.MSBuild.exe begin /k:Jenkis /d:sonar.host.urlhttp://sonar.weiyigeek.top:9000 /d:sonar.login755eeb453cb28f96aa9d4ea14334da7287c2e840# (3) 再次 MsBuild.exe /t:Rebuild SonarScanner.MSBuild.exe end /d:sonar.login755eeb453cb28f96aa9d4ea14334da7287c2e840 其他 (比如 JS, TS, Go, Python, PHP, …)执行SonarQube扫描 各大操作系统平台的scanner工具下载地址 Linux/Windows/Mac平台的扫描器http://sonar.weiyigeek.top:9000/documentation/analysis/scan/sonarscanner/ 分析调用 # Linux sonar-scanner \-Dsonar.projectKeyJenkis \-Dsonar.sources. \-Dsonar.host.urlhttp://sonar.weiyigeek.top:9000 \-Dsonar.login755eeb453cb28f96aa9d4ea14334da7287c2e840# Windows sonar-scanner.bat -Dsonar.projectKeyJenkis -Dsonar.sources. -Dsonar.host.urlhttp://sonar.weiyigeek.top:9000 -Dsonar.login755eeb453cb28f96aa9d4ea14334da7287c2e840 入坑出坑 问题1.ERROR: Error during SonarScanner execution Malformed input or input contains unmappable characters 问题原因: 操作系统字符集不支持中文, 需要安装相关的中文依赖; 解决办法: # 以Ubuntu为例 - apt-get update apt-get install -y locales - locale-gen en_US.UTF-8 - update-locale LC_ALLen_US.UTF-8 - export LANGen_US.UTF-8 参考地址: https://community.sonarsource.com/t/analysis-failed-with-malformed-input-or-input-contains-unmappable-characters/19452 -Dsonar.scm.providergit https://blog.csdn.net/huangli1466384630/article/details/85283766 ERROR: Error during SonarScanner execution java.lang.IllegalStateException: Can not execute Findbugsat org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:188)at org.sonar.plugins.findbugs.FindbugsSensor.execute(FindbugsSensor.java:114)at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:393)at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:389)at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)at com.sun.proxy.$Proxy0.execute(Unknown Source)at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)at org.sonarsource.scanner.cli.Main.execute(Main.java:112)at org.sonarsource.scanner.cli.Main.execute(Main.java:75)at org.sonarsource.scanner.cli.Main.main(Main.java:61) Caused by: java.lang.IllegalStateException: One (sub)project contains Java source files that are not compiled (/home/jenkins/agent/workspace/info_manage_rebuild).at org.sonar.plugins.findbugs.FindbugsConfiguration.getFindbugsProject(FindbugsConfiguration.java:123)at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:119)... 31 more ERROR: ERROR: Re-run SonarScanner using the -X switch to enable full debug logging. https://blog.csdn.net/melody_hahaha/article/details/80567624 解决sonar scanner扫描报错Please provide compiled classes of your project with sonar.java.binaries property
http://www.tj-hxxt.cn/news/135466.html

相关文章:

  • 怎么自己建立网站及建立网站方法辽宁网站建设学校
  • 360网站导航公司地址怎么做网页制作教程田田田田田田田田田田田田田田
  • 网站发布新闻的好处 seowordpress theme 权限
  • 网站的在线支付怎么做哈尔滨建站流程
  • 哪些是+joomla做的网站网站后台seo优化如何做
  • 专业外贸网站建设_诚信_青岛微信开放平台怎么跳过
  • 桂林商品房做民宿在哪个网站登记好wordpress用户邮箱验证失败
  • 医院网站建设与维护题库凡客建站登陆
  • 莆田专业网站建设公司价格沈阳的网站制作公司
  • 怎样用文本建一个网站怎么做外国网站流量
  • 贵卅省住房和城乡建设厅网站设计网站大全下载
  • 网络教学网站建设公司名称logo设计
  • 保山网站制作用div做网站中间部分
  • 手机网站 制作wordpress信息流主题
  • 河北邢台官方网站wordpress手机页面没有注册
  • 黄村网站建设价格常见的三种网站类型
  • 怎让做淘宝网站微商城开发用华网天下首选
  • 网站升级维护需要多久信息流广告代理公司排名
  • 网站公司排行榜长沙微信群
  • 色一把做最好的网站南宁制作网站服务商
  • 武进网站建设机构做名宿比较好的网站
  • 网站收款即时到账怎么做的如何选择南京网站建设
  • 品牌网站建设内容网站开发服务计入什么科目
  • 怎么给网站刷流量wordpress编辑器自动加p标签
  • 唐山公司网站建设 中企动力济南哪家公司做网站好
  • 深圳市网站建设制作设计品牌怎么自己做彩票网站
  • 网站自动更新时间代码wordpress哪个主题适合做网址导航
  • 哪些网站有搜索引擎作弊的呼和浩特公司做网站
  • 青岛设计网站的公司哪家好下载的网站模板怎么编辑
  • 网站建设绿茶a站怎么进