diff --git a/src/backend/ci/core/common/common-codecc/src/main/kotlin/com/tencent/devops/plugin/codecc/CodeCCAutoConfiguration.kt b/src/backend/ci/core/common/common-codecc/src/main/kotlin/com/tencent/devops/plugin/codecc/CodeCCAutoConfiguration.kt index 6fa2eee13bd..c5a92c87b18 100644 --- a/src/backend/ci/core/common/common-codecc/src/main/kotlin/com/tencent/devops/plugin/codecc/CodeCCAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-codecc/src/main/kotlin/com/tencent/devops/plugin/codecc/CodeCCAutoConfiguration.kt @@ -46,16 +46,12 @@ class CodeCCAutoConfiguration { codeccApiProxyGateWay: String = "", @Value("\${codecc.host:}") - codeccHost: String = "", - - @Value("\${codecc.gray.projectId:}") - codeccGrayProjectId: String? = null + codeccHost: String = "" ): CodeccApi = CodeccApi( codeccApiUrl = codeccApiGateWay, codeccApiProxyUrl = codeccApiProxyGateWay, - codeccHost = codeccHost, - codeccGrayProjectId = codeccGrayProjectId + codeccHost = codeccHost ) } diff --git a/src/backend/ci/core/common/common-codecc/src/main/kotlin/com/tencent/devops/plugin/codecc/CodeccApi.kt b/src/backend/ci/core/common/common-codecc/src/main/kotlin/com/tencent/devops/plugin/codecc/CodeccApi.kt index 7b7be901397..581d0ff231b 100644 --- a/src/backend/ci/core/common/common-codecc/src/main/kotlin/com/tencent/devops/plugin/codecc/CodeccApi.kt +++ b/src/backend/ci/core/common/common-codecc/src/main/kotlin/com/tencent/devops/plugin/codecc/CodeccApi.kt @@ -31,7 +31,7 @@ import com.fasterxml.jackson.module.kotlin.readValue import com.tencent.devops.common.api.auth.AUTH_HEADER_CODECC_OPENAPI_TOKEN import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_PROJECT_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID -import com.tencent.devops.common.api.auth.AUTH_HEADER_PROJECT_ID +import com.tencent.devops.common.api.auth.AUTH_HEADER_GATEWAY_TAG import com.tencent.devops.common.api.exception.RemoteServiceException import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.api.util.JsonUtil @@ -50,8 +50,7 @@ import org.springframework.beans.factory.annotation.Value class CodeccApi( private val codeccApiUrl: String, private val codeccApiProxyUrl: String, - private val codeccHost: String, - private val codeccGrayProjectId: String? = null + private val codeccHost: String ) { @Value("\${codecc.openapi.token:#{null}}") @@ -189,11 +188,11 @@ class CodeccApi( return objectMapper.readValue(result) } - fun getCodeccOpensourceMeasurement(atomCodeSrc: String): Result> { + fun getCodeccOpensourceMeasurement(atomCodeSrc: String, tag: String? = null): Result> { val url = "http://$codeccHost/ms/openapi/api/open/v2/defect/opensource/measurement?url=$atomCodeSrc" val headers = mutableMapOf() - if (!codeccGrayProjectId.isNullOrBlank()) { - headers[AUTH_HEADER_PROJECT_ID] = codeccGrayProjectId + if (!tag.isNullOrBlank()) { + headers[AUTH_HEADER_GATEWAY_TAG] = tag headers[AUTH_HEADER_CODECC_OPENAPI_TOKEN] = codeccOpenApiToken } val httpReq = Request.Builder()