DevOps服务拉去Sonar信息问题

  • Choerodon平台版本:0.25.5

  • 运行环境:自主搭建

  • 问题描述:

    DevOps服务拉取sonar扫描结果,8.0以上版本sonar会报错。无法拉取信息

  • 执行的操作:

    升级Sonarqube到8.5以解决质量门问题,升级后DevOps服务无法正常拉取扫描结果

  • 报错信息(请尽量使用代码块或系统截图的形式展现):

    错误日志如下:

2021-06-30 11:06:40.266  WARN 9 --- [nio-8060-exec-5] o.h.core.exception.BaseExceptionHandler  : Common exception, Request: {URI=/v1/projects/1/app_service/52/sonarqube, method=public org.springframework.http.ResponseEntity<io.choerodon.devops.api.vo.SonarContentsVO> io.choerodon.devops.api.controller.v1.AppServiceController.getSonarQube(java.lang.Long,java.lang.Long)}, User: CustomUserDetails{userId=349, username=xmcai, roleId=10, roleIds=[10, 12], siteRoleIds=[], tenantRoleIds=[10, 12], roleMergeFlag=true, tenantId=1, tenantIds=[1], organizationId=1, isAdmin=true, clientId=null, timeZone='CTT, language='zh_CN, roleLabels='[TENANT_ROLE, GITLAB_OWNER, PROJECT_ADMIN, TENANT_ADMIN, PROJECT_ROLE], apiEncryptFlag=0}
io.choerodon.core.exception.CommonException: {"errors":[{"msg":"The 'component' parameter is missing"}]}
   at io.choerodon.devops.app.service.impl.AppServiceServiceImpl.getSonarContent(AppServiceServiceImpl.java:1385)
   at io.choerodon.devops.app.service.impl.AppServiceServiceImpl$$FastClassBySpringCGLIB$$e2351bf.invoke(<generated>)
   at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
   at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684)
   at io.choerodon.devops.app.service.impl.AppServiceServiceImpl$$EnhancerBySpringCGLIB$$812ef545.getSonarContent(<generated>)
   at io.choerodon.devops.api.controller.v1.AppServiceController.getSonarQube(AppServiceController.java:536)
   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)
  • 建议:

    查询了下SonarQube的API: GET api/measures/component
    其参数component由7.9版本的可选,变成了必须。
    代码中给给出的参数是** queryContentMap.put(“componentKey”, key); **
    对于这个参数,是否应该替换成7.6以后版本,改用component,这样可以兼容后续版本~

1赞