diff --git a/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/config/CodeSignProperties.kt b/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/config/CodeSignProperties.kt deleted file mode 100644 index 5678fc65088..00000000000 --- a/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/config/CodeSignProperties.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. - * - * A copy of the MIT License is included in this file. - * - * - * Terms of the MIT License: - * --------------------------------------------------- - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of - * the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT - * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package com.tencent.devops.sign.config - -import org.springframework.boot.context.properties.ConfigurationProperties -import org.springframework.boot.context.properties.ConstructorBinding - -@ConstructorBinding -@ConfigurationProperties(prefix = "codesign") -class CodeSignProperties { - val paths: Map? = null -} diff --git a/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/impl/SignServiceImpl.kt b/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/impl/SignServiceImpl.kt index 4e6eb153af9..06dc44bb078 100644 --- a/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/impl/SignServiceImpl.kt +++ b/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/impl/SignServiceImpl.kt @@ -40,7 +40,6 @@ import com.tencent.devops.sign.api.pojo.IpaInfoPlist import com.tencent.devops.sign.api.pojo.IpaSignInfo import com.tencent.devops.sign.api.pojo.MobileProvisionInfo import com.tencent.devops.sign.api.pojo.SignDetail -import com.tencent.devops.sign.config.CodeSignProperties import com.tencent.devops.sign.service.ArchiveService import com.tencent.devops.sign.service.FileService import com.tencent.devops.sign.service.MobileProvisionService @@ -51,27 +50,31 @@ import com.tencent.devops.sign.utils.SignUtils.APP_INFO_PLIST_FILENAME import com.tencent.devops.sign.utils.SignUtils.MAIN_APP_FILENAME import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Service import java.io.File import java.io.InputStream import java.util.regex.Pattern @Service -@EnableConfigurationProperties(CodeSignProperties::class) @Suppress("TooManyFunctions") class SignServiceImpl @Autowired constructor( private val fileService: FileService, private val signInfoService: SignInfoService, private val archiveService: ArchiveService, - private val mobileProvisionService: MobileProvisionService, - private val codeSignProperties: CodeSignProperties + private val mobileProvisionService: MobileProvisionService ) : SignService { companion object { private val logger = LoggerFactory.getLogger(SignServiceImpl::class.java) const val DEFAULT_CODESIGN_PATH = "/usr/bin/codesign" } + @Value("\${codesign.paths.version1:#{null}}") + private val codesignPathVersion1: String? = null + + @Value("\${codesign.paths.version2:#{null}}") + private val codesignPathVersion2: String? = null + override fun uploadIpaAndDecodeInfo( resignId: String, ipaSignInfo: IpaSignInfo, @@ -483,11 +486,12 @@ class SignServiceImpl @Autowired constructor( } private fun getCodeSignFile(version: String?): String { - logger.info("SIGN| codeSignProperties=$codeSignProperties") - return if (version.isNullOrBlank()) { - DEFAULT_CODESIGN_PATH - } else { - codeSignProperties.paths?.get(version) ?: DEFAULT_CODESIGN_PATH + logger.info("SIGN|codesignPathVersion1=$codesignPathVersion1" + + "|codesignPathVersion2=$codesignPathVersion2") + return when (version) { + "version1" -> codesignPathVersion1 ?: DEFAULT_CODESIGN_PATH + "version2" -> codesignPathVersion2 ?: DEFAULT_CODESIGN_PATH + else -> DEFAULT_CODESIGN_PATH } } } diff --git a/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/service/AsyncSignService.kt b/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/service/AsyncSignService.kt index 7ca7a2dd85d..4e880c3fdcd 100644 --- a/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/service/AsyncSignService.kt +++ b/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/service/AsyncSignService.kt @@ -61,7 +61,7 @@ class AsyncSignService( taskPoolSize ?: DEFAULT_TASK_POOL_SIZE, 0L, TimeUnit.MILLISECONDS, - LinkedBlockingQueue(taskQueueSize ?: 5) + LinkedBlockingQueue(taskQueueSize ?: DEFAULT_TASK_QUEUE_SIZE) ) fun asyncSign( @@ -74,7 +74,12 @@ class AsyncSignService( signExecutorService.execute { val start = LocalDateTime.now() logger.info("[$resignId] asyncSign start") - val success = signService.signIpaAndArchive(resignId, ipaSignInfo, ipaFile, taskExecuteCount) + val success = signService.signIpaAndArchive( + resignId = resignId, + ipaSignInfo = ipaSignInfo, + ipaFile = ipaFile, + taskExecuteCount = taskExecuteCount + ) logger.info("[$resignId] asyncSign finished with success:$success") signBean.signTaskFinish( elapse = LocalDateTime.now().timestampmilli() - start.timestampmilli(), @@ -107,7 +112,7 @@ class AsyncSignService( override fun destroy() { // 当有签名任务执行时,阻塞服务的退出 signExecutorService.shutdown() - while (!signExecutorService.awaitTermination(5, TimeUnit.SECONDS)) { + while (!signExecutorService.awaitTermination(EXECUTOR_DESTROY_AWAIT_SECOND, TimeUnit.SECONDS)) { logger.warn("SignTaskBean still has sign tasks.") } } @@ -126,5 +131,7 @@ class AsyncSignService( companion object { private val logger = LoggerFactory.getLogger(AsyncSignService::class.java) const val DEFAULT_TASK_POOL_SIZE = 10 + const val DEFAULT_TASK_QUEUE_SIZE = 5 + const val EXECUTOR_DESTROY_AWAIT_SECOND = 5L } }