diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineResourceVersionDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineResourceVersionDao.kt index a80262393b2..2f7c4ee757e 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineResourceVersionDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineResourceVersionDao.kt @@ -32,12 +32,15 @@ import com.tencent.devops.common.api.util.timestampmilli import com.tencent.devops.common.pipeline.Model import com.tencent.devops.common.pipeline.enums.BranchVersionAction import com.tencent.devops.common.pipeline.enums.VersionStatus +import com.tencent.devops.model.process.Tables.T_PIPELINE_RESOURCE import com.tencent.devops.model.process.Tables.T_PIPELINE_RESOURCE_VERSION import com.tencent.devops.model.process.tables.records.TPipelineResourceVersionRecord import com.tencent.devops.process.engine.pojo.PipelineInfo import com.tencent.devops.process.pojo.pipeline.PipelineResourceVersion +import com.tencent.devops.process.pojo.setting.PipelineModelVersion import com.tencent.devops.process.pojo.setting.PipelineVersionSimple import com.tencent.devops.process.utils.PipelineVersionUtils +import org.jooq.Condition import org.jooq.DSLContext import org.jooq.RecordMapper import org.jooq.impl.DSL @@ -513,6 +516,27 @@ class PipelineResourceVersionDao { } } + fun updatePipelineModel( + dslContext: DSLContext, + userId: String, + pipelineModelVersion: PipelineModelVersion + ) { + with(T_PIPELINE_RESOURCE_VERSION) { + val conditions = mutableListOf() + conditions.add(PROJECT_ID.eq(pipelineModelVersion.projectId)) + conditions.add(PIPELINE_ID.eq(pipelineModelVersion.pipelineId)) + val version = pipelineModelVersion.version + if (version != null) { + conditions.add(VERSION.eq(version)) + } + dslContext.update(this) + .set(MODEL, pipelineModelVersion.model) + .set(CREATOR, userId) + .where(conditions) + .execute() + } + } + fun updateSettingVersion( dslContext: DSLContext, userId: String, diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index 5e012887f1e..f9479fd6ef5 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -1782,7 +1782,11 @@ class PipelineRepositoryService constructor( ) .addAttribute(ActionAuditContent.PROJECT_CODE_TEMPLATE, pipelineModelVersion.projectId) .scopeId = pipelineModelVersion.projectId - pipelineResourceDao.updatePipelineModel(dslContext, userId, pipelineModelVersion) + dslContext.transaction { configuration -> + val transactionContext = DSL.using(configuration) + pipelineResourceDao.updatePipelineModel(transactionContext, userId, pipelineModelVersion) + pipelineResourceVersionDao.updatePipelineModel(transactionContext, userId, pipelineModelVersion) + } } finally { lock.unlock() } diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/dao/StoreBaseEnvQueryDao.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/dao/StoreBaseEnvQueryDao.kt index b88953ede6b..24d68458244 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/dao/StoreBaseEnvQueryDao.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/dao/StoreBaseEnvQueryDao.kt @@ -57,6 +57,22 @@ class StoreBaseEnvQueryDao { } } + fun getDefaultBaseEnvInfo( + dslContext: DSLContext, + storeId: String, + osName: String? = null + ): TStoreBaseEnvRecord? { + return with(TStoreBaseEnv.T_STORE_BASE_ENV) { + val conditions = mutableListOf() + conditions.add(STORE_ID.eq(storeId)) + conditions.add(DEFAULT_FLAG.eq(true)) + if (!osName.isNullOrBlank()) { + conditions.add(OS_NAME.eq(osName)) + } + dslContext.selectFrom(this).where(conditions).limit(1).fetchOne() + } + } + fun batchQueryStoreLanguage(dslContext: DSLContext, storeIds: List): Result> { with(TStoreBaseEnv.T_STORE_BASE_ENV) { return dslContext.select(ID, LANGUAGE).from(this) diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/SensitiveApiServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/SensitiveApiServiceImpl.kt index a3c12834bcd..8dcd0a3e81f 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/SensitiveApiServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/SensitiveApiServiceImpl.kt @@ -259,13 +259,11 @@ class SensitiveApiServiceImpl @Autowired constructor( params = arrayOf("$storeType:$storeCode:$version") ) val baseEnvRecord = storeBaseEnvQueryDao.getBaseEnvsByStoreId( - dslContext = dslContext, - storeId = storeId, - osName = osName, - osArch = osArch - )?.getOrNull(0) ?: throw ErrorCodeException( - errorCode = CommonMessageCode.PARAMETER_IS_INVALID, - params = arrayOf("$osName:$osArch") + dslContext = dslContext, storeId = storeId, osName = osName, osArch = osArch + )?.getOrNull(0) ?: storeBaseEnvQueryDao.getDefaultBaseEnvInfo( + dslContext = dslContext, storeId = storeId, osName = osName + ) ?: storeBaseEnvQueryDao.getDefaultBaseEnvInfo(dslContext, storeId) ?: throw ErrorCodeException( + errorCode = CommonMessageCode.PARAMETER_IS_INVALID, params = arrayOf("$osName:$osArch") ) val dbFileShaContent = storeBaseEnvExtQueryDao.getBaseExtEnvsByEnvId( dslContext = dslContext,