diff --git a/src/backend/ci/ext/tencent/artifactory/biz-artifactory-tencent/src/main/kotlin/com/tencent/devops/artifactory/service/bkrepo/BkRepoService.kt b/src/backend/ci/ext/tencent/artifactory/biz-artifactory-tencent/src/main/kotlin/com/tencent/devops/artifactory/service/bkrepo/BkRepoService.kt index d89a6fbc567..c716e8bcf91 100644 --- a/src/backend/ci/ext/tencent/artifactory/biz-artifactory-tencent/src/main/kotlin/com/tencent/devops/artifactory/service/bkrepo/BkRepoService.kt +++ b/src/backend/ci/ext/tencent/artifactory/biz-artifactory-tencent/src/main/kotlin/com/tencent/devops/artifactory/service/bkrepo/BkRepoService.kt @@ -179,7 +179,7 @@ class BkRepoService @Autowired constructor( ) { logger.info( "setProperties, userId: $userId, projectId: $projectId, artifactoryType: $artifactoryType, " + - "argPath: $argPath, properties: $properties" + "argPath: $argPath, properties: $properties" ) if (properties.isEmpty()) { logger.info("property empty") @@ -197,7 +197,7 @@ class BkRepoService @Autowired constructor( ): List { logger.info( "getProperties, userId: $userId, projectId: $projectId, artifactoryType: $artifactoryType," + - " path: $path" + " path: $path" ) val normalizedPath = PathUtils.checkAndNormalizeAbsPath(path) val matadataMap = @@ -229,8 +229,8 @@ class BkRepoService @Autowired constructor( ): List { logger.info( "getPropertiesByRegex, projectId: $projectId, pipelineId: $pipelineId, buildId: $buildId, " + - "artifactoryType: $artifactoryType, argPath: $argPath, crossProjectId: $crossProjectId, " + - "crossPipineId: $crossPipineId, crossBuildNo: $crossBuildNo" + "artifactoryType: $artifactoryType, argPath: $argPath, crossProjectId: $crossProjectId, " + + "crossPipineId: $crossPipineId, crossBuildNo: $crossBuildNo" ) var targetProjectId = projectId @@ -249,10 +249,10 @@ class BkRepoService @Autowired constructor( channelCode = ChannelCode.BS ).data targetBuildId = (targetBuild ?: throw BadRequestException( - I18nUtil.getCodeLanMessage( - messageCode = BUILD_NOT_EXIST, - params = arrayOf(crossBuildNo) - ) + I18nUtil.getCodeLanMessage( + messageCode = BUILD_NOT_EXIST, + params = arrayOf(crossBuildNo) + ) )).id } } @@ -333,7 +333,7 @@ class BkRepoService @Autowired constructor( ): List { logger.info( "getBuildFileList, userId: $userId, projectId: $projectId," + - " pipelineId: $pipelineId, buildId: $buildId" + " pipelineId: $pipelineId, buildId: $buildId" ) pipelineService.validatePermission( userId, @@ -457,9 +457,9 @@ class BkRepoService @Autowired constructor( if (!metadataMap.containsKey(ARCHIVE_PROPS_PIPELINE_ID) || metadataMap[ARCHIVE_PROPS_PIPELINE_ID].isNullOrBlank()) { throw BadRequestException( I18nUtil.getCodeLanMessage( - messageCode = METADATA_NOT_EXIST, - params = arrayOf("pipelineId") - ) + messageCode = METADATA_NOT_EXIST, + params = arrayOf("pipelineId") + ) ) } val pipelineId = metadataMap[ARCHIVE_PROPS_PIPELINE_ID] @@ -532,7 +532,7 @@ class BkRepoService @Autowired constructor( logger.info( "pipelineHasPermissionList.contains(pipelineId):" + - " ${(!checkPermission || pipelineHasPermissionList.contains(pipelineId))}" + " ${(!checkPermission || pipelineHasPermissionList.contains(pipelineId))}" ) if ((!checkPermission || pipelineHasPermissionList.contains(pipelineId)) && pipelineIdToNameMap.containsKey(pipelineId) && buildIdToNameMap.containsKey(buildId) @@ -540,26 +540,15 @@ class BkRepoService @Autowired constructor( val pipelineName = pipelineIdToNameMap[pipelineId]!! val buildName = buildIdToNameMap[buildId]!! fileInfoList.add( - FileInfo( - name = it.name, - fullName = pipelineService.getFullName( - it.fullPath, - pipelineId, - pipelineName, - buildId, - buildName - ), - path = it.fullPath, - fullPath = it.fullPath, - size = it.size, - folder = it.folder, - modifiedTime = LocalDateTime.parse(it.lastModifiedDate, DateTimeFormatter.ISO_DATE_TIME) - .timestamp(), - artifactoryType = RepoUtils.getTypeByRepo(it.repoName), + buildPipelineArtifactInfo( + nodeInfo = it, + pipelineId = pipelineId, + pipelineName = pipelineName, + buildId = buildId, + buildName = buildName, properties = properties, appVersion = appVersion, - shortUrl = shortUrl, - md5 = it.md5 + shortUrl = shortUrl ) ) } @@ -575,25 +564,51 @@ class BkRepoService @Autowired constructor( } } - private fun buildCustomArtifactInfo( + private fun buildPipelineArtifactInfo( nodeInfo: QueryNodeInfo, + pipelineId: String, + pipelineName: String, + buildId: String, + buildName: String, properties: List, - appVersion: String? + appVersion: String?, + shortUrl: String ): FileInfo { - // 归档插件归档目录时,在目录多归档一个.bkci_pipeline文件, 记录归档目录的信息 return if (nodeInfo.name == ".bkci_pipeline") { + buildFolderArtifactInfo(nodeInfo, properties) + } else { FileInfo( - name = nodeInfo.path.split("/").last { it.isNotBlank() }, - fullName = nodeInfo.path, - path = nodeInfo.path, - fullPath = nodeInfo.path, + name = nodeInfo.name, + fullName = pipelineService.getFullName( + nodeInfo.fullPath, + pipelineId, + pipelineName, + buildId, + buildName + ), + path = nodeInfo.fullPath, + fullPath = nodeInfo.fullPath, size = nodeInfo.size, - folder = true, + folder = nodeInfo.folder, modifiedTime = LocalDateTime.parse(nodeInfo.lastModifiedDate, DateTimeFormatter.ISO_DATE_TIME) .timestamp(), artifactoryType = RepoUtils.getTypeByRepo(nodeInfo.repoName), - properties = properties + properties = properties, + appVersion = appVersion, + shortUrl = shortUrl, + md5 = nodeInfo.md5 ) + } + } + + private fun buildCustomArtifactInfo( + nodeInfo: QueryNodeInfo, + properties: List, + appVersion: String? + ): FileInfo { + // 归档插件归档目录时,在目录多归档一个.bkci_pipeline文件, 记录归档目录的信息 + return if (nodeInfo.name == ".bkci_pipeline") { + buildFolderArtifactInfo(nodeInfo, properties) } else { FileInfo( name = nodeInfo.name, @@ -612,6 +627,21 @@ class BkRepoService @Autowired constructor( } } + private fun buildFolderArtifactInfo(nodeInfo: QueryNodeInfo, properties: List): FileInfo { + return FileInfo( + name = nodeInfo.path.split("/").last { it.isNotBlank() }, + fullName = nodeInfo.path, + path = nodeInfo.path, + fullPath = nodeInfo.path, + size = nodeInfo.size, + folder = true, + modifiedTime = LocalDateTime.parse(nodeInfo.lastModifiedDate, DateTimeFormatter.ISO_DATE_TIME) + .timestamp(), + artifactoryType = RepoUtils.getTypeByRepo(nodeInfo.repoName), + properties = properties + ) + } + private fun buildImageArtifactInfo(manifestInfo: QueryNodeInfo): FileInfo { with(manifestInfo) { val (imageName, version) = PathUtils.getImageNameAndVersion(fullPath) @@ -778,7 +808,7 @@ class BkRepoService @Autowired constructor( ): String { logger.info( "externalDownloadUrl, creatorId: $creatorId, userId: $userId," + - " projectId: $projectId, artifactoryType: $artifactoryType, fullPath: $fullPath, ttl: $ttl" + " projectId: $projectId, artifactoryType: $artifactoryType, fullPath: $fullPath, ttl: $ttl" ) val shareUri = bkRepoClient.createShareUri( creatorId = creatorId,