From 9608f90ed9fa03da52a022d923dfc0b16f613719 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 1 Jun 2021 12:12:52 +0800 Subject: [PATCH 001/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/build.gradle.kts | 39 +++++++++++++++++-- .../ci/buildSrc/src/main/kotlin/Versions.kt | 21 ++++++++-- .../biz-artifactory/build.gradle.kts | 6 +-- .../ci/core/auth/model-auth/build.gradle.kts | 1 - .../core/common/common-api/build.gradle.kts | 10 ++--- .../common-auth-blueking/build.gradle.kts | 2 +- .../common-auth-mock/build.gradle.kts | 1 - .../common-auth-v3/build.gradle.kts | 5 +-- .../common/common-notify/build.gradle.kts | 2 +- .../core/common/common-scm/build.gradle.kts | 4 +- .../common/common-security/build.gradle.kts | 14 +++---- .../common/common-service/build.gradle.kts | 1 - .../core/common/common-test/build.gradle.kts | 2 +- .../core/common/common-util/build.gradle.kts | 2 +- .../biz-dockerhost/build.gradle.kts | 18 ++++----- .../boot-dockerhost/build.gradle.kts | 5 +-- .../biz-environment/build.gradle.kts | 6 +-- .../ci/core/image/biz-image/build.gradle.kts | 12 +++--- src/backend/ci/core/log/build.gradle.kts | 2 +- .../biz-monitoring/build.gradle.kts | 6 +-- .../core/notify/biz-notify/build.gradle.kts | 1 - .../core/openapi/biz-openapi/build.gradle.kts | 6 +-- .../openapi/boot-openapi/build.gradle.kts | 6 +-- .../ci/core/process/biz-base/build.gradle.kts | 13 ------- .../core/process/biz-process/build.gradle.kts | 2 +- .../core/process/boot-engine/build.gradle.kts | 4 -- .../process/plugin-trigger/build.gradle.kts | 5 +-- .../core/project/biz-project/build.gradle.kts | 2 +- .../biz-repository/build.gradle.kts | 2 +- .../model-repository/build.gradle.kts | 1 - .../ci/core/sign/api-sign/build.gradle.kts | 1 - .../ci/core/sign/biz-sign/build.gradle.kts | 3 +- .../ci/core/store/biz-store/build.gradle.kts | 2 +- .../websocket/biz-websocket/build.gradle.kts | 2 +- .../worker/worker-common/build.gradle.kts | 8 ++-- 35 files changed, 117 insertions(+), 100 deletions(-) diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index 77ca9a0afe3..e2963c2ce01 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -113,8 +113,6 @@ subprojects { } configure { - applyMavenExclusions(false) - imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${Versions.SpringBoot}") } @@ -144,7 +142,6 @@ subprojects { dependency("commons-codec:commons-codec:${Versions.CommonCodec}") dependency("org.jooq:jooq:${Versions.Jooq}") dependency("org.apache.lucene:lucene-core:${Versions.Lucene}") - dependency("io.jsonwebtoken:jjwt:${Versions.Jjwt}") dependency("org.mockito:mockito-all:${Versions.Mockito}") dependency("net.sf.json-lib:json-lib:${Versions.JsonLib}") dependency("com.cronutils:cron-utils:${Versions.CronUtils}") @@ -153,6 +150,42 @@ subprojects { dependency("com.tencent.devops.ci-plugins:sigar:${Versions.Sigar}") dependency("org.influxdb:influxdb-java:${Versions.InfluxDB}") dependency("com.github.ben-manes.caffeine:caffeine:${Versions.Caffeine}") + dependency("net.coobird:thumbnailator:${Versions.Thumbnailator}") + dependency("com.vdurmont:emoji-java:${Versions.EmojiJava}") + dependency("org.apache.commons:commons-csv:${Versions.CommonCsv}") + dependency("org.apache.commons:commons-collections4:${Versions.CommonCollections4}") + dependency("com.nhaarman:mockito-kotlin-kt1.1:${Versions.MockitoKt}") + dependency("org.tmatesoft.svnkit:svnkit:${Versions.Svnkit}") + dependency("org.eclipse.jgit:org.eclipse.jgit:${Versions.JGit}") + dependency("org.glassfish.jersey.containers:jersey-container-servlet:${Versions.Jersey}") + dependency("javax.websocket:javax.websocket-api:${Versions.WebSocketApi}") + dependency("com.googlecode.plist:dd-plist:${Versions.DdPlist}") + dependency("net.dongliu:apk-parser:${Versions.ApkParser}") + dependency("org.xerial:sqlite-jdbc:${Versions.SqlLiteJdbc}") + dependency("com.github.oshi:oshi-core:${Versions.OshiCore}") + + dependencySet("com.tencent.bkrepo:${Versions.TencentBkRepo}") { + entry("api-generic") + entry("api-repository") + } + + dependencySet("io.jsonwebtoken:${Versions.JJwt}") { + entry("jjwt-api") + entry("jjwt") + entry("jjwt-impl") + entry("jjwt-jackson") + } + + dependencySet("org.glassfish.jersey.core:${Versions.Jersey}") { + entry("jersey-client") + entry("jersey-server") + entry("jersey-common") + } + + dependencySet("com.github.docker-java:${Versions.DockerJava}") { + entry("docker-java") + entry("docker-java-transport-okhttp") + } dependencySet("org.springframework.cloud:${Versions.SpringConsul}") { entry("spring-cloud-starter-consul-discovery") diff --git a/src/backend/ci/buildSrc/src/main/kotlin/Versions.kt b/src/backend/ci/buildSrc/src/main/kotlin/Versions.kt index 343a1d9ed15..0df94cba851 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/Versions.kt +++ b/src/backend/ci/buildSrc/src/main/kotlin/Versions.kt @@ -11,13 +11,13 @@ object Versions { const val Elasticsearch = "7.0.0" const val HashIds = "1.0.3" const val Jaxrs = "2.0" - const val OkHttp = "3.9.1" + const val OkHttp = "3.14.4" const val Httpclient = "4.5.2" const val CommonExec = "1.3" const val Vmware = "5.1" const val BouncyCastle = "1.46" const val Dom4j = "1.6.1" - const val Compress = "1.15" + const val Compress = "1.16.1" const val Reflections = "0.9.11" const val JsonSchema = "2.2.6" const val Jasypt = "2.0.0" @@ -31,7 +31,6 @@ object Versions { const val Feign = "9.5.1" const val FeignForm = "3.8.0" const val Slf4j = "1.7.25" - const val Jjwt = "0.9.0" const val Mockito = "1.10.19" const val JsonLib = "2.4" const val CronUtils = "7.0.1" @@ -43,4 +42,20 @@ object Versions { const val Jolokia = "1.6.0" const val InfluxDB = "2.10" const val Caffeine = "2.8.8" + const val Thumbnailator = "0.4.8" + const val EmojiJava = "5.1.1" + const val CommonCsv = "1.8" + const val CommonCollections4 = "4.4" + const val MockitoKt = "1.6.0" + const val Svnkit = "1.9.3" + const val JGit = "5.0.2.201807311906-r" + const val JJwt = "0.10.8" + const val DockerJava = "3.2.5" + const val Jersey = "2.25.1" + const val WebSocketApi = "1.1" + const val DdPlist = "1.23" + const val ApkParser = "2.5.3" + const val SqlLiteJdbc = "3.23.1" + const val OshiCore = "3.4.0" + const val TencentBkRepo = "1.0.0" } diff --git a/src/backend/ci/core/artifactory/biz-artifactory/build.gradle.kts b/src/backend/ci/core/artifactory/biz-artifactory/build.gradle.kts index 3d316c79d83..6204204f78b 100644 --- a/src/backend/ci/core/artifactory/biz-artifactory/build.gradle.kts +++ b/src/backend/ci/core/artifactory/biz-artifactory/build.gradle.kts @@ -36,8 +36,8 @@ dependencies { api(project(":core:artifactory:model-artifactory")) api(project(":core:project:api-project")) api(project(":core:process:api-process")) - api("com.tencent.bkrepo:api-generic:1.0.0") - api("com.tencent.bkrepo:api-repository:1.0.0") + api("com.tencent.bkrepo:api-generic") + api("com.tencent.bkrepo:api-repository") api("com.amazonaws:aws-java-sdk-s3") - api("net.coobird:thumbnailator:0.4.8") + api("net.coobird:thumbnailator") } diff --git a/src/backend/ci/core/auth/model-auth/build.gradle.kts b/src/backend/ci/core/auth/model-auth/build.gradle.kts index 727a2c6f0a1..8d8a3964a48 100644 --- a/src/backend/ci/core/auth/model-auth/build.gradle.kts +++ b/src/backend/ci/core/auth/model-auth/build.gradle.kts @@ -27,5 +27,4 @@ plugins { `task-gen-jooq` - } diff --git a/src/backend/ci/core/common/common-api/build.gradle.kts b/src/backend/ci/core/common/common-api/build.gradle.kts index f60e198c7fb..fd8204fc7b1 100644 --- a/src/backend/ci/core/common/common-api/build.gradle.kts +++ b/src/backend/ci/core/common/common-api/build.gradle.kts @@ -37,19 +37,19 @@ dependencies { api("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") api("com.fasterxml.jackson.jaxrs:jackson-jaxrs-base") api("org.bouncycastle:bcprov-jdk16") - compile("com.github.fge:json-schema-validator") { + api("com.github.fge:json-schema-validator") { exclude(group = "javax.mail", module = "mailapi") exclude(group = "com.google.guava", module = "guava") } - compile("com.google.guava:guava") + api("com.google.guava:guava") api("com.squareup.okhttp3:okhttp") - api("commons-codec:commons-codec:1.9") + api("commons-codec:commons-codec") api("org.springframework.boot:spring-boot-starter-data-redis") api("org.apache.commons:commons-compress") api("org.apache.commons:commons-exec") api("javax.servlet:javax.servlet-api") api("javax.validation:validation-api") - api("com.vdurmont:emoji-java:5.1.1") + api("com.vdurmont:emoji-java") api("org.apache.lucene:lucene-core") - api("org.apache.commons:commons-csv:1.8") + api("org.apache.commons:commons-csv") } diff --git a/src/backend/ci/core/common/common-auth/common-auth-blueking/build.gradle.kts b/src/backend/ci/core/common/common-auth/common-auth-blueking/build.gradle.kts index 3899aa69ca5..91f3b1d38f8 100644 --- a/src/backend/ci/core/common/common-auth/common-auth-blueking/build.gradle.kts +++ b/src/backend/ci/core/common/common-auth/common-auth-blueking/build.gradle.kts @@ -38,5 +38,5 @@ dependencies { api("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") api("com.fasterxml.jackson.jaxrs:jackson-jaxrs-base") api("com.fasterxml.jackson.module:jackson-module-kotlin") - api(group = "org.json", name = "json", version = "20180130") + api("org.json:json") } diff --git a/src/backend/ci/core/common/common-auth/common-auth-mock/build.gradle.kts b/src/backend/ci/core/common/common-auth/common-auth-mock/build.gradle.kts index a36b3ab3f8f..68255093092 100644 --- a/src/backend/ci/core/common/common-auth/common-auth-mock/build.gradle.kts +++ b/src/backend/ci/core/common/common-auth/common-auth-mock/build.gradle.kts @@ -38,5 +38,4 @@ dependencies { api("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") api("com.fasterxml.jackson.jaxrs:jackson-jaxrs-base") api("com.fasterxml.jackson.module:jackson-module-kotlin") -// api(group: 'org.json', name: 'json', version: '20180130' } diff --git a/src/backend/ci/core/common/common-auth/common-auth-v3/build.gradle.kts b/src/backend/ci/core/common/common-auth/common-auth-v3/build.gradle.kts index 641759b39f7..c2ccdafaa66 100644 --- a/src/backend/ci/core/common/common-auth/common-auth-v3/build.gradle.kts +++ b/src/backend/ci/core/common/common-auth/common-auth-v3/build.gradle.kts @@ -39,8 +39,5 @@ dependencies { api("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") api("com.fasterxml.jackson.jaxrs:jackson-jaxrs-base") api("com.fasterxml.jackson.module:jackson-module-kotlin") - implementation(group = "org.apache.commons", name = "commons-collections4", version = "4.4") - - -// api(group="org.json", name="json", version="20180130" + implementation("org.apache.commons:commons-collections4") } diff --git a/src/backend/ci/core/common/common-notify/build.gradle.kts b/src/backend/ci/core/common/common-notify/build.gradle.kts index 4956b62393b..ebd7a2a8061 100644 --- a/src/backend/ci/core/common/common-notify/build.gradle.kts +++ b/src/backend/ci/core/common/common-notify/build.gradle.kts @@ -29,5 +29,5 @@ dependencies { api(project(":core:common:common-pipeline")) api(project(":core:common:common-web")) api("org.mockito:mockito-all") - api("com.nhaarman:mockito-kotlin-kt1.1:1.6.0") + api("com.nhaarman:mockito-kotlin-kt1.1") } diff --git a/src/backend/ci/core/common/common-scm/build.gradle.kts b/src/backend/ci/core/common/common-scm/build.gradle.kts index 62e72851ee3..c116aa18113 100644 --- a/src/backend/ci/core/common/common-scm/build.gradle.kts +++ b/src/backend/ci/core/common/common-scm/build.gradle.kts @@ -29,7 +29,7 @@ dependencies { api(project(":core:common:common-service")) api(project(":core:common:common-api")) api("org.slf4j:slf4j-api") - api("org.tmatesoft.svnkit:svnkit:1.9.3") + api("org.tmatesoft.svnkit:svnkit") api("com.squareup.okhttp3:okhttp") - api("org.eclipse.jgit:org.eclipse.jgit:5.0.2.201807311906-r") + api("org.eclipse.jgit:org.eclipse.jgit") } diff --git a/src/backend/ci/core/common/common-security/build.gradle.kts b/src/backend/ci/core/common/common-security/build.gradle.kts index 29165226022..0351b9b9749 100644 --- a/src/backend/ci/core/common/common-security/build.gradle.kts +++ b/src/backend/ci/core/common/common-security/build.gradle.kts @@ -28,12 +28,12 @@ dependencies { api(project(":core:common:common-util")) api(project(":core:common:common-service")) - implementation("com.google.guava:guava") - api(group = "org.springframework.boot", name = "spring-boot") - api(group = "org.springframework.boot", name = "spring-boot-autoconfigure") + api("org.springframework.boot:spring-boot") + api("org.springframework.boot:spring-boot-autoconfigure") + api("org.springframework.boot:spring-boot-configuration-processor") + api("io.jsonwebtoken:jjwt-api") implementation("org.springframework:spring-context") - api(group = "org.springframework.boot", name = "spring-boot-configuration-processor") - api("io.jsonwebtoken:jjwt-api:0.10.8") - runtimeOnly("io.jsonwebtoken:jjwt-impl:0.10.8") - runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.10.8") + implementation("com.google.guava:guava") + runtimeOnly("io.jsonwebtoken:jjwt-impl") + runtimeOnly("io.jsonwebtoken:jjwt-jackson") } diff --git a/src/backend/ci/core/common/common-service/build.gradle.kts b/src/backend/ci/core/common/common-service/build.gradle.kts index e2849a74906..c8802682426 100644 --- a/src/backend/ci/core/common/common-service/build.gradle.kts +++ b/src/backend/ci/core/common/common-service/build.gradle.kts @@ -35,7 +35,6 @@ dependencies { api("org.jolokia:jolokia-core") api("javax.servlet:javax.servlet-api") api("org.springframework:spring-web") - testImplementation("org.springframework.boot:spring-boot-starter-test") } diff --git a/src/backend/ci/core/common/common-test/build.gradle.kts b/src/backend/ci/core/common/common-test/build.gradle.kts index d4bf86656a7..06fba7688c3 100644 --- a/src/backend/ci/core/common/common-test/build.gradle.kts +++ b/src/backend/ci/core/common/common-test/build.gradle.kts @@ -27,5 +27,5 @@ dependencies { api("org.mockito:mockito-all") - api("com.nhaarman:mockito-kotlin-kt1.1:1.6.0") + api("com.nhaarman:mockito-kotlin-kt1.1") } diff --git a/src/backend/ci/core/common/common-util/build.gradle.kts b/src/backend/ci/core/common/common-util/build.gradle.kts index 5d275f66487..d625e1868af 100644 --- a/src/backend/ci/core/common/common-util/build.gradle.kts +++ b/src/backend/ci/core/common/common-util/build.gradle.kts @@ -27,10 +27,10 @@ dependencies { api(project(":core:common:common-api")) + api("org.apache.commons:commons-lang3") implementation("commons-codec:commons-codec") implementation("com.google.guava:guava") implementation("org.jolokia:jolokia-core") - api("org.apache.commons:commons-lang3") compileOnly("org.projectlombok:lombok") annotationProcessor("org.projectlombok:lombok") } diff --git a/src/backend/ci/core/dockerhost/biz-dockerhost/build.gradle.kts b/src/backend/ci/core/dockerhost/biz-dockerhost/build.gradle.kts index 7bb0308b93a..7f3def0acca 100644 --- a/src/backend/ci/core/dockerhost/biz-dockerhost/build.gradle.kts +++ b/src/backend/ci/core/dockerhost/biz-dockerhost/build.gradle.kts @@ -31,14 +31,14 @@ dependencies { api(project(":core:dockerhost:api-dockerhost")) api(project(":core:process:api-process")) api(project(":core:store:api-store-image")) - api(group = "com.github.docker-java", name = "docker-java", version = "3.2.5") - api(group = "com.github.docker-java", name = "docker-java-transport-okhttp", version = "3.2.5") - api(group = "org.apache.httpcomponents", name = "httpclient", version = "4.5.2") - api(group = "org.glassfish.jersey.core", name = "jersey-client", version = "2.25.1") - api(group = "org.glassfish.jersey.containers", name = "jersey-container-servlet", version = "2.25.1") - api(group = "org.glassfish.jersey.core", name = "jersey-server", version = "2.25.1") - api(group = "org.glassfish.jersey.core", name = "jersey-common", version = "2.25.1") + api("com.github.docker-java:docker-java") + api("com.github.docker-java:docker-java-transport-okhttp") + api("org.apache.httpcomponents:httpclient") + api("org.glassfish.jersey.core:jersey-client") + api("org.glassfish.jersey.core:jersey-server") + api("org.glassfish.jersey.core:jersey-common") + api("org.glassfish.jersey.containers:jersey-container-servlet") api("org.slf4j:slf4j-api") - api("com.squareup.okhttp3:okhttp:3.14.4") - api(group = "com.tencent.devops.ci-plugins", name = "sigar") + api("com.squareup.okhttp3:okhttp") + api("com.tencent.devops.ci-plugins:sigar") } diff --git a/src/backend/ci/core/dockerhost/boot-dockerhost/build.gradle.kts b/src/backend/ci/core/dockerhost/boot-dockerhost/build.gradle.kts index adba0f83f1e..dc2d2c94216 100644 --- a/src/backend/ci/core/dockerhost/boot-dockerhost/build.gradle.kts +++ b/src/backend/ci/core/dockerhost/boot-dockerhost/build.gradle.kts @@ -27,11 +27,10 @@ dependencies { api(project(":core:dockerhost:biz-dockerhost")) - //api(project(":dockerhost:plugin-dockerhost-distcc") api(project(":core:dockerhost:plugin-dockerhost-codecc")) - api(("com.squareup.okhttp3:okhttp:3.14.4")) + api("com.squareup.okhttp3:okhttp") } plugins { - `task-spring-boot-package` + `task-spring-boot-package` } diff --git a/src/backend/ci/core/environment/biz-environment/build.gradle.kts b/src/backend/ci/core/environment/biz-environment/build.gradle.kts index bde05438ff5..f96e34e467c 100644 --- a/src/backend/ci/core/environment/biz-environment/build.gradle.kts +++ b/src/backend/ci/core/environment/biz-environment/build.gradle.kts @@ -38,7 +38,7 @@ dependencies { api(project(":core:common:common-auth:common-auth-api")) api(project(":core:common:common-db")) api(project(":core:common:common-websocket")) - api("org.apache.commons:commons-compress:1.15") - api("org.json:json:20140107") - api("org.influxdb:influxdb-java:2.10") + api("org.apache.commons:commons-compress") + api("org.json:json") + api("org.influxdb:influxdb-java") } diff --git a/src/backend/ci/core/image/biz-image/build.gradle.kts b/src/backend/ci/core/image/biz-image/build.gradle.kts index a11a77368dc..94046a6cb56 100644 --- a/src/backend/ci/core/image/biz-image/build.gradle.kts +++ b/src/backend/ci/core/image/biz-image/build.gradle.kts @@ -37,10 +37,10 @@ dependencies { api(project(":core:common:common-auth:common-auth-api")) api(project(":core:common:common-db")) api(project(":core:common:common-log")) - api(("org.apache.commons:commons-compress:1.16.1")) - api(group = "com.github.docker-java", name = "docker-java", version = "3.1.1") - api(group = "org.glassfish.jersey.core", name = "jersey-client", version = "2.25.1") - api(group = "org.glassfish.jersey.containers", name = "jersey-container-servlet", version = "2.25.1") - api(group = "org.glassfish.jersey.core", name = "jersey-server", version = "2.25.1") - api(group = "org.glassfish.jersey.core", name = "jersey-common", version = "2.25.1") + api("org.apache.commons:commons-compress") + api("com.github.docker-java:docker-java") + api("org.glassfish.jersey.core:jersey-client") + api("org.glassfish.jersey.core:jersey-server") + api("org.glassfish.jersey.core:jersey-common") + api("org.glassfish.jersey.containers:jersey-container-servlet") } diff --git a/src/backend/ci/core/log/build.gradle.kts b/src/backend/ci/core/log/build.gradle.kts index 0984a512e23..d4eba2f19da 100644 --- a/src/backend/ci/core/log/build.gradle.kts +++ b/src/backend/ci/core/log/build.gradle.kts @@ -28,7 +28,7 @@ subprojects { group = "com.tencent.bk.devops.ci.log" dependencies { - // 解决依赖冲突:process要求lucene-8.6.0,es-rest-client7.0.0要求lucene-8.0.0 + // FIXME 解决依赖冲突:process要求lucene-8.6.0,es-rest-client7.0.0要求lucene-8.0.0 api("org.apache.lucene:lucene-core:8.0.0") api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") api("org.jetbrains.kotlin:kotlin-reflect") diff --git a/src/backend/ci/core/monitoring/biz-monitoring/build.gradle.kts b/src/backend/ci/core/monitoring/biz-monitoring/build.gradle.kts index 20317133914..9b0531ebd6f 100644 --- a/src/backend/ci/core/monitoring/biz-monitoring/build.gradle.kts +++ b/src/backend/ci/core/monitoring/biz-monitoring/build.gradle.kts @@ -29,7 +29,7 @@ dependencies { api(project(":core:monitoring:api-monitoring")) api(project(":core:common:common-db")) api(project(":core:common:common-notify")) - api("org.apache.commons:commons-compress:1.15") - api("org.json:json:20140107") - api("org.influxdb:influxdb-java:2.10") + api("org.apache.commons:commons-compress") + api("org.json:json") + api("org.influxdb:influxdb-java") } diff --git a/src/backend/ci/core/notify/biz-notify/build.gradle.kts b/src/backend/ci/core/notify/biz-notify/build.gradle.kts index 3e5692e853a..a7707790ba4 100644 --- a/src/backend/ci/core/notify/biz-notify/build.gradle.kts +++ b/src/backend/ci/core/notify/biz-notify/build.gradle.kts @@ -28,7 +28,6 @@ dependencies { api(project(":core:notify:api-notify")) api(project(":core:notify:api-notify")) -// api(project(":ext:blueking:common:common-auth:common-auth-blueking") api(project(":core:notify:model-notify")) api(project(":core:common:common-db")) api(project(":core:common:common-notify")) diff --git a/src/backend/ci/core/openapi/biz-openapi/build.gradle.kts b/src/backend/ci/core/openapi/biz-openapi/build.gradle.kts index 65fbbb409d8..962b849d7e2 100644 --- a/src/backend/ci/core/openapi/biz-openapi/build.gradle.kts +++ b/src/backend/ci/core/openapi/biz-openapi/build.gradle.kts @@ -34,9 +34,9 @@ dependencies { api(project(":core:environment:api-environment")) api(project(":core:artifactory:api-artifactory-sample")) api(project(":core:common:common-client")) - api("io.jsonwebtoken:jjwt-api:0.10.8") - runtimeOnly("io.jsonwebtoken:jjwt-impl:0.10.8") - runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.10.8") + api("io.jsonwebtoken:jjwt-api") + runtimeOnly("io.jsonwebtoken:jjwt-impl") + runtimeOnly("io.jsonwebtoken:jjwt-jackson") api(group = "net.sf.json-lib", name = "json-lib", classifier = "jdk15") api("org.springframework.boot:spring-boot-starter-aop") } diff --git a/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts b/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts index 5c52c999581..34005c31349 100644 --- a/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts +++ b/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts @@ -29,9 +29,9 @@ dependencies { api(project(":core:openapi:biz-openapi")) api(group = "net.sf.json-lib", name = "json-lib", classifier = "jdk15") api("org.springframework.boot:spring-boot-starter-aop") - api("io.jsonwebtoken:jjwt-api:0.10.8") - runtime("io.jsonwebtoken:jjwt-impl:0.10.8") - runtime("io.jsonwebtoken:jjwt-jackson:0.10.8") + api("io.jsonwebtoken:jjwt-api") + runtimeOnly("io.jsonwebtoken:jjwt-impl") + runtimeOnly("io.jsonwebtoken:jjwt-jackson") } plugins { `task-spring-boot-package` diff --git a/src/backend/ci/core/process/biz-base/build.gradle.kts b/src/backend/ci/core/process/biz-base/build.gradle.kts index 32e387531a9..4a9ba443efa 100644 --- a/src/backend/ci/core/process/biz-base/build.gradle.kts +++ b/src/backend/ci/core/process/biz-base/build.gradle.kts @@ -28,31 +28,18 @@ dependencies { api(project(":core:process:plugin-load")) // Model检查 api(project(":core:common:common-service")) -// api(project(":core:common:common-web")) api(project(":core:common:common-client")) // 其他微服务调用 -// api(project(":core:common:common-redis")) api(project(":core:common:common-archive")) -// api(project(":core:common:common-log")) api(project(":core:common:common-db")) api(project(":core:common:common-websocket")) // 依赖websocket枚举 -// api(project(":core:store:api-store")) -// api(project(":core:store:api-store-image")) api(project(":core:dispatch:api-dispatch")) // Dispatch配额实现在dispatch,考虑移除 api(project(":core:project:api-project")) // 依赖读取项目VO -// api(project(":core:repository:api-repository")) -// api(project(":core:artifactory:api-artifactory")) api(project(":core:process:api-process")) api(project(":core:quality:api-quality")) // 质量红线API,考虑移除 -// api(project(":core:plugin:api-plugin")) api(project(":core:plugin:codecc-plugin:common-codecc")) // MarketBuildUtils依赖了CodeCC,考虑移除 api(project(":core:notify:api-notify")) // 消息通知API,考虑移除 api(project(":core:process:model-process")) - api("com.zaxxer:HikariCP") api("mysql:mysql-connector-java") -// api("org.springframework.boot:spring-boot-starter-websocket" -// api(group: 'javax.websocket', name: 'javax.websocket-api', version: '1.1' -// api("io.undertow:undertow-servlet" -// api("io.undertow:undertow-websockets-jsr" testImplementation(project(":core:common:common-test")) } diff --git a/src/backend/ci/core/process/biz-process/build.gradle.kts b/src/backend/ci/core/process/biz-process/build.gradle.kts index 1b41f68bfd3..47c135a278d 100644 --- a/src/backend/ci/core/process/biz-process/build.gradle.kts +++ b/src/backend/ci/core/process/biz-process/build.gradle.kts @@ -52,7 +52,7 @@ dependencies { api("com.zaxxer:HikariCP") api("mysql:mysql-connector-java") api("org.springframework.boot:spring-boot-starter-websocket") - api(group = "javax.websocket", name = "javax.websocket-api", version = "1.1") + api("javax.websocket:javax.websocket-api") api("io.undertow:undertow-servlet") api("io.undertow:undertow-websockets-jsr") testImplementation(project(":core:common:common-test")) diff --git a/src/backend/ci/core/process/boot-engine/build.gradle.kts b/src/backend/ci/core/process/boot-engine/build.gradle.kts index 30bf0db55c3..52f2d268337 100644 --- a/src/backend/ci/core/process/boot-engine/build.gradle.kts +++ b/src/backend/ci/core/process/boot-engine/build.gradle.kts @@ -28,7 +28,3 @@ dependencies { api(project(":core:process:biz-engine")) } - -//plugins { -// `task-spring-boot-package` -//} diff --git a/src/backend/ci/core/process/plugin-trigger/build.gradle.kts b/src/backend/ci/core/process/plugin-trigger/build.gradle.kts index 47e9bb57660..5e85d38bd5a 100644 --- a/src/backend/ci/core/process/plugin-trigger/build.gradle.kts +++ b/src/backend/ci/core/process/plugin-trigger/build.gradle.kts @@ -32,10 +32,7 @@ dependencies { api(project(":core:process:model-process")) api(project(":core:process:api-process")) api(project(":core:process:plugin-sdk")) - - implementation("org.quartz-scheduler:quartz") { - exclude(group = "com.zaxxer", module = "HikariCP-java7") - } + implementation("org.quartz-scheduler:quartz") } plugins { diff --git a/src/backend/ci/core/project/biz-project/build.gradle.kts b/src/backend/ci/core/project/biz-project/build.gradle.kts index 625b4414248..41d135eb1ab 100644 --- a/src/backend/ci/core/project/biz-project/build.gradle.kts +++ b/src/backend/ci/core/project/biz-project/build.gradle.kts @@ -38,5 +38,5 @@ dependencies { api(project(":core:artifactory:api-artifactory")) api("com.amazonaws:aws-java-sdk-s3") - api("net.coobird:thumbnailator:0.4.8") + api("net.coobird:thumbnailator") } diff --git a/src/backend/ci/core/repository/biz-repository/build.gradle.kts b/src/backend/ci/core/repository/biz-repository/build.gradle.kts index d27b5fd7ac5..8f93499e8fb 100644 --- a/src/backend/ci/core/repository/biz-repository/build.gradle.kts +++ b/src/backend/ci/core/repository/biz-repository/build.gradle.kts @@ -36,5 +36,5 @@ dependencies { api(project(":core:repository:api-repository")) api(project(":core:repository:model-repository")) api(project(":core:common:common-db")) - api("org.eclipse.jgit:org.eclipse.jgit:5.0.2.201807311906-r") + api("org.eclipse.jgit:org.eclipse.jgit") } diff --git a/src/backend/ci/core/repository/model-repository/build.gradle.kts b/src/backend/ci/core/repository/model-repository/build.gradle.kts index 727a2c6f0a1..8d8a3964a48 100644 --- a/src/backend/ci/core/repository/model-repository/build.gradle.kts +++ b/src/backend/ci/core/repository/model-repository/build.gradle.kts @@ -27,5 +27,4 @@ plugins { `task-gen-jooq` - } diff --git a/src/backend/ci/core/sign/api-sign/build.gradle.kts b/src/backend/ci/core/sign/api-sign/build.gradle.kts index bcd4e18fd7b..3864cc227a8 100644 --- a/src/backend/ci/core/sign/api-sign/build.gradle.kts +++ b/src/backend/ci/core/sign/api-sign/build.gradle.kts @@ -30,7 +30,6 @@ dependencies { api(project(":core:common:common-web")) } - plugins { `task-deploy-to-maven` } diff --git a/src/backend/ci/core/sign/biz-sign/build.gradle.kts b/src/backend/ci/core/sign/biz-sign/build.gradle.kts index be4f375ae1c..9869e1b6292 100644 --- a/src/backend/ci/core/sign/biz-sign/build.gradle.kts +++ b/src/backend/ci/core/sign/biz-sign/build.gradle.kts @@ -37,6 +37,5 @@ dependencies { api(project(":core:common:common-auth:common-auth-api")) api("mysql:mysql-connector-java") api("org.json:json") - api("com.googlecode.plist:dd-plist:1.23") -// api(project(":core:sign:model-sign")) + api("com.googlecode.plist:dd-plist") } diff --git a/src/backend/ci/core/store/biz-store/build.gradle.kts b/src/backend/ci/core/store/biz-store/build.gradle.kts index 54474d7feaf..69c912691a8 100644 --- a/src/backend/ci/core/store/biz-store/build.gradle.kts +++ b/src/backend/ci/core/store/biz-store/build.gradle.kts @@ -38,5 +38,5 @@ dependencies { api(project(":core:artifactory:api-artifactory-store")) api(project(":core:store:model-store")) testImplementation(project(":core:common:common-test")) - api("net.coobird:thumbnailator:0.4.8") + api("net.coobird:thumbnailator") } diff --git a/src/backend/ci/core/websocket/biz-websocket/build.gradle.kts b/src/backend/ci/core/websocket/biz-websocket/build.gradle.kts index 61042ac563a..4fd71a422f5 100644 --- a/src/backend/ci/core/websocket/biz-websocket/build.gradle.kts +++ b/src/backend/ci/core/websocket/biz-websocket/build.gradle.kts @@ -32,7 +32,7 @@ dependencies { api(project(":core:project:api-project")) api(project(":core:websocket:api-websocket")) api("org.springframework.boot:spring-boot-starter-websocket") - api(group = "javax.websocket", name = "javax.websocket-api", version = "1.1") + api("javax.websocket:javax.websocket-api") api("io.undertow:undertow-servlet") api("io.undertow:undertow-websockets-jsr") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") diff --git a/src/backend/ci/core/worker/worker-common/build.gradle.kts b/src/backend/ci/core/worker/worker-common/build.gradle.kts index 3966f685de5..3bcf1421d2c 100644 --- a/src/backend/ci/core/worker/worker-common/build.gradle.kts +++ b/src/backend/ci/core/worker/worker-common/build.gradle.kts @@ -39,10 +39,10 @@ dependencies { api("org.jetbrains.kotlin:kotlin-reflect") api("org.apache.commons:commons-exec") api("org.apache.commons:commons-compress") - api("com.github.oshi:oshi-core:3.4.0") - api(group = "com.googlecode.plist", name = "dd-plist", version = "1.20") - api(group = "net.dongliu", name = "apk-parser", version = "2.5.3") - api(group = "org.xerial", name = "sqlite-jdbc", version = "3.23.1") + api("com.github.oshi:oshi-core") + api("com.googlecode.plist:dd-plist") + api("net.dongliu:apk-parser") + api("org.xerial:sqlite-jdbc") api("ch.qos.logback:logback-core") api("ch.qos.logback:logback-classic") api(fileTree(mapOf("dir" to "lib/KillProcessTree.jar", "include" to listOf("*.jar")))) From 573bc423638ad2f6f43167138a53232d72d4b245 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 15 Jun 2021 16:58:01 +0800 Subject: [PATCH 002/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/buildSrc/gradle.properties | 94 ++++++++++----------- src/backend/ci/buildSrc/settings.gradle.kts | 1 - 2 files changed, 47 insertions(+), 48 deletions(-) delete mode 100644 src/backend/ci/buildSrc/settings.gradle.kts diff --git a/src/backend/ci/buildSrc/gradle.properties b/src/backend/ci/buildSrc/gradle.properties index 3c2ddb148a9..6f60486f68a 100644 --- a/src/backend/ci/buildSrc/gradle.properties +++ b/src/backend/ci/buildSrc/gradle.properties @@ -1,47 +1,47 @@ -# -# 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. -# -kotlin.incremental=true -systemProp.file.encoding=utf-8 -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -org.gradle.daemon=true -org.gradle.daemon.idleTimeout=3600000 -#systemProp.http.proxyHost= -#systemProp.http.proxyPort= -#systemProp.https.proxyHost= -#systemProp.https.proxyPort= -MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public -MAVEN_REPO_DEPLOY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -MAVEN_REPO_USERNAME= -MAVEN_REPO_PASSWORD= -MAVEN_REPO_SNAPSHOT_URL= -MAVEN_REPO_SNAPSHOT_DEPLOY_URL= -MAVEN_REPO_SNAPSHOT_USERNAME= -MAVEN_REPO_SNAPSHOT_PASSWORD= -DB_HOST=127.0.0.1:3306 -DB_USERNAME=root -DB_PASSWORD=root -DB_PREFIX=devops_ci_ +# +# 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. +# +kotlin.incremental=true +systemProp.file.encoding=utf-8 +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m +org.gradle.daemon=true +org.gradle.daemon.idleTimeout=3600000 +#systemProp.http.proxyHost= +#systemProp.http.proxyPort= +#systemProp.https.proxyHost= +#systemProp.https.proxyPort= +MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public +MAVEN_REPO_DEPLOY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/ +MAVEN_REPO_USERNAME= +MAVEN_REPO_PASSWORD= +MAVEN_REPO_SNAPSHOT_URL= +MAVEN_REPO_SNAPSHOT_DEPLOY_URL= +MAVEN_REPO_SNAPSHOT_USERNAME= +MAVEN_REPO_SNAPSHOT_PASSWORD= +DB_HOST=127.0.0.1:3306 +DB_USERNAME=root +DB_PASSWORD=root +DB_PREFIX=devops_ci_ diff --git a/src/backend/ci/buildSrc/settings.gradle.kts b/src/backend/ci/buildSrc/settings.gradle.kts deleted file mode 100644 index 46de7658a6b..00000000000 --- a/src/backend/ci/buildSrc/settings.gradle.kts +++ /dev/null @@ -1 +0,0 @@ -// 保留该文件 参考官网 : https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:build_sources From 934e019a3f1dfed32c908394d00410b71438bd80 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 16 Jun 2021 10:51:58 +0800 Subject: [PATCH 003/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/buildSrc/src/main/kotlin/constants/Libs.kt | 8 ++++++++ .../buildSrc/src/main/kotlin/{ => constants}/Versions.kt | 0 .../kotlin/{ => plugins}/task-deploy-to-maven.gradle.kts | 3 --- .../main/kotlin/{ => plugins}/task-gen-jooq.gradle.kts | 0 .../main/kotlin/{ => plugins}/task-shadow-jar.gradle.kts | 4 +--- .../{ => plugins}/task-spring-boot-package.gradle.kts | 8 -------- 6 files changed, 9 insertions(+), 14 deletions(-) create mode 100644 src/backend/ci/buildSrc/src/main/kotlin/constants/Libs.kt rename src/backend/ci/buildSrc/src/main/kotlin/{ => constants}/Versions.kt (100%) rename src/backend/ci/buildSrc/src/main/kotlin/{ => plugins}/task-deploy-to-maven.gradle.kts (99%) rename src/backend/ci/buildSrc/src/main/kotlin/{ => plugins}/task-gen-jooq.gradle.kts (100%) rename src/backend/ci/buildSrc/src/main/kotlin/{ => plugins}/task-shadow-jar.gradle.kts (99%) rename src/backend/ci/buildSrc/src/main/kotlin/{ => plugins}/task-spring-boot-package.gradle.kts (92%) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/constants/Libs.kt b/src/backend/ci/buildSrc/src/main/kotlin/constants/Libs.kt new file mode 100644 index 00000000000..0db82719d71 --- /dev/null +++ b/src/backend/ci/buildSrc/src/main/kotlin/constants/Libs.kt @@ -0,0 +1,8 @@ +object Libs { + const val KotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.Kotlin}" + const val KotlinReflectLib = "org.jetbrains.kotlin:kotlin-reflect:${Versions.Kotlin}" + const val KotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Kotlin}" + const val SpringBootGradlePlugin = "org.springframework.boot:spring-boot-gradle-plugin:${Versions.SpringBoot}" + const val DependencyManagement = "io.spring.gradle:dependency-management-plugin:${Versions.DependencyManagement}" + const val KotlinSpringGradlePlugin = "org.jetbrains.kotlin:kotlin-allopen:${Versions.Kotlin}" +} diff --git a/src/backend/ci/buildSrc/src/main/kotlin/Versions.kt b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt similarity index 100% rename from src/backend/ci/buildSrc/src/main/kotlin/Versions.kt rename to src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt diff --git a/src/backend/ci/buildSrc/src/main/kotlin/task-deploy-to-maven.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts similarity index 99% rename from src/backend/ci/buildSrc/src/main/kotlin/task-deploy-to-maven.gradle.kts rename to src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts index 0e987e862b2..b7c8b4c347b 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/task-deploy-to-maven.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts @@ -28,9 +28,6 @@ import java.net.URI plugins { - kotlin - maven - `kotlin-spring` `maven-publish` signing } diff --git a/src/backend/ci/buildSrc/src/main/kotlin/task-gen-jooq.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts similarity index 100% rename from src/backend/ci/buildSrc/src/main/kotlin/task-gen-jooq.gradle.kts rename to src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts diff --git a/src/backend/ci/buildSrc/src/main/kotlin/task-shadow-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-shadow-jar.gradle.kts similarity index 99% rename from src/backend/ci/buildSrc/src/main/kotlin/task-shadow-jar.gradle.kts rename to src/backend/ci/buildSrc/src/main/kotlin/plugins/task-shadow-jar.gradle.kts index b0dab44a72e..1336ea1efb0 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/task-shadow-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-shadow-jar.gradle.kts @@ -1,5 +1,3 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * @@ -26,9 +24,9 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar * 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. */ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { - kotlin id("com.github.johnrengelman.shadow") application } diff --git a/src/backend/ci/buildSrc/src/main/kotlin/task-spring-boot-package.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts similarity index 92% rename from src/backend/ci/buildSrc/src/main/kotlin/task-spring-boot-package.gradle.kts rename to src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts index e43e2ae83fe..23c8e0c4653 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/task-spring-boot-package.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts @@ -33,14 +33,6 @@ version = "" plugins { kotlin("jvm") - id("org.jetbrains.kotlin.plugin.spring") - id("org.springframework.boot") -} - -dependencies { - api(project(":core:common:common-api")) - api(project(":core:common:common-web")) - api(project(":core:common:common-service")) } ext { From e3f8c4aa30ade147896a4fa199079319f572d211 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Fri, 18 Jun 2021 16:52:11 +0800 Subject: [PATCH 004/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/buildSrc/build.gradle.kts | 9 +++------ src/backend/ci/buildSrc/gradle.properties | 9 --------- .../buildSrc/src/main/kotlin/constants/Libs.kt | 8 -------- .../plugins/task-deploy-to-maven.gradle.kts | 1 - .../kotlin/plugins/task-gen-jooq.gradle.kts | 7 +------ .../task-spring-boot-package.gradle.kts | 18 +++++++----------- 6 files changed, 11 insertions(+), 41 deletions(-) delete mode 100644 src/backend/ci/buildSrc/src/main/kotlin/constants/Libs.kt diff --git a/src/backend/ci/buildSrc/build.gradle.kts b/src/backend/ci/buildSrc/build.gradle.kts index 8972eb08127..3388b1c7c8f 100644 --- a/src/backend/ci/buildSrc/build.gradle.kts +++ b/src/backend/ci/buildSrc/build.gradle.kts @@ -1,8 +1,9 @@ +// gradle使用kts plugins { `kotlin-dsl` } -// 仓库 +// 插件使用仓库 repositories { var mavenRepoUrl: String? = System.getProperty("mavenRepoUrl") if (mavenRepoUrl == null) { @@ -19,11 +20,7 @@ repositories { jcenter() } -kotlinDslPluginOptions { - experimentalWarning.set(false) -} - - +// 依赖插件 dependencies { implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72") implementation("org.jetbrains.kotlin:kotlin-allopen:1.3.72") diff --git a/src/backend/ci/buildSrc/gradle.properties b/src/backend/ci/buildSrc/gradle.properties index 6f60486f68a..c02aa4e03d7 100644 --- a/src/backend/ci/buildSrc/gradle.properties +++ b/src/backend/ci/buildSrc/gradle.properties @@ -24,15 +24,6 @@ # 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. # -kotlin.incremental=true -systemProp.file.encoding=utf-8 -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -org.gradle.daemon=true -org.gradle.daemon.idleTimeout=3600000 -#systemProp.http.proxyHost= -#systemProp.http.proxyPort= -#systemProp.https.proxyHost= -#systemProp.https.proxyPort= MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public MAVEN_REPO_DEPLOY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/ MAVEN_REPO_USERNAME= diff --git a/src/backend/ci/buildSrc/src/main/kotlin/constants/Libs.kt b/src/backend/ci/buildSrc/src/main/kotlin/constants/Libs.kt deleted file mode 100644 index 0db82719d71..00000000000 --- a/src/backend/ci/buildSrc/src/main/kotlin/constants/Libs.kt +++ /dev/null @@ -1,8 +0,0 @@ -object Libs { - const val KotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.Kotlin}" - const val KotlinReflectLib = "org.jetbrains.kotlin:kotlin-reflect:${Versions.Kotlin}" - const val KotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Kotlin}" - const val SpringBootGradlePlugin = "org.springframework.boot:spring-boot-gradle-plugin:${Versions.SpringBoot}" - const val DependencyManagement = "io.spring.gradle:dependency-management-plugin:${Versions.DependencyManagement}" - const val KotlinSpringGradlePlugin = "org.jetbrains.kotlin:kotlin-allopen:${Versions.Kotlin}" -} diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts index b7c8b4c347b..0b09168b17b 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts @@ -24,7 +24,6 @@ * 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. */ - import java.net.URI plugins { diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts index 35a1cd94472..1bb2550e705 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts @@ -1,5 +1,3 @@ -import nu.studer.gradle.jooq.JooqGenerate - /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * @@ -26,18 +24,15 @@ import nu.studer.gradle.jooq.JooqGenerate * 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. */ - +import nu.studer.gradle.jooq.JooqGenerate plugins { id("nu.studer.jooq") - kotlin("jvm") } val jooqGenerator by project.configurations -val api by project.configurations dependencies { - api("org.jooq:jooq") jooqGenerator("mysql:mysql-connector-java:8.0.22") } diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts index 23c8e0c4653..a4e7fa854c0 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts @@ -35,23 +35,19 @@ plugins { kotlin("jvm") } -ext { - var gitDir = file("$projectDir/../../../.git") - project.extra["commit"] = if (gitDir.exists()) { - gitDir = file("$projectDir/../../../") - Grgit.open(gitDir).head() - } else { - null - } -} - tasks { withType { jvmArgs = listOf("-Dspring.output.ansi.enabled=ALWAYS", "-Dfile.encoding=UTF-8") } register("copyVersionInfo") { - val commit: Commit? = project.extra["commit"] as Commit? + var gitDir = file("$projectDir/../../../.git") + val commit: Commit? = if (gitDir.exists()) { + gitDir = file("$projectDir/../../../") + Grgit.open(gitDir).head() + } else { + null + } if (null != commit && File("$projectDir/src/main/resources").exists()) { File("$projectDir/src/main/resources/version.txt").writeText( """ From c7a78f4df14c5e837c2c7fe5b59115b5dac17b6d Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 30 Jun 2021 21:16:21 +0800 Subject: [PATCH 005/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/build.gradle.kts | 236 +- .../plugins/task-deploy-to-maven.gradle.kts | 8 +- .../kotlin/plugins/task-gen-jooq.gradle.kts | 4 +- .../task-spring-boot-package.gradle.kts | 13 +- .../ci/core/artifactory/build.gradle.kts | 66 +- .../model-artifactory/build.gradle.kts | 61 +- src/backend/ci/core/auth/build.gradle.kts | 66 +- .../tencent/devops/common/api/util/Watcher.kt | 158 +- .../common/redis/RedisAutoConfiguration.kt | 130 +- .../devops/common/redis/RedisOperation.kt | 359 ++-- .../devops/common/security/jwt/JwtManager.kt | 344 +-- .../common/security/util/EnvironmentUtil.kt | 216 +- .../common/web/jmx/exception/JmxExceptions.kt | 158 +- .../web/mq/CoreRabbitMQConfiguration.kt | 268 +-- .../web/mq/ExtendRabbitMQConfiguration.kt | 252 +-- .../ci/core/dispatch-docker/build.gradle.kts | 66 +- src/backend/ci/core/dispatch/build.gradle.kts | 66 +- .../services/DockerHostBuildService.kt | 1890 ++++++++--------- .../ci/core/environment/build.gradle.kts | 66 +- src/backend/ci/core/image/build.gradle.kts | 66 +- .../log/cron/impl/IndexCleanJobESImpl.kt | 308 +-- src/backend/ci/core/log/build.gradle.kts | 8 - src/backend/ci/core/misc/build.gradle.kts | 66 +- .../ci/core/monitoring/build.gradle.kts | 66 +- src/backend/ci/core/notify/build.gradle.kts | 66 +- src/backend/ci/core/openapi/build.gradle.kts | 66 +- src/backend/ci/core/plugin/build.gradle.kts | 66 +- .../devops/process/jmx/api/ProcessJmxApi.kt | 178 +- .../process/jmx/elements/JmxElements.kt | 158 +- src/backend/ci/core/process/build.gradle.kts | 66 +- .../plugin/load/ContainerBizPluginLoader.kt | 116 +- .../plugin/load/ElementBizPluginLoader.kt | 116 +- .../devops/project/jmx/api/ProjectJmxApi.kt | 148 +- src/backend/ci/core/project/build.gradle.kts | 66 +- src/backend/ci/core/quality/build.gradle.kts | 66 +- .../ci/core/repository/build.gradle.kts | 66 +- .../devops/sign/config/SignExecutorConfig.kt | 116 +- src/backend/ci/core/sign/build.gradle.kts | 66 +- src/backend/ci/core/store/build.gradle.kts | 66 +- src/backend/ci/core/ticket/build.gradle.kts | 66 +- .../configuration/WebSocketConfig.kt | 208 +- .../handler/BKHandshakeInterceptor.kt | 164 +- .../websocket/handler/SessionHandler.kt | 174 +- ...SessionWebSocketHandlerDecoratorFactory.kt | 88 +- .../ci/core/websocket/build.gradle.kts | 66 +- src/backend/ci/gradle.properties | 93 +- src/backend/ci/settings.gradle.kts | 12 + 47 files changed, 3507 insertions(+), 3731 deletions(-) diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index a68727d1c81..811c4d9536f 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -1,69 +1,18 @@ plugins { - kotlin("jvm") + id("com.tencent.devops.boot") apply false } apply("$rootDir/detekt.gradle.kts") allprojects { - // 包路径 - group = "com.tencent.bk.devops.ci" - - // 版本 - version = "1.6.0" - val devopsVersion = System.getProperty("ci_version") - if (devopsVersion != null) { - version = devopsVersion - } - val snapshot = System.getProperty("snapshot") - version = if (snapshot == "true") { - version as String + "-SNAPSHOT" - } else { - version as String + "-RELEASE" - } - - // 仓库 - var mavenRepoUrl = System.getProperty("mavenRepoUrl") - if (mavenRepoUrl == null) { - mavenRepoUrl = System.getenv("mavenRepoUrl") - } - if (mavenRepoUrl == null) { - mavenRepoUrl = extra["MAVEN_REPO_URL"] as String - } - repositories { - mavenLocal() - maven(url = mavenRepoUrl) - maven(url = "https://repo.spring.io/libs-milestone") - mavenCentral() - jcenter() - } - - // 创建目录 - task("createCodeDirs") { - val paths = listOf( - "src/main/java", - "src/main/kotlin", - "src/main/resources", - "src/test/java", - "src/test/kotlin", - "src/test/resources" - ) - paths.forEach { - val f = File(it) - if (!f.exists()) { - f.mkdirs() - } - } - } -} + apply(plugin = "com.tencent.devops.boot") + apply(plugin = "maven") + apply(plugin = "io.spring.dependency-management") -subprojects { - apply(plugin = "idea") + /************ https://github.com/bkdevops-projects/devops-framework/issues/73 ********/ apply(plugin = "java") apply(plugin = "kotlin") - apply(plugin = "maven") apply(plugin = "org.jetbrains.kotlin.plugin.spring") - apply(plugin = "io.spring.dependency-management") - tasks.withType { kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() @@ -80,19 +29,19 @@ subprojects { tasks.getByName("jar") { onlyIf { - sourceSets.main.get().allSource.files.isNotEmpty() + project.the()["main"].allSource.files.isNotEmpty() } } tasks.getByName("uploadArchives") { onlyIf { - sourceSets.main.get().allSource.files.isNotEmpty() + project.the()["main"].allSource.files.isNotEmpty() } } tasks.getByName("install") { onlyIf { - sourceSets.main.get().allSource.files.isNotEmpty() && + project.the()["main"].allSource.files.isNotEmpty() && !name.startsWith("model-") && !name.startsWith("boot-") && !name.startsWith("biz-") @@ -109,135 +58,88 @@ subprojects { } dependencies { - testImplementation("junit:junit") + "testImplementation"("junit:junit") } + /*****************************************************************************************/ - configure { - imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:${Versions.SpringBoot}") + // 包路径 + group = "com.tencent.bk.devops.ci" + // 版本 + version = System.getProperty("ci_version") ?: "1.6.0" + version = if (System.getProperty("snapshot") == "true") { + version as String + "-SNAPSHOT" + } else { + version as String + "-RELEASE" + } + + // 仓库 + val mavenRepoUrl = System.getProperty("mavenRepoUrl") + ?: System.getenv("mavenRepoUrl") + ?: extra["MAVEN_REPO_URL"] as String + + repositories { + mavenLocal() + maven(url = mavenRepoUrl) + maven(url = "https://repo.spring.io/libs-milestone") + mavenCentral() + jcenter() + } + + // 创建目录 + task("createCodeDirs") { + listOf( + "src/main/java", + "src/main/kotlin", + "src/main/resources", + "src/test/java", + "src/test/kotlin", + "src/test/resources" + ).forEach { + val f = File(it) + if (!f.exists()) { + f.mkdirs() + } } + } + + configure { dependencies { - dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.Kotlin}") - dependency("org.jetbrains.kotlin:kotlin-reflect:${Versions.Kotlin}") - dependency("com.google.guava:guava:${Versions.Guava}") - dependency("com.floragunn:search-guard-ssl:${Versions.SearchGuardSsl}") - dependency("org.elasticsearch:elasticsearch:${Versions.Elasticsearch}") - dependency("org.elasticsearch.client:elasticsearch-rest-client:${Versions.Elasticsearch}") - dependency("org.elasticsearch.client:elasticsearch-rest-high-level-client:${Versions.Elasticsearch}") - dependency("org.hashids:hashids:${Versions.HashIds}") + dependency("org.mockito:mockito-all:${Versions.Mockito}") + dependency("com.nhaarman:mockito-kotlin-kt1.1:${Versions.MockitoKt}") dependency("javax.ws.rs:javax.ws.rs-api:${Versions.Jaxrs}") - dependency("com.squareup.okhttp3:okhttp:${Versions.OkHttp}") - dependency("org.apache.httpcomponents:httpclient:${Versions.Httpclient}") - dependency("org.apache.commons:commons-exec:${Versions.CommonExec}") - dependency("com.vmware:vijava:${Versions.Vmware}") dependency("org.bouncycastle:bcprov-jdk16:${Versions.BouncyCastle}") - dependency("dom4j:dom4j:${Versions.Dom4j}") - dependency("org.apache.commons:commons-compress:${Versions.Compress}") - dependency("org.reflections:reflections:${Versions.Reflections}") dependency("com.github.fge:json-schema-validator:${Versions.JsonSchema}") - dependency("com.github.ulisesbocchio:jasypt-spring-boot-starter:${Versions.Jasypt}") - dependency("org.jolokia:jolokia-core:${Versions.Jolokia}") - dependency("org.apache.commons:commons-lang3:${Versions.CommonLang3}") - dependency("commons-codec:commons-codec:${Versions.CommonCodec}") - dependency("org.jooq:jooq:${Versions.Jooq}") - dependency("org.apache.lucene:lucene-core:${Versions.Lucene}") - dependency("org.mockito:mockito-all:${Versions.Mockito}") - dependency("net.sf.json-lib:json-lib:${Versions.JsonLib}") - dependency("com.cronutils:cron-utils:${Versions.CronUtils}") - dependency("com.amazonaws:aws-java-sdk-s3:${Versions.AwsS3}") - dependency("org.asynchttpclient:async-http-client:${Versions.AsyncHttpClient}") - dependency("com.tencent.devops.ci-plugins:sigar:${Versions.Sigar}") - dependency("org.influxdb:influxdb-java:${Versions.InfluxDB}") - dependency("com.github.ben-manes.caffeine:caffeine:${Versions.Caffeine}") - dependency("net.coobird:thumbnailator:${Versions.Thumbnailator}") + dependency("org.apache.commons:commons-exec:${Versions.CommonExec}") dependency("com.vdurmont:emoji-java:${Versions.EmojiJava}") + dependency("org.apache.lucene:lucene-core:${Versions.Lucene}") dependency("org.apache.commons:commons-csv:${Versions.CommonCsv}") + dependency("org.hashids:hashids:${Versions.HashIds}") + dependency("com.github.ulisesbocchio:jasypt-spring-boot-starter:${Versions.Jasypt}") + dependency("com.cronutils:cron-utils:${Versions.CronUtils}") dependency("org.apache.commons:commons-collections4:${Versions.CommonCollections4}") - dependency("com.nhaarman:mockito-kotlin-kt1.1:${Versions.MockitoKt}") - dependency("org.tmatesoft.svnkit:svnkit:${Versions.Svnkit}") - dependency("org.eclipse.jgit:org.eclipse.jgit:${Versions.JGit}") - dependency("org.glassfish.jersey.containers:jersey-container-servlet:${Versions.Jersey}") - dependency("javax.websocket:javax.websocket-api:${Versions.WebSocketApi}") + dependency("net.coobird:thumbnailator:${Versions.Thumbnailator}") + dependency("com.vmware:vijava:${Versions.Vmware}") + dependency("com.tencent.devops.ci-plugins:sigar:${Versions.Sigar}") + dependency("net.sf.json-lib:json-lib:${Versions.JsonLib}") dependency("com.googlecode.plist:dd-plist:${Versions.DdPlist}") - dependency("net.dongliu:apk-parser:${Versions.ApkParser}") - dependency("org.xerial:sqlite-jdbc:${Versions.SqlLiteJdbc}") dependency("com.github.oshi:oshi-core:${Versions.OshiCore}") - - dependencySet("com.tencent.bkrepo:${Versions.TencentBkRepo}") { - entry("api-generic") - entry("api-repository") - } - - dependencySet("io.jsonwebtoken:${Versions.JJwt}") { - entry("jjwt-api") - entry("jjwt") - entry("jjwt-impl") - entry("jjwt-jackson") - } - - dependencySet("org.glassfish.jersey.core:${Versions.Jersey}") { - entry("jersey-client") - entry("jersey-server") - entry("jersey-common") - } - - dependencySet("com.github.docker-java:${Versions.DockerJava}") { - entry("docker-java") - entry("docker-java-transport-okhttp") - } - - dependencySet("org.springframework.cloud:${Versions.SpringConsul}") { - entry("spring-cloud-starter-consul-discovery") - entry("spring-cloud-starter-consul-core") - entry("spring-cloud-starter-config") - entry("spring-cloud-config-server") - } + dependency("net.dongliu:apk-parser:${Versions.ApkParser}") + dependency("dom4j:dom4j:${Versions.Dom4j}") dependencySet("io.swagger:${Versions.Swagger}") { entry("swagger-annotations") entry("swagger-jersey2-jaxrs") } - dependencySet("com.fasterxml.jackson.module:${Versions.Jackson}") { - entry("jackson-module-kotlin") - } - - dependencySet("com.fasterxml.jackson.core:${Versions.Jackson}") { - entry("jackson-core") - entry("jackson-databind") - entry("jackson-annotations") - } - - dependencySet("com.fasterxml.jackson.jaxrs:${Versions.Jackson}") { - entry("jackson-jaxrs-json-provider") - entry("jackson-jaxrs-base") - } - - dependencySet("io.github.openfeign:${Versions.Feign}") { - entry("feign-jaxrs") - entry("feign-okhttp") - entry("feign-jackson") - } - - dependencySet("io.github.openfeign.form:${Versions.FeignForm}") { - entry("feign-form") - entry("feign-form-spring") - } - - dependencySet("org.slf4j:${Versions.Slf4j}") { - entry("slf4j-api") - entry("slf4j-simple") - } - - dependencySet("ch.qos.logback:${Versions.Logback}") { - entry("logback-core") - entry("logback-classic") + dependencySet("com.github.docker-java:${Versions.DockerJava}") { + entry("docker-java") + entry("docker-java-transport-okhttp") } - dependencySet("org.apache.poi:${Versions.Poi}") { - entry("poi") - entry("poi-ooxml") + dependencySet("com.tencent.bkrepo:${Versions.TencentBkRepo}") { + entry("api-generic") + entry("api-repository") } } } diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts index 0b09168b17b..79ee6bc8422 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-deploy-to-maven.gradle.kts @@ -29,6 +29,8 @@ import java.net.URI plugins { `maven-publish` signing + maven + java } val sourceJar = tasks.register("sourceJar") { @@ -216,12 +218,6 @@ tasks.getByName("signMavenJavaPublication") { } } -val api by project.configurations -dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") -} - tasks.getByName("uploadArchives") { var mavenRepoDeployUrl: String? = System.getProperty("mavenRepoDeployUrl") var mavenRepoUsername = System.getProperty("mavenRepoUsername") diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts index 1bb2550e705..ef25cf65988 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts @@ -30,10 +30,12 @@ plugins { id("nu.studer.jooq") } -val jooqGenerator by project.configurations +val jooqGenerator by configurations +val api by configurations dependencies { jooqGenerator("mysql:mysql-connector-java:8.0.22") + api("org.jooq:jooq") } val moduleNames = when (val moduleName = name.split("-")[1]) { diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts index a4e7fa854c0..963c05b29c3 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts @@ -33,6 +33,7 @@ version = "" plugins { kotlin("jvm") + id("org.springframework.boot") } tasks { @@ -61,18 +62,6 @@ tasks { } dependsOn("build") } - - register("copyToRelease") { - from("build/libs") { - include("**/*.jar") - } - into("${rootDir}/release") - outputs.upToDateWhen { false } - dependsOn("bootJar") - dependsOn("test") - } - - getByName("build").dependsOn("copyToRelease") } configurations.forEach { diff --git a/src/backend/ci/core/artifactory/build.gradle.kts b/src/backend/ci/core/artifactory/build.gradle.kts index 83fa115e20b..79bf1a005f3 100644 --- a/src/backend/ci/core/artifactory/build.gradle.kts +++ b/src/backend/ci/core/artifactory/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.artifactory" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.artifactory" +} diff --git a/src/backend/ci/core/artifactory/model-artifactory/build.gradle.kts b/src/backend/ci/core/artifactory/model-artifactory/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/artifactory/model-artifactory/build.gradle.kts +++ b/src/backend/ci/core/artifactory/model-artifactory/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/auth/build.gradle.kts b/src/backend/ci/core/auth/build.gradle.kts index 01794c90aa5..6cfb6e675e8 100644 --- a/src/backend/ci/core/auth/build.gradle.kts +++ b/src/backend/ci/core/auth/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.auth" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.auth" +} diff --git a/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/Watcher.kt b/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/Watcher.kt index ddcedd4ca5c..602633742d8 100644 --- a/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/Watcher.kt +++ b/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/Watcher.kt @@ -1,79 +1,79 @@ -/* - * 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.common.api.util - -import org.springframework.util.StopWatch - -/** - * 非线程安全 - * 针对running值导致抛出异常的位置主动做了stop,并增加了一个全部耗时统计 - */ -class Watcher(id: String = "") : StopWatch(id) { - - val createTime: Long = System.currentTimeMillis() - - fun elapsed() = System.currentTimeMillis() - createTime - - override fun start() { - if (isRunning) { - stop() - } - super.start() - } - - override fun start(taskName: String?) { - if (isRunning) { - stop() - } - super.start(taskName) - } - - override fun toString(): String { - if (isRunning) { - stop() - } - val sb = StringBuilder(shortSummary()) - this.taskInfo.forEach { task -> - sb.append("|").append(task.taskName).append("=").append(task.timeMillis) - } - return sb.toString() - } - - override fun shortSummary(): String { - return "watcher|$id|total=$totalTimeMillis|elapsed=${elapsed()}" - } - - override fun stop() { - if (isRunning) { - try { - super.stop() - } catch (ignored: IllegalStateException) { - } - } - } -} +/* + * 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.common.api.util + +import org.springframework.util.StopWatch + +/** + * 非线程安全 + * 针对running值导致抛出异常的位置主动做了stop,并增加了一个全部耗时统计 + */ +class Watcher(id: String = "") : StopWatch(id) { + + val createTime: Long = System.currentTimeMillis() + + fun elapsed() = System.currentTimeMillis() - createTime + + override fun start() { + if (isRunning) { + stop() + } + super.start() + } + + override fun start(taskName: String) { + if (isRunning) { + stop() + } + super.start(taskName) + } + + override fun toString(): String { + if (isRunning) { + stop() + } + val sb = StringBuilder(shortSummary()) + this.taskInfo.forEach { task -> + sb.append("|").append(task.taskName).append("=").append(task.timeMillis) + } + return sb.toString() + } + + override fun shortSummary(): String { + return "watcher|$id|total=$totalTimeMillis|elapsed=${elapsed()}" + } + + override fun stop() { + if (isRunning) { + try { + super.stop() + } catch (ignored: IllegalStateException) { + } + } + } +} diff --git a/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisAutoConfiguration.kt b/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisAutoConfiguration.kt index e536c7d05ba..9ea6134f808 100644 --- a/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisAutoConfiguration.kt @@ -1,65 +1,65 @@ -/* - * 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.common.redis - -import com.tencent.devops.common.redis.concurrent.SimpleRateLimiter -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Value -import org.springframework.boot.autoconfigure.AutoConfigureBefore -import org.springframework.boot.autoconfigure.AutoConfigureOrder -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.core.Ordered -import org.springframework.data.redis.connection.RedisConnectionFactory -import org.springframework.data.redis.core.RedisTemplate -import org.springframework.data.redis.serializer.StringRedisSerializer - -@Configuration -@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) -@AutoConfigureBefore(RedisAutoConfiguration::class) -class RedisAutoConfiguration { - - @Value("\${spring.redis.name:#{null}}") - private var redisName: String? = null - - @Bean - fun redisOperation(@Autowired factory: RedisConnectionFactory): RedisOperation { - val template = RedisTemplate() - template.connectionFactory = factory - template.keySerializer = StringRedisSerializer() - template.valueSerializer = StringRedisSerializer() - template.afterPropertiesSet() - return RedisOperation(template, redisName) - } - - @Bean - fun simpleRateLimiter(@Autowired redisOperation: RedisOperation): SimpleRateLimiter { - return SimpleRateLimiter(redisOperation) - } -} +/* + * 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.common.redis + +import com.tencent.devops.common.redis.concurrent.SimpleRateLimiter +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Value +import org.springframework.boot.autoconfigure.AutoConfigureBefore +import org.springframework.boot.autoconfigure.AutoConfigureOrder +import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.core.Ordered +import org.springframework.data.redis.connection.RedisConnectionFactory +import org.springframework.data.redis.core.RedisTemplate +import org.springframework.data.redis.serializer.StringRedisSerializer + +@Configuration +@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) +@AutoConfigureBefore(RedisAutoConfiguration::class) +class RedisAutoConfiguration { + + @Value("\${spring.redis.name:#{null}}") + private var redisName: String? = null + + @Bean + fun redisOperation(@Autowired factory: RedisConnectionFactory): RedisOperation { + val template = RedisTemplate() + template.setConnectionFactory(factory) + template.keySerializer = StringRedisSerializer() + template.valueSerializer = StringRedisSerializer() + template.afterPropertiesSet() + return RedisOperation(template, redisName) + } + + @Bean + fun simpleRateLimiter(@Autowired redisOperation: RedisOperation): SimpleRateLimiter { + return SimpleRateLimiter(redisOperation) + } +} diff --git a/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisOperation.kt b/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisOperation.kt index 71029e56cca..afa011950e7 100644 --- a/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisOperation.kt +++ b/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisOperation.kt @@ -1,179 +1,180 @@ -/* - * 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.common.redis - -import org.springframework.data.redis.core.Cursor -import org.springframework.data.redis.core.RedisCallback -import org.springframework.data.redis.core.RedisTemplate -import org.springframework.data.redis.core.ScanOptions -import java.util.Date -import java.util.concurrent.TimeUnit - -class RedisOperation(private val redisTemplate: RedisTemplate, private val redisName: String? = null) { - - // max expire time is 30 days - private val maxExpireTime = TimeUnit.DAYS.toSeconds(30) - - fun get(key: String): String? { - return redisTemplate.opsForValue().get(key) - } - - fun getAndSet(key: String, defaultValue: String, expiredInSecond: Long? = null): String? { - val value = redisTemplate.opsForValue().getAndSet(key, defaultValue) - if (value == null) { - redisTemplate.expire(key, expiredInSecond ?: maxExpireTime, TimeUnit.SECONDS) - } - return value - } - - fun increment(key: String, incr: Long): Long? { - return redisTemplate.opsForValue().increment(key, incr) - } - - fun set(key: String, value: String, expiredInSecond: Long? = null, expired: Boolean? = true) { - return if (expired == false) { - redisTemplate.opsForValue().set(key, value) - } else { - redisTemplate.opsForValue().set(key, value, expiredInSecond ?: maxExpireTime, TimeUnit.SECONDS) - } - } - - fun delete(key: String) { - redisTemplate.delete(key) - } - - fun delete(keys: Collection) { - redisTemplate.delete(keys) - } - - fun hasKey(key: String): Boolean { - return redisTemplate.hasKey(key) - } - - fun addSetValue(key: String, item: String) { - redisTemplate.opsForSet().add(key, item) - } - - fun removeSetMember(key: String, item: String) { - redisTemplate.opsForSet().remove(key, item) - } - - fun isMember(key: String, item: String): Boolean { - return redisTemplate.opsForSet().isMember(key, item) - } - - fun getSetMembers(key: String): Set? { - return redisTemplate.opsForSet().members(key) - } - - /** - * @param key key - * @param hashKey hash key - * @param values values - */ - fun hset(key: String, hashKey: String, values: String) { - redisTemplate.opsForHash().put(key, hashKey, values) - } - - fun hget(key: String, hashKey: String): String? { - return redisTemplate.opsForHash().get(key, hashKey) - } - - fun hdelete(key: String, hashKey: String) { - redisTemplate.opsForHash().delete(key, hashKey) - } - - fun hdelete(key: String, hashKeys: Collection) { - redisTemplate.opsForHash().delete(key, hashKeys) - } - - fun hhaskey(key: String, hashKey: String): Boolean { - return redisTemplate.opsForHash().hasKey(key, hashKey) - } - - fun hsize(key: String): Long { - return redisTemplate.opsForHash().size(key) - } - - fun hvalues(key: String): MutableList? { - return redisTemplate.opsForHash().values(key) - } - - fun hkeys(key: String): MutableSet? { - return redisTemplate.opsForHash().keys(key) - } - - fun hentries(key: String): MutableMap? { - return redisTemplate.opsForHash().entries(key) - } - - fun sadd(key: String, vararg values: String): Long? { - return redisTemplate.opsForSet().add(key, *values) - } - - fun sremove(key: String, values: String): Long? { - return redisTemplate.opsForSet().remove(key, values) - } - - fun sscan(key: String, pattern: String, count: Long = 1000L): Cursor? { - val options = ScanOptions.scanOptions().match(pattern).count(count).build() - return redisTemplate.opsForSet().scan(key, options) - } - - fun zadd(key: String, values: String, score: Double): Boolean? { - return redisTemplate.opsForZSet().add(key, values, score) - } - - fun zremove(key: String, values: String): Long { - return redisTemplate.opsForZSet().remove(key, values) - } - - fun zsize(key: String, min: Double, max: Double): Long { - return redisTemplate.opsForZSet().count(key, min, max) - } - - fun zremoveRangeByScore(key: String, min: Double, max: Double): Long? { - return redisTemplate.opsForZSet().removeRangeByScore(key, min, max) - } - - fun expireAt(key: String, date: Date): Boolean { - return redisTemplate.expireAt(key, date) - } - - fun expire(key: String, expiredInSecond: Long) { - redisTemplate.expire(key, expiredInSecond, TimeUnit.SECONDS) - } - - fun execute(action: RedisCallback): T { - return redisTemplate.execute(action) - } - - fun getRedisName(): String? { - return redisName - } -} +/* + * 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.common.redis + +import org.springframework.data.redis.core.Cursor +import org.springframework.data.redis.core.RedisCallback +import org.springframework.data.redis.core.RedisTemplate +import org.springframework.data.redis.core.ScanOptions +import java.lang.NullPointerException +import java.util.Date +import java.util.concurrent.TimeUnit + +class RedisOperation(private val redisTemplate: RedisTemplate, private val redisName: String? = null) { + + // max expire time is 30 days + private val maxExpireTime = TimeUnit.DAYS.toSeconds(30) + + fun get(key: String): String? { + return redisTemplate.opsForValue().get(key) + } + + fun getAndSet(key: String, defaultValue: String, expiredInSecond: Long? = null): String? { + val value = redisTemplate.opsForValue().getAndSet(key, defaultValue) + if (value == null) { + redisTemplate.expire(key, expiredInSecond ?: maxExpireTime, TimeUnit.SECONDS) + } + return value + } + + fun increment(key: String, incr: Long): Long? { + return redisTemplate.opsForValue().increment(key, incr) + } + + fun set(key: String, value: String, expiredInSecond: Long? = null, expired: Boolean? = true) { + return if (expired == false) { + redisTemplate.opsForValue().set(key, value) + } else { + redisTemplate.opsForValue().set(key, value, expiredInSecond ?: maxExpireTime, TimeUnit.SECONDS) + } + } + + fun delete(key: String) { + redisTemplate.delete(key) + } + + fun delete(keys: Collection) { + redisTemplate.delete(keys) + } + + fun hasKey(key: String): Boolean { + return redisTemplate.hasKey(key) + } + + fun addSetValue(key: String, item: String) { + redisTemplate.opsForSet().add(key, item) + } + + fun removeSetMember(key: String, item: String) { + redisTemplate.opsForSet().remove(key, item) + } + + fun isMember(key: String, item: String): Boolean { + return redisTemplate.opsForSet().isMember(key, item) ?: false + } + + fun getSetMembers(key: String): Set? { + return redisTemplate.opsForSet().members(key) + } + + /** + * @param key key + * @param hashKey hash key + * @param values values + */ + fun hset(key: String, hashKey: String, values: String) { + redisTemplate.opsForHash().put(key, hashKey, values) + } + + fun hget(key: String, hashKey: String): String? { + return redisTemplate.opsForHash().get(key, hashKey) + } + + fun hdelete(key: String, hashKey: String) { + redisTemplate.opsForHash().delete(key, hashKey) + } + + fun hdelete(key: String, hashKeys: Collection) { + redisTemplate.opsForHash().delete(key, hashKeys) + } + + fun hhaskey(key: String, hashKey: String): Boolean { + return redisTemplate.opsForHash().hasKey(key, hashKey) + } + + fun hsize(key: String): Long { + return redisTemplate.opsForHash().size(key) + } + + fun hvalues(key: String): MutableList? { + return redisTemplate.opsForHash().values(key) + } + + fun hkeys(key: String): MutableSet? { + return redisTemplate.opsForHash().keys(key) + } + + fun hentries(key: String): MutableMap? { + return redisTemplate.opsForHash().entries(key) + } + + fun sadd(key: String, vararg values: String): Long? { + return redisTemplate.opsForSet().add(key, *values) + } + + fun sremove(key: String, values: String): Long? { + return redisTemplate.opsForSet().remove(key, values) + } + + fun sscan(key: String, pattern: String, count: Long = 1000L): Cursor? { + val options = ScanOptions.scanOptions().match(pattern).count(count).build() + return redisTemplate.opsForSet().scan(key, options) + } + + fun zadd(key: String, values: String, score: Double): Boolean? { + return redisTemplate.opsForZSet().add(key, values, score) + } + + fun zremove(key: String, values: String): Long { + return redisTemplate.opsForZSet().remove(key, values) ?: 0 + } + + fun zsize(key: String, min: Double, max: Double): Long { + return redisTemplate.opsForZSet().count(key, min, max) ?: 0 + } + + fun zremoveRangeByScore(key: String, min: Double, max: Double): Long? { + return redisTemplate.opsForZSet().removeRangeByScore(key, min, max) + } + + fun expireAt(key: String, date: Date): Boolean { + return redisTemplate.expireAt(key, date) + } + + fun expire(key: String, expiredInSecond: Long) { + redisTemplate.expire(key, expiredInSecond, TimeUnit.SECONDS) + } + + fun execute(action: RedisCallback): T { + return redisTemplate.execute(action) ?: throw NullPointerException() + } + + fun getRedisName(): String? { + return redisName + } +} diff --git a/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/jwt/JwtManager.kt b/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/jwt/JwtManager.kt index e25cb48720b..d03ddd916e8 100644 --- a/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/jwt/JwtManager.kt +++ b/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/jwt/JwtManager.kt @@ -1,172 +1,172 @@ -/* - * 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.common.security.jwt - -import com.google.common.cache.CacheBuilder -import com.tencent.devops.common.api.util.JsonUtil -import com.tencent.devops.common.security.pojo.SecurityJwtInfo -import com.tencent.devops.common.security.util.EnvironmentUtil -import io.jsonwebtoken.ExpiredJwtException -import io.jsonwebtoken.Jwts -import io.jsonwebtoken.SignatureAlgorithm -import org.jolokia.util.Base64Util -import org.slf4j.LoggerFactory -import org.springframework.scheduling.annotation.SchedulingConfigurer -import org.springframework.scheduling.config.ScheduledTaskRegistrar -import java.net.InetAddress -import java.security.KeyFactory -import java.security.PrivateKey -import java.security.PublicKey -import java.security.spec.PKCS8EncodedKeySpec -import java.security.spec.X509EncodedKeySpec -import java.time.Instant -import java.util.Date -import java.util.concurrent.TimeUnit - -class JwtManager( - private val privateKeyString: String?, - private val publicKeyString: String?, - private val enable: Boolean -) : SchedulingConfigurer { - private var token: String? = null - private val publicKey: PublicKey? - private val privateKey: PrivateKey? - private val authEnable: Boolean - private val securityJwtInfo: SecurityJwtInfo? - - // private val securityJwtInfo: SecurityJwtInfo - private val tokenCache = CacheBuilder.newBuilder() - .maximumSize(9999).expireAfterWrite(5, TimeUnit.MINUTES).build() - - /** - * 获取JWT jwt token - * - * @return - */ - fun getToken(): String? { - return if (token != null) { - token - } else generateToken() - } - - private fun generateToken(): String? { - // token 超时10min - val expireAt = System.currentTimeMillis() + 1000 * 60 * 10 - val json = if (securityJwtInfo == null) "X-DEVOPS-JWT-TOKEN AUTH" else JsonUtil.toJson(securityJwtInfo) - token = Jwts.builder().setSubject(json).setExpiration(Date(expireAt)) - .signWith(SignatureAlgorithm.RS512, privateKey).compact() - return token - } - - /** - * 验证JWT - * - * @param token jwt token - * @return - */ - fun verifyJwt(token: String): Boolean { - val start = System.currentTimeMillis() - val tokenExpireAt = tokenCache.getIfPresent(token) - if (tokenExpireAt != null) { - // 如果未超时 - if (tokenExpireAt > Instant.now().epochSecond) { - return true - } - } - try { - val claims = Jwts.parser() - .setSigningKey(publicKey) - .parseClaimsJws(token) - .body - logger.info("Verify jwt sub:${claims["sub"]}") - val expireAt = claims.get("exp", Date::class.java) - if (expireAt != null) { - tokenCache.put(token, expireAt.time) - } - } catch (e: ExpiredJwtException) { - logger.warn("Token is expire!", e) - return false - } catch (e: Exception) { - logger.warn("Verify jwt caught exception", e) - return false - } finally { - val cost = System.currentTimeMillis() - start - if (cost > 100) { - logger.warn("Verify jwt cost too much, cost:{}", cost) - } - } - return true - } - - override fun configureTasks(taskRegistrar: ScheduledTaskRegistrar?) { - if (isAuthEnable()) { - taskRegistrar?.addFixedDelayTask( - this@JwtManager::refreshToken, - 5 * 60 * 1000 - ) - } - } - - fun refreshToken() { - logger.info("Refresh service jwt token") - generateToken() - } - - fun isAuthEnable(): Boolean { - // 只有authEnable=true,且privateKeyString、publicKeyString不为空的时候,才会验证 - return authEnable && !privateKeyString.isNullOrBlank() && !publicKeyString.isNullOrBlank() - } - - fun isSendEnable(): Boolean { - // 只有authEnable=true,且privateKeyString、publicKeyString不为空的时候,才会验证 - return !privateKeyString.isNullOrBlank() && !publicKeyString.isNullOrBlank() - } - - init { - if (privateKeyString.isNullOrBlank() || publicKeyString.isNullOrBlank()) { - privateKey = null - publicKey = null - authEnable = false - } else { - val keyFactory = KeyFactory.getInstance("RSA") - privateKey = keyFactory.generatePrivate(PKCS8EncodedKeySpec(Base64Util.decode(privateKeyString))) - publicKey = keyFactory.generatePublic(X509EncodedKeySpec(Base64Util.decode(publicKeyString))) - authEnable = enable - } - securityJwtInfo = SecurityJwtInfo( - ip = InetAddress.getLocalHost().hostAddress, - applicationName = EnvironmentUtil.getApplicationName(), - activeProfile = EnvironmentUtil.getActiveProfile(), - serverPort = EnvironmentUtil.getServerPort() - ) - logger.info("Init JwtManager successfully!") - } - - companion object { - private val logger = LoggerFactory.getLogger(JwtManager::class.java) - } -} +/* + * 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.common.security.jwt + +import com.google.common.cache.CacheBuilder +import com.tencent.devops.common.api.util.JsonUtil +import com.tencent.devops.common.security.pojo.SecurityJwtInfo +import com.tencent.devops.common.security.util.EnvironmentUtil +import io.jsonwebtoken.ExpiredJwtException +import io.jsonwebtoken.Jwts +import io.jsonwebtoken.SignatureAlgorithm +import org.jolokia.util.Base64Util +import org.slf4j.LoggerFactory +import org.springframework.scheduling.annotation.SchedulingConfigurer +import org.springframework.scheduling.config.ScheduledTaskRegistrar +import java.net.InetAddress +import java.security.KeyFactory +import java.security.PrivateKey +import java.security.PublicKey +import java.security.spec.PKCS8EncodedKeySpec +import java.security.spec.X509EncodedKeySpec +import java.time.Instant +import java.util.Date +import java.util.concurrent.TimeUnit + +class JwtManager( + private val privateKeyString: String?, + private val publicKeyString: String?, + private val enable: Boolean +) : SchedulingConfigurer { + private var token: String? = null + private val publicKey: PublicKey? + private val privateKey: PrivateKey? + private val authEnable: Boolean + private val securityJwtInfo: SecurityJwtInfo? + + // private val securityJwtInfo: SecurityJwtInfo + private val tokenCache = CacheBuilder.newBuilder() + .maximumSize(9999).expireAfterWrite(5, TimeUnit.MINUTES).build() + + /** + * 获取JWT jwt token + * + * @return + */ + fun getToken(): String? { + return if (token != null) { + token + } else generateToken() + } + + private fun generateToken(): String? { + // token 超时10min + val expireAt = System.currentTimeMillis() + 1000 * 60 * 10 + val json = if (securityJwtInfo == null) "X-DEVOPS-JWT-TOKEN AUTH" else JsonUtil.toJson(securityJwtInfo) + token = Jwts.builder().setSubject(json).setExpiration(Date(expireAt)) + .signWith(SignatureAlgorithm.RS512, privateKey).compact() + return token + } + + /** + * 验证JWT + * + * @param token jwt token + * @return + */ + fun verifyJwt(token: String): Boolean { + val start = System.currentTimeMillis() + val tokenExpireAt = tokenCache.getIfPresent(token) + if (tokenExpireAt != null) { + // 如果未超时 + if (tokenExpireAt > Instant.now().epochSecond) { + return true + } + } + try { + val claims = Jwts.parser() + .setSigningKey(publicKey) + .parseClaimsJws(token) + .body + logger.info("Verify jwt sub:${claims["sub"]}") + val expireAt = claims.get("exp", Date::class.java) + if (expireAt != null) { + tokenCache.put(token, expireAt.time) + } + } catch (e: ExpiredJwtException) { + logger.warn("Token is expire!", e) + return false + } catch (e: Exception) { + logger.warn("Verify jwt caught exception", e) + return false + } finally { + val cost = System.currentTimeMillis() - start + if (cost > 100) { + logger.warn("Verify jwt cost too much, cost:{}", cost) + } + } + return true + } + + override fun configureTasks(taskRegistrar: ScheduledTaskRegistrar) { + if (isAuthEnable()) { + taskRegistrar?.addFixedDelayTask( + this@JwtManager::refreshToken, + 5 * 60 * 1000 + ) + } + } + + fun refreshToken() { + logger.info("Refresh service jwt token") + generateToken() + } + + fun isAuthEnable(): Boolean { + // 只有authEnable=true,且privateKeyString、publicKeyString不为空的时候,才会验证 + return authEnable && !privateKeyString.isNullOrBlank() && !publicKeyString.isNullOrBlank() + } + + fun isSendEnable(): Boolean { + // 只有authEnable=true,且privateKeyString、publicKeyString不为空的时候,才会验证 + return !privateKeyString.isNullOrBlank() && !publicKeyString.isNullOrBlank() + } + + init { + if (privateKeyString.isNullOrBlank() || publicKeyString.isNullOrBlank()) { + privateKey = null + publicKey = null + authEnable = false + } else { + val keyFactory = KeyFactory.getInstance("RSA") + privateKey = keyFactory.generatePrivate(PKCS8EncodedKeySpec(Base64Util.decode(privateKeyString))) + publicKey = keyFactory.generatePublic(X509EncodedKeySpec(Base64Util.decode(publicKeyString))) + authEnable = enable + } + securityJwtInfo = SecurityJwtInfo( + ip = InetAddress.getLocalHost().hostAddress, + applicationName = EnvironmentUtil.getApplicationName(), + activeProfile = EnvironmentUtil.getActiveProfile(), + serverPort = EnvironmentUtil.getServerPort() + ) + logger.info("Init JwtManager successfully!") + } + + companion object { + private val logger = LoggerFactory.getLogger(JwtManager::class.java) + } +} diff --git a/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/util/EnvironmentUtil.kt b/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/util/EnvironmentUtil.kt index 21f2bd9fdb8..51ee6edb8f5 100644 --- a/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/util/EnvironmentUtil.kt +++ b/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/util/EnvironmentUtil.kt @@ -1,108 +1,108 @@ -/* - * 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.common.security.util - -import org.apache.commons.lang.StringUtils -import org.springframework.beans.BeansException -import org.springframework.context.ApplicationContext -import org.springframework.context.ApplicationContextAware -import org.springframework.stereotype.Component - -@Component -class EnvironmentUtil : ApplicationContextAware { - - /** - * 实现ApplicationContextAware接口的回调方法,设置上下文环境 - */ - @Throws(BeansException::class) - override fun setApplicationContext(applicationContext: ApplicationContext?) { - EnvironmentUtil.applicationContext = applicationContext - } - - companion object { - // Spring应用上下文环境 - private var applicationContext: ApplicationContext? = null - - // 正式环境 - private var isProdProfileActive: Boolean? = null - - /** - * 获取activeProfile信息 - * @return String - */ - fun getActiveProfile(): String { - return StringUtils.join(applicationContext?.environment?.activeProfiles ?: arrayOf(), ",") - } - - /** - * 获取applicationName信息 - * @return String - */ - fun getApplicationName(): String { - return applicationContext?.environment?.getProperty("spring.application.name") ?: "" - } - - /** - * 获取serverPort信息 - * @return Int - */ - fun getServerPort(): Int { - return applicationContext?.environment?.getProperty("server.port")?.toInt() ?: 0 - } - - /** - * 是否为正式环境 - * @return Boolean - */ - fun isProdProfileActive(): Boolean { - if (isProdProfileActive != null) { - return isProdProfileActive!! - } - isProdProfileActive = isProfileActive("prod") - return isProdProfileActive!! - } - - /** - * 判断是否为某个环境 - * @param String 环境名称 - * @return Boolean - */ - private fun isProfileActive(profile: String): Boolean { - val activeProfiles: Array? = - applicationContext?.environment?.activeProfiles - if (activeProfiles != null && activeProfiles.isNotEmpty()) { - for (activeProfile in activeProfiles) { - if (activeProfile == profile) { - return true - } - } - } - return false - } - } -} +/* + * 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.common.security.util + +import org.apache.commons.lang.StringUtils +import org.springframework.beans.BeansException +import org.springframework.context.ApplicationContext +import org.springframework.context.ApplicationContextAware +import org.springframework.stereotype.Component + +@Component +class EnvironmentUtil : ApplicationContextAware { + + /** + * 实现ApplicationContextAware接口的回调方法,设置上下文环境 + */ + @Throws(BeansException::class) + override fun setApplicationContext(applicationContext: ApplicationContext) { + EnvironmentUtil.applicationContext = applicationContext + } + + companion object { + // Spring应用上下文环境 + private var applicationContext: ApplicationContext? = null + + // 正式环境 + private var isProdProfileActive: Boolean? = null + + /** + * 获取activeProfile信息 + * @return String + */ + fun getActiveProfile(): String { + return StringUtils.join(applicationContext?.environment?.activeProfiles ?: arrayOf(), ",") + } + + /** + * 获取applicationName信息 + * @return String + */ + fun getApplicationName(): String { + return applicationContext?.environment?.getProperty("spring.application.name") ?: "" + } + + /** + * 获取serverPort信息 + * @return Int + */ + fun getServerPort(): Int { + return applicationContext?.environment?.getProperty("server.port")?.toInt() ?: 0 + } + + /** + * 是否为正式环境 + * @return Boolean + */ + fun isProdProfileActive(): Boolean { + if (isProdProfileActive != null) { + return isProdProfileActive!! + } + isProdProfileActive = isProfileActive("prod") + return isProdProfileActive!! + } + + /** + * 判断是否为某个环境 + * @param String 环境名称 + * @return Boolean + */ + private fun isProfileActive(profile: String): Boolean { + val activeProfiles: Array? = + applicationContext?.environment?.activeProfiles + if (activeProfiles != null && activeProfiles.isNotEmpty()) { + for (activeProfile in activeProfiles) { + if (activeProfile == profile) { + return true + } + } + } + return false + } + } +} diff --git a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/jmx/exception/JmxExceptions.kt b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/jmx/exception/JmxExceptions.kt index 99519b069d2..63b64d82a21 100644 --- a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/jmx/exception/JmxExceptions.kt +++ b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/jmx/exception/JmxExceptions.kt @@ -1,79 +1,79 @@ -/* - * 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.common.web.jmx.exception - -import com.tencent.devops.common.service.Profile -import com.tencent.devops.common.service.utils.SpringContextUtil -import org.slf4j.LoggerFactory -import org.springframework.jmx.export.MBeanExporter -import java.util.HashMap -import javax.management.ObjectName - -object JmxExceptions { - - private val exceptions = HashMap() - - fun encounter(exception: Throwable) { - try { - val bean = getBean(exception) ?: return - bean.incre() - } catch (ignored: Throwable) { - logger.warn("Fail to record the exception ${exception.message}", ignored) - } - } - - private fun getBean(t: Throwable): ExceptionBean? { - val className = t.javaClass.name - var bean = exceptions[className] - if (bean == null) { - synchronized(this) { - bean = exceptions[className] - if (bean == null) { - bean = ExceptionBean(className) - val serviceName = SpringContextUtil.getBean(Profile::class.java).getApplicationName() - if (serviceName.isNullOrBlank()) { - logger.warn("Fail to get the service name, ignore the mbean") - return null - } - val name = "com.tencent.devops.$serviceName:type=exceptions,name=$className" - logger.info("Register exception $className mbean") - SpringContextUtil.getBean(MBeanExporter::class.java).registerManagedResource(bean, ObjectName(name)) - exceptions.put(className, bean!!) - } - } - } - return bean - } - - private val logger = LoggerFactory.getLogger(JmxExceptions::class.java) -} - -fun main() { - val throwable = Throwable("sss") - println(throwable.javaClass.name) -} +/* + * 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.common.web.jmx.exception + +import com.tencent.devops.common.service.Profile +import com.tencent.devops.common.service.utils.SpringContextUtil +import org.slf4j.LoggerFactory +import org.springframework.jmx.export.MBeanExporter +import javax.management.ObjectName + +object JmxExceptions { + + private val exceptions = HashMap() + + fun encounter(exception: Throwable) { + try { + val bean = getBean(exception) ?: return + bean.incre() + } catch (ignored: Throwable) { + logger.warn("Fail to record the exception ${exception.message}", ignored) + } + } + + private fun getBean(t: Throwable): ExceptionBean? { + val className = t.javaClass.name + var bean = exceptions[className] + if (bean == null) { + synchronized(this) { + bean = exceptions[className] + if (bean == null) { + bean = ExceptionBean(className) + val serviceName = SpringContextUtil.getBean(Profile::class.java).getApplicationName() + if (serviceName.isNullOrBlank()) { + logger.warn("Fail to get the service name, ignore the mbean") + return null + } + val name = "com.tencent.devops.$serviceName:type=exceptions,name=$className" + logger.info("Register exception $className mbean") + SpringContextUtil.getBean(MBeanExporter::class.java) + .registerManagedResource(bean!!, ObjectName(name)) + exceptions.put(className, bean!!) + } + } + } + return bean + } + + private val logger = LoggerFactory.getLogger(JmxExceptions::class.java) +} + +fun main() { + val throwable = Throwable("sss") + println(throwable.javaClass.name) +} diff --git a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/mq/CoreRabbitMQConfiguration.kt b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/mq/CoreRabbitMQConfiguration.kt index 754027ab020..d994bb4eb45 100644 --- a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/mq/CoreRabbitMQConfiguration.kt +++ b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/mq/CoreRabbitMQConfiguration.kt @@ -1,134 +1,134 @@ -/* - * 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.common.web.mq - -import com.fasterxml.jackson.databind.ObjectMapper -import com.tencent.devops.common.web.mq.property.CoreRabbitMQProperties -import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory -import org.springframework.amqp.rabbit.connection.CachingConnectionFactory -import org.springframework.amqp.rabbit.connection.ConnectionFactory -import org.springframework.amqp.rabbit.core.RabbitAdmin -import org.springframework.amqp.rabbit.core.RabbitTemplate -import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter -import org.springframework.beans.factory.annotation.Qualifier -import org.springframework.beans.factory.annotation.Value -import org.springframework.boot.autoconfigure.AutoConfigureBefore -import org.springframework.boot.autoconfigure.AutoConfigureOrder -import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration -import org.springframework.boot.context.properties.EnableConfigurationProperties -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.context.annotation.Primary -import org.springframework.core.Ordered - -@Configuration -@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) -@AutoConfigureBefore(RabbitAutoConfiguration::class) -@EnableConfigurationProperties(CoreRabbitMQProperties::class) -class CoreRabbitMQConfiguration { - - @Value("\${spring.rabbitmq.core.virtual-host}") - private val virtualHost: String? = null - @Value("\${spring.rabbitmq.core.username}") - private val username: String? = null - @Value("\${spring.rabbitmq.core.password}") - private val password: String? = null - @Value("\${spring.rabbitmq.core.addresses}") - private val addresses: String? = null - @Value("\${spring.rabbitmq.core.listener.simple.concurrency:#{null}}") - private var concurrency: Int? = null - @Value("\${spring.rabbitmq.core.listener.simple.max-concurrency:#{null}}") - private var maxConcurrency: Int? = null - @Value("\${spring.rabbitmq.core.cache.channel.size:#{null}}") - private var channelCacheSize: Int? = null - @Value("\${spring.rabbitmq.listener.simple.prefetch:#{null}}") - private val preFetchCount: Int? = null - - @Bean(name = [CORE_CONNECTION_FACTORY_NAME]) - @Primary - fun coreConnectionFactory(config: CoreRabbitMQProperties): ConnectionFactory { - val connectionFactory = CachingConnectionFactory() - connectionFactory.host = config.host - connectionFactory.port = config.port - connectionFactory.username = username - connectionFactory.setPassword(password) - connectionFactory.virtualHost = virtualHost - connectionFactory.setAddresses(addresses) - if (channelCacheSize != null && channelCacheSize!! > 0) { - connectionFactory.channelCacheSize = channelCacheSize!! - } - return connectionFactory - } - - @Bean(name = [CORE_RABBIT_TEMPLATE_NAME]) - @Primary - fun coreRabbitTemplate( - @Qualifier(CORE_CONNECTION_FACTORY_NAME) - connectionFactory: ConnectionFactory, - objectMapper: ObjectMapper - ): RabbitTemplate { - val rabbitTemplate = RabbitTemplate(connectionFactory) - rabbitTemplate.messageConverter = messageConverter(objectMapper) - return rabbitTemplate - } - - @Bean(value = [CORE_RABBIT_ADMIN_NAME]) - @Primary - fun coreRabbitAdmin( - @Qualifier(CORE_CONNECTION_FACTORY_NAME) - connectionFactory: ConnectionFactory - ): RabbitAdmin { - return RabbitAdmin(connectionFactory) - } - - @Bean(value = [CORE_LISTENER_CONTAINER_NAME]) - @Primary - fun coreFactory( - @Qualifier(CORE_CONNECTION_FACTORY_NAME) - connectionFactory: ConnectionFactory, - objectMapper: ObjectMapper - ): SimpleRabbitListenerContainerFactory { - val factory = SimpleRabbitListenerContainerFactory() - factory.setMessageConverter(messageConverter(objectMapper)) - factory.setConnectionFactory(connectionFactory) - if (concurrency != null) { - factory.setConcurrentConsumers(concurrency) - } - if (maxConcurrency != null) { - factory.setMaxConcurrentConsumers(maxConcurrency) - } - if (preFetchCount != null) { - factory.setPrefetchCount(preFetchCount) - } - return factory - } - - @Bean - fun messageConverter(objectMapper: ObjectMapper) = - Jackson2JsonMessageConverter(objectMapper) -} +/* + * 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.common.web.mq + +import com.fasterxml.jackson.databind.ObjectMapper +import com.tencent.devops.common.web.mq.property.CoreRabbitMQProperties +import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory +import org.springframework.amqp.rabbit.connection.CachingConnectionFactory +import org.springframework.amqp.rabbit.connection.ConnectionFactory +import org.springframework.amqp.rabbit.core.RabbitAdmin +import org.springframework.amqp.rabbit.core.RabbitTemplate +import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter +import org.springframework.beans.factory.annotation.Qualifier +import org.springframework.beans.factory.annotation.Value +import org.springframework.boot.autoconfigure.AutoConfigureBefore +import org.springframework.boot.autoconfigure.AutoConfigureOrder +import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration +import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Primary +import org.springframework.core.Ordered + +@Configuration +@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) +@AutoConfigureBefore(RabbitAutoConfiguration::class) +@EnableConfigurationProperties(CoreRabbitMQProperties::class) +class CoreRabbitMQConfiguration { + + @Value("\${spring.rabbitmq.core.virtual-host}") + private val virtualHost: String? = null + @Value("\${spring.rabbitmq.core.username}") + private val username: String? = null + @Value("\${spring.rabbitmq.core.password}") + private val password: String? = null + @Value("\${spring.rabbitmq.core.addresses}") + private val addresses: String? = null + @Value("\${spring.rabbitmq.core.listener.simple.concurrency:#{null}}") + private var concurrency: Int? = null + @Value("\${spring.rabbitmq.core.listener.simple.max-concurrency:#{null}}") + private var maxConcurrency: Int? = null + @Value("\${spring.rabbitmq.core.cache.channel.size:#{null}}") + private var channelCacheSize: Int? = null + @Value("\${spring.rabbitmq.listener.simple.prefetch:#{null}}") + private val preFetchCount: Int? = null + + @Bean(name = [CORE_CONNECTION_FACTORY_NAME]) + @Primary + fun coreConnectionFactory(config: CoreRabbitMQProperties): ConnectionFactory { + val connectionFactory = CachingConnectionFactory() + connectionFactory.host = config.host + connectionFactory.port = config.port + connectionFactory.username = username!! + connectionFactory.setPassword(password!!) + connectionFactory.virtualHost = virtualHost!! + connectionFactory.setAddresses(addresses!!) + if (channelCacheSize != null && channelCacheSize!! > 0) { + connectionFactory.channelCacheSize = channelCacheSize!! + } + return connectionFactory + } + + @Bean(name = [CORE_RABBIT_TEMPLATE_NAME]) + @Primary + fun coreRabbitTemplate( + @Qualifier(CORE_CONNECTION_FACTORY_NAME) + connectionFactory: ConnectionFactory, + objectMapper: ObjectMapper + ): RabbitTemplate { + val rabbitTemplate = RabbitTemplate(connectionFactory) + rabbitTemplate.messageConverter = messageConverter(objectMapper) + return rabbitTemplate + } + + @Bean(value = [CORE_RABBIT_ADMIN_NAME]) + @Primary + fun coreRabbitAdmin( + @Qualifier(CORE_CONNECTION_FACTORY_NAME) + connectionFactory: ConnectionFactory + ): RabbitAdmin { + return RabbitAdmin(connectionFactory) + } + + @Bean(value = [CORE_LISTENER_CONTAINER_NAME]) + @Primary + fun coreFactory( + @Qualifier(CORE_CONNECTION_FACTORY_NAME) + connectionFactory: ConnectionFactory, + objectMapper: ObjectMapper + ): SimpleRabbitListenerContainerFactory { + val factory = SimpleRabbitListenerContainerFactory() + factory.setMessageConverter(messageConverter(objectMapper)) + factory.setConnectionFactory(connectionFactory) + if (concurrency != null) { + factory.setConcurrentConsumers(concurrency) + } + if (maxConcurrency != null) { + factory.setMaxConcurrentConsumers(maxConcurrency) + } + if (preFetchCount != null) { + factory.setPrefetchCount(preFetchCount) + } + return factory + } + + @Bean + fun messageConverter(objectMapper: ObjectMapper) = + Jackson2JsonMessageConverter(objectMapper) +} diff --git a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/mq/ExtendRabbitMQConfiguration.kt b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/mq/ExtendRabbitMQConfiguration.kt index e870bb95ef6..b449e4cce52 100644 --- a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/mq/ExtendRabbitMQConfiguration.kt +++ b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/mq/ExtendRabbitMQConfiguration.kt @@ -1,126 +1,126 @@ -/* - * 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.common.web.mq - -import com.fasterxml.jackson.databind.ObjectMapper -import com.tencent.devops.common.web.mq.property.ExtendRabbitMQProperties -import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory -import org.springframework.amqp.rabbit.connection.CachingConnectionFactory -import org.springframework.amqp.rabbit.connection.ConnectionFactory -import org.springframework.amqp.rabbit.core.RabbitAdmin -import org.springframework.amqp.rabbit.core.RabbitTemplate -import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter -import org.springframework.beans.factory.annotation.Qualifier -import org.springframework.beans.factory.annotation.Value -import org.springframework.boot.autoconfigure.AutoConfigureBefore -import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration -import org.springframework.boot.context.properties.EnableConfigurationProperties -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration - -@Configuration -@AutoConfigureBefore(RabbitAutoConfiguration::class) -@EnableConfigurationProperties(ExtendRabbitMQProperties::class) -class ExtendRabbitMQConfiguration { - - @Value("\${spring.rabbitmq.extend.virtual-host}") - private val virtualHost: String? = null - @Value("\${spring.rabbitmq.extend.username}") - private val username: String? = null - @Value("\${spring.rabbitmq.extend.password}") - private val password: String? = null - @Value("\${spring.rabbitmq.extend.addresses}") - private val addresses: String? = null - @Value("\${spring.rabbitmq.extend.listener.simple.concurrency:#{null}}") - private var concurrency: Int? = null - @Value("\${spring.rabbitmq.extend.listener.simple.max-concurrency:#{null}}") - private var maxConcurrency: Int? = null - @Value("\${spring.rabbitmq.extend.cache.channel.size:#{null}}") - private var channelCacheSize: Int? = null - @Value("\${spring.rabbitmq.listener.simple.prefetch:#{null}}") - private val preFetchCount: Int? = null - - @Bean(name = [EXTEND_CONNECTION_FACTORY_NAME]) - fun extendConnectionFactory(config: ExtendRabbitMQProperties): ConnectionFactory { - val connectionFactory = CachingConnectionFactory() - connectionFactory.host = config.host - connectionFactory.port = config.port - connectionFactory.username = username - connectionFactory.setPassword(password) - connectionFactory.virtualHost = virtualHost - connectionFactory.setAddresses(addresses) - if (channelCacheSize != null && channelCacheSize!! > 0) { - connectionFactory.channelCacheSize = channelCacheSize!! - } - return connectionFactory - } - - @Bean(name = [EXTEND_RABBIT_TEMPLATE_NAME]) - fun extendRabbitTemplate( - @Qualifier(value = EXTEND_CONNECTION_FACTORY_NAME) - connectionFactory: ConnectionFactory, - objectMapper: ObjectMapper - ): RabbitTemplate { - val rabbitTemplate = RabbitTemplate(connectionFactory) - rabbitTemplate.messageConverter = messageConverter(objectMapper) - return rabbitTemplate - } - - @Bean(value = [EXTEND_RABBIT_ADMIN_NAME]) - fun extendRabbitAdmin( - @Qualifier(EXTEND_CONNECTION_FACTORY_NAME) - connectionFactory: ConnectionFactory - ): RabbitAdmin? { - return RabbitAdmin(connectionFactory) - } - - @Bean(value = [EXTEND_LISTENER_CONTAINER_NAME]) - fun extendFactory( - @Qualifier(EXTEND_CONNECTION_FACTORY_NAME) - connectionFactory: ConnectionFactory, - objectMapper: ObjectMapper - ): SimpleRabbitListenerContainerFactory { - val factory = SimpleRabbitListenerContainerFactory() - factory.setMessageConverter(messageConverter(objectMapper)) - factory.setConnectionFactory(connectionFactory) - if (concurrency != null) { - factory.setConcurrentConsumers(concurrency) - } - if (maxConcurrency != null) { - factory.setMaxConcurrentConsumers(maxConcurrency) - } - if (preFetchCount != null) { - factory.setPrefetchCount(preFetchCount) - } - return factory - } - - @Bean - fun messageConverter(objectMapper: ObjectMapper) = - Jackson2JsonMessageConverter(objectMapper) -} +/* + * 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.common.web.mq + +import com.fasterxml.jackson.databind.ObjectMapper +import com.tencent.devops.common.web.mq.property.ExtendRabbitMQProperties +import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory +import org.springframework.amqp.rabbit.connection.CachingConnectionFactory +import org.springframework.amqp.rabbit.connection.ConnectionFactory +import org.springframework.amqp.rabbit.core.RabbitAdmin +import org.springframework.amqp.rabbit.core.RabbitTemplate +import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter +import org.springframework.beans.factory.annotation.Qualifier +import org.springframework.beans.factory.annotation.Value +import org.springframework.boot.autoconfigure.AutoConfigureBefore +import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration +import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +@AutoConfigureBefore(RabbitAutoConfiguration::class) +@EnableConfigurationProperties(ExtendRabbitMQProperties::class) +class ExtendRabbitMQConfiguration { + + @Value("\${spring.rabbitmq.extend.virtual-host}") + private val virtualHost: String? = null + @Value("\${spring.rabbitmq.extend.username}") + private val username: String? = null + @Value("\${spring.rabbitmq.extend.password}") + private val password: String? = null + @Value("\${spring.rabbitmq.extend.addresses}") + private val addresses: String? = null + @Value("\${spring.rabbitmq.extend.listener.simple.concurrency:#{null}}") + private var concurrency: Int? = null + @Value("\${spring.rabbitmq.extend.listener.simple.max-concurrency:#{null}}") + private var maxConcurrency: Int? = null + @Value("\${spring.rabbitmq.extend.cache.channel.size:#{null}}") + private var channelCacheSize: Int? = null + @Value("\${spring.rabbitmq.listener.simple.prefetch:#{null}}") + private val preFetchCount: Int? = null + + @Bean(name = [EXTEND_CONNECTION_FACTORY_NAME]) + fun extendConnectionFactory(config: ExtendRabbitMQProperties): ConnectionFactory { + val connectionFactory = CachingConnectionFactory() + connectionFactory.host = config.host + connectionFactory.port = config.port + connectionFactory.username = username!! + connectionFactory.setPassword(password!!) + connectionFactory.virtualHost = virtualHost!! + connectionFactory.setAddresses(addresses!!) + if (channelCacheSize != null && channelCacheSize!! > 0) { + connectionFactory.channelCacheSize = channelCacheSize!! + } + return connectionFactory + } + + @Bean(name = [EXTEND_RABBIT_TEMPLATE_NAME]) + fun extendRabbitTemplate( + @Qualifier(value = EXTEND_CONNECTION_FACTORY_NAME) + connectionFactory: ConnectionFactory, + objectMapper: ObjectMapper + ): RabbitTemplate { + val rabbitTemplate = RabbitTemplate(connectionFactory) + rabbitTemplate.messageConverter = messageConverter(objectMapper) + return rabbitTemplate + } + + @Bean(value = [EXTEND_RABBIT_ADMIN_NAME]) + fun extendRabbitAdmin( + @Qualifier(EXTEND_CONNECTION_FACTORY_NAME) + connectionFactory: ConnectionFactory + ): RabbitAdmin? { + return RabbitAdmin(connectionFactory) + } + + @Bean(value = [EXTEND_LISTENER_CONTAINER_NAME]) + fun extendFactory( + @Qualifier(EXTEND_CONNECTION_FACTORY_NAME) + connectionFactory: ConnectionFactory, + objectMapper: ObjectMapper + ): SimpleRabbitListenerContainerFactory { + val factory = SimpleRabbitListenerContainerFactory() + factory.setMessageConverter(messageConverter(objectMapper)) + factory.setConnectionFactory(connectionFactory) + if (concurrency != null) { + factory.setConcurrentConsumers(concurrency) + } + if (maxConcurrency != null) { + factory.setMaxConcurrentConsumers(maxConcurrency) + } + if (preFetchCount != null) { + factory.setPrefetchCount(preFetchCount) + } + return factory + } + + @Bean + fun messageConverter(objectMapper: ObjectMapper) = + Jackson2JsonMessageConverter(objectMapper) +} diff --git a/src/backend/ci/core/dispatch-docker/build.gradle.kts b/src/backend/ci/core/dispatch-docker/build.gradle.kts index 2592c8251ab..89dc54f41db 100644 --- a/src/backend/ci/core/dispatch-docker/build.gradle.kts +++ b/src/backend/ci/core/dispatch-docker/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.dispatch.docker" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.dispatch.docker" +} diff --git a/src/backend/ci/core/dispatch/build.gradle.kts b/src/backend/ci/core/dispatch/build.gradle.kts index 726db0f1a99..79332440156 100644 --- a/src/backend/ci/core/dispatch/build.gradle.kts +++ b/src/backend/ci/core/dispatch/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.dispatch" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.dispatch" +} diff --git a/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/services/DockerHostBuildService.kt b/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/services/DockerHostBuildService.kt index 047d54df75a..a8b2961a419 100644 --- a/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/services/DockerHostBuildService.kt +++ b/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/services/DockerHostBuildService.kt @@ -1,945 +1,945 @@ -/* - * 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.dockerhost.services - -import com.github.dockerjava.api.DockerClient -import com.github.dockerjava.api.command.BuildImageResultCallback -import com.github.dockerjava.api.command.InspectContainerResponse -import com.github.dockerjava.api.exception.NotFoundException -import com.github.dockerjava.api.exception.UnauthorizedException -import com.github.dockerjava.api.model.AuthConfig -import com.github.dockerjava.api.model.AuthConfigurations -import com.github.dockerjava.api.model.BuildResponseItem -import com.github.dockerjava.api.model.ExposedPort -import com.github.dockerjava.api.model.Frame -import com.github.dockerjava.api.model.HostConfig -import com.github.dockerjava.api.model.Ports -import com.github.dockerjava.api.model.PushResponseItem -import com.github.dockerjava.api.model.Statistics -import com.github.dockerjava.core.DefaultDockerClientConfig -import com.github.dockerjava.core.DockerClientBuilder -import com.github.dockerjava.core.InvocationBuilder -import com.github.dockerjava.core.command.LogContainerResultCallback -import com.github.dockerjava.core.command.PushImageResultCallback -import com.github.dockerjava.core.command.WaitContainerResultCallback -import com.github.dockerjava.okhttp.OkDockerHttpClient -import com.github.dockerjava.transport.DockerHttpClient -import com.tencent.devops.common.api.constant.CommonMessageCode -import com.tencent.devops.common.api.pojo.Result -import com.tencent.devops.common.api.util.JsonUtil -import com.tencent.devops.common.pipeline.type.docker.ImageType -import com.tencent.devops.common.web.mq.alert.AlertLevel -import com.tencent.devops.dispatch.docker.pojo.DockerHostBuildInfo -import com.tencent.devops.dispatch.pojo.enums.PipelineTaskStatus -import com.tencent.devops.dockerhost.common.Constants -import com.tencent.devops.dockerhost.common.DockerExitCodeEnum -import com.tencent.devops.dockerhost.common.ErrorCodeEnum -import com.tencent.devops.dockerhost.config.DockerHostConfig -import com.tencent.devops.dockerhost.dispatch.AlertApi -import com.tencent.devops.dockerhost.dispatch.DockerHostBuildLogResourceApi -import com.tencent.devops.dockerhost.dispatch.DockerHostBuildResourceApi -import com.tencent.devops.dockerhost.docker.DockerBindLoader -import com.tencent.devops.dockerhost.docker.DockerEnvLoader -import com.tencent.devops.dockerhost.docker.DockerVolumeLoader -import com.tencent.devops.dockerhost.exception.ContainerException -import com.tencent.devops.dockerhost.exception.NoSuchImageException -import com.tencent.devops.dockerhost.pojo.CheckImageRequest -import com.tencent.devops.dockerhost.pojo.CheckImageResponse -import com.tencent.devops.dockerhost.pojo.DockerBuildParam -import com.tencent.devops.dockerhost.pojo.DockerRunParam -import com.tencent.devops.dockerhost.pojo.DockerRunPortBinding -import com.tencent.devops.dockerhost.utils.CommonUtils -import com.tencent.devops.dockerhost.utils.ENTRY_POINT_CMD -import com.tencent.devops.dockerhost.utils.RandomUtil -import com.tencent.devops.dockerhost.utils.SigarUtil -import com.tencent.devops.process.engine.common.VMUtils -import com.tencent.devops.store.pojo.image.enums.ImageRDTypeEnum -import org.apache.commons.lang3.StringUtils -import org.slf4j.LoggerFactory -import org.springframework.core.env.Environment -import org.springframework.stereotype.Component -import java.io.File -import java.io.IOException -import java.nio.file.Paths -import java.text.SimpleDateFormat -import java.util.Date -import java.util.TimeZone -import java.util.concurrent.TimeUnit -import javax.annotation.PostConstruct - -@Suppress("ALL") -@Component -class DockerHostBuildService( - private val dockerHostConfig: DockerHostConfig, - private val environment: Environment, - private val dockerHostBuildApi: DockerHostBuildResourceApi, - private val dockerHostBuildLogResourceApi: DockerHostBuildLogResourceApi, - private val alertApi: AlertApi -) : AbstractDockerHostBuildService(dockerHostConfig, dockerHostBuildApi) { - - companion object { - private val logger = LoggerFactory.getLogger(DockerHostBuildService::class.java) - } - - fun checkImage( - buildId: String, - checkImageRequest: CheckImageRequest, - containerId: String?, - containerHashId: String? - ): Result { - logger.info("checkImage buildId: $buildId, checkImageRequest: $checkImageRequest") - // 判断用户录入的镜像信息是否能正常拉取到镜像 - val imageName = checkImageRequest.imageName - try { - val pullImageResult = createPullImage( - imageType = checkImageRequest.imageType, - imageName = checkImageRequest.imageName, - registryUser = checkImageRequest.registryUser, - registryPwd = checkImageRequest.registryPwd, - buildId = buildId, - containerId = containerId, - containerHashId = containerHashId - ) - logger.info("pullImageResult: $pullImageResult") - if (pullImageResult.isNotOk()) { - return Result(pullImageResult.status, pullImageResult.message, null) - } - } catch (t: Throwable) { - logger.warn("Fail to pull the image $imageName of build $buildId", t) - log(buildId, "pull image fail,error is:${t.message}", containerId, containerHashId) - return Result(CommonMessageCode.SYSTEM_ERROR.toInt(), t.message, null) - } - val dockerImageName = CommonUtils.normalizeImageName(checkImageRequest.imageName) - // 查询镜像详细信息 - val imageInfo = httpLongDockerCli.inspectImageCmd(dockerImageName).exec() - logger.info("imageInfo: $imageInfo") - val checkImageResponse = CheckImageResponse( - author = imageInfo.author, - comment = imageInfo.comment, - size = imageInfo.size!!, - virtualSize = imageInfo.virtualSize, - repoTags = imageInfo.repoTags!! - ) - return Result(checkImageResponse) - } - - override fun createContainer(dockerHostBuildInfo: DockerHostBuildInfo): String { - val imageName = CommonUtils.normalizeImageName(dockerHostBuildInfo.imageName) - // 执行docker pull - createPullImage(dockerHostBuildInfo) - - // 执行docker run - val containerId = createDockerRun(dockerHostBuildInfo, imageName) - - // 等待一段时间,检查一下agent是否正常启动 - waitAgentUp(dockerHostBuildInfo, containerId) - - return containerId - } - - override fun stopContainer(dockerHostBuildInfo: DockerHostBuildInfo) { - try { - // docker stop - val containerInfo = httpLongDockerCli.inspectContainerCmd(dockerHostBuildInfo.containerId).exec() - if ("exited" != containerInfo.state.status) { - httpLongDockerCli.stopContainerCmd(dockerHostBuildInfo.containerId).withTimeout(15).exec() - } - } catch (e: Throwable) { - logger.error("Stop the container failed, containerId: ${dockerHostBuildInfo.containerId}, error msg: $e") - } - - try { - // docker rm - httpLongDockerCli.removeContainerCmd(dockerHostBuildInfo.containerId).exec() - } catch (e: Throwable) { - logger.error("Stop the container failed, containerId: ${dockerHostBuildInfo.containerId}, error msg: $e") - } finally { - // 找出所有跟本次构建关联的dockerRun启动容器并停止容器 - val containerInfo = httpLongDockerCli.listContainersCmd().withStatusFilter(setOf("running")).exec() - for (container in containerInfo) { - try { - // logger.info("${dockerBuildInfo.buildId}|${dockerBuildInfo.vmSeqId} containerName: ${container.names[0]}") - val containerName = container.names[0] - if (containerName.contains(getDockerRunStopPattern(dockerHostBuildInfo))) { - logger.info("${dockerHostBuildInfo.buildId}|${dockerHostBuildInfo.vmSeqId} " + - "stop dockerRun container, containerId: ${container.id}") - httpLongDockerCli.stopContainerCmd(container.id).withTimeout(15).exec() - } - } catch (e: Exception) { - logger.error("${dockerHostBuildInfo.buildId}|${dockerHostBuildInfo.vmSeqId} " + - "Stop dockerRun container failed, containerId: ${container.id}", e) - } - } - } - } - - private fun createDockerRun(dockerBuildInfo: DockerHostBuildInfo, imageName: String): String { - try { - // docker run - val binds = DockerBindLoader.loadBinds(dockerBuildInfo) - - val containerName = - "dispatch-${dockerBuildInfo.buildId}-${dockerBuildInfo.vmSeqId}-${RandomUtil.randomString()}" - val container = httpLongDockerCli.createContainerCmd(imageName) - .withName(containerName) - .withCmd("/bin/sh", ENTRY_POINT_CMD) - .withEnv(DockerEnvLoader.loadEnv(dockerBuildInfo)) - .withVolumes(DockerVolumeLoader.loadVolumes(dockerBuildInfo)) - .withHostConfig(HostConfig().withBinds(binds).withNetworkMode("bridge")) - .exec() - - logger.info("Created container $container") - httpLongDockerCli.startContainerCmd(container.id).exec() - - return container.id - } catch (er: Throwable) { - logger.error(er.toString()) - logger.error(er.cause.toString()) - logger.error(er.message) - log( - buildId = dockerBuildInfo.buildId, - red = true, - message = "启动构建环境失败,错误信息:${er.message}", - tag = VMUtils.genStartVMTaskId(dockerBuildInfo.vmSeqId.toString()), - containerHashId = dockerBuildInfo.containerHashId - ) - if (er is NotFoundException) { - throw NoSuchImageException("Create container failed: ${er.message}") - } else { - alertApi.alert( - AlertLevel.HIGH.name, "Docker构建机创建容器失败", "Docker构建机创建容器失败, " + - "母机IP:${CommonUtils.getInnerIP()}, 失败信息:${er.message}" - ) - throw ContainerException( - errorCodeEnum = ErrorCodeEnum.CREATE_CONTAINER_ERROR, - message = "[${dockerBuildInfo.buildId}]|Create container failed" - ) - } - } - } - - private fun waitAgentUp(dockerBuildInfo: DockerHostBuildInfo, containerId: String) { - var exitCode = 0L - try { - // 等待5s,看agent是否正常启动 - Thread.sleep(5000) - val containerState = getContainerState(containerId) - logger.info("containerState: $containerState") - if (containerState != null) { - exitCode = containerState.exitCodeLong ?: 0L - } - } catch (e: Exception) { - logger.error("[${dockerBuildInfo.buildId}]|[${dockerBuildInfo.vmSeqId}] waitAgentUp failed. containerId: $containerId", e) - } - - if (exitCode != 0L && DockerExitCodeEnum.getValue(exitCode) != null) { - val errorCodeEnum = DockerExitCodeEnum.getValue(exitCode)!!.errorCodeEnum - logger.error("[${dockerBuildInfo.buildId}]|[${dockerBuildInfo.vmSeqId}] waitAgentUp failed. " + - "${errorCodeEnum.formatErrorMessage}. containerId: $containerId") - throw ContainerException( - errorCodeEnum = errorCodeEnum, - message = "Failed to wait agent up. ${errorCodeEnum.formatErrorMessage}" - ) - } - } - - private fun getDockerRunStopPattern(dockerBuildInfo: DockerHostBuildInfo): String { - // 用户取消操作 - return if (dockerBuildInfo.vmSeqId == 0) { - "dockerRun-${dockerBuildInfo.buildId}" - } else { - "dockerRun-${dockerBuildInfo.buildId}-${dockerBuildInfo.vmSeqId}" - } - } - - fun getContainerNum(): Int { - try { - val dockerInfo = httpLongDockerCli.infoCmd().exec() - return dockerInfo.containersRunning ?: 0 - } catch (e: Throwable) { - logger.error("Get container num failed") - } - return 0 - } - - fun dockerBuildAndPushImage( - projectId: String, - pipelineId: String, - vmSeqId: String, - dockerBuildParam: DockerBuildParam, - buildId: String, - elementId: String?, - outer: Boolean - ): Pair { - lateinit var dockerClient: DockerClient - try { - val repoAddr = dockerBuildParam.repoAddr - val userName = dockerBuildParam.userName - val password = dockerBuildParam.password - val config = DefaultDockerClientConfig.createDefaultConfigBuilder() - .withDockerConfig(dockerHostConfig.dockerConfig) - .withApiVersion(dockerHostConfig.apiVersion) - .withRegistryUrl(repoAddr) - .withRegistryUsername(userName) - .withRegistryPassword(password) - .build() - - val longHttpClient: DockerHttpClient = OkDockerHttpClient.Builder() - .dockerHost(config.dockerHost) - .sslConfig(config.sslConfig) - .connectTimeout(5000) - .readTimeout(300000) - .build() - - dockerClient = DockerClientBuilder.getInstance(config).withDockerHttpClient(longHttpClient).build() - val authConfig = AuthConfig() - .withUsername(userName) - .withPassword(password) - .withRegistryAddress(repoAddr) - - val authConfigurations = AuthConfigurations() - authConfigurations.addConfig(authConfig) - - val ticket = dockerBuildParam.ticket - val args = dockerBuildParam.args - ticket.forEach { - val baseConfig = AuthConfig() - .withUsername(it.second) - .withPassword(it.third) - .withRegistryAddress(it.first) - authConfigurations.addConfig(baseConfig) - } - - val workspace = getWorkspace(pipelineId, vmSeqId.toInt(), dockerBuildParam.poolNo ?: "0") - val buildDir = Paths.get(workspace + dockerBuildParam.buildDir).normalize().toString() - val dockerfilePath = Paths.get(workspace + dockerBuildParam.dockerFile).normalize().toString() - val baseDirectory = File(buildDir) - val dockerfile = File(dockerfilePath) -/* val imageNameTag = - getImageNameWithTag( - repoAddr = repoAddr, - projectId = projectId, - imageName = dockerBuildParam.imageName, - imageTag = dockerBuildParam.imageTag, - outer = outer - )*/ - - val imageNameTagSet = mutableSetOf() - if (dockerBuildParam.imageTagList.isNotEmpty()) { - dockerBuildParam.imageTagList.forEach { - imageNameTagSet.add(getImageNameWithTag( - repoAddr = repoAddr, - projectId = projectId, - imageName = dockerBuildParam.imageName, - imageTag = it, - outer = outer - )) - } - } else { - imageNameTagSet.add(getImageNameWithTag( - repoAddr = repoAddr, - projectId = projectId, - imageName = dockerBuildParam.imageName, - imageTag = dockerBuildParam.imageTag, - outer = outer - )) - } - - logger.info("Build docker image, workspace: $workspace, buildDir:$buildDir, dockerfile: $dockerfilePath") - logger.info("Build docker image, imageNameTag: $imageNameTagSet") - val step = dockerClient.buildImageCmd().withNoCache(true) - .withPull(true) - .withBuildAuthConfigs(authConfigurations) - .withBaseDirectory(baseDirectory) - .withDockerfile(dockerfile) - .withTags(imageNameTagSet) - args.map { it.trim().split("=") }.forEach { - step.withBuildArg(it.first(), it.last()) - } - step.exec(MyBuildImageResultCallback(buildId, elementId, dockerHostBuildApi)) - .awaitImageId() - - imageNameTagSet.parallelStream().forEach { - logger.info("Build image success, now push to repo, image name and tag: $it") - dockerClient.pushImageCmd(it) - .withAuthConfig(authConfig) - .exec(MyPushImageResultCallback(buildId, elementId, dockerHostBuildApi)) - .awaitCompletion() - - logger.info("Push image success, now remove local image, image name and tag: $it") - try { - httpLongDockerCli.removeImageCmd(it).exec() - logger.info("Remove local image success") - } catch (e: Throwable) { - logger.error("Docker rmi failed, msg: ${e.message}") - } - } - - return Pair(true, null) - } catch (e: Throwable) { - logger.error("Docker build and push failed, exception: ", e) - val cause = if (e.cause != null && e.cause!!.message != null) { - e.cause!!.message!!.removePrefix(getWorkspace(pipelineId = pipelineId, - vmSeqId = vmSeqId.toInt(), - poolNo = dockerBuildParam.poolNo ?: "0") - ) - } else { - "" - } - - return Pair(false, e.message + if (cause.isBlank()) "" else " cause:【$cause】") - } finally { - try { - dockerClient.close() - } catch (e: IOException) { - logger.error("docker client close exception: ${e.message}") - } - } - } - - fun dockerRun( - projectId: String, - pipelineId: String, - vmSeqId: String, - buildId: String, - dockerRunParam: DockerRunParam - ): Triple> { - try { - val imageName = CommonUtils.normalizeImageName(dockerRunParam.imageName) - // docker pull - try { - LocalImageCache.saveOrUpdate(imageName) - createPullImage( - imageType = ImageType.THIRD.type, - imageName = dockerRunParam.imageName, - registryUser = dockerRunParam.registryUser, - registryPwd = dockerRunParam.registryPwd, - buildId = buildId, - containerId = vmSeqId, - containerHashId = "" - ) - } catch (t: UnauthorizedException) { - val errorMessage = "无权限拉取镜像:$imageName,请检查凭证" - logger.error(errorMessage, t) - // 直接失败,禁止使用本地镜像 - throw NotFoundException(errorMessage) - } catch (t: NotFoundException) { - val errorMessage = "仓库中镜像不存在:$imageName,请检查凭证" - logger.error(errorMessage, t) - // 直接失败,禁止使用本地镜像 - throw NotFoundException(errorMessage) - } catch (t: Throwable) { - logger.warn("Fail to pull the image $imageName of build $buildId", t, "") - log( - buildId = buildId, - message = "拉取镜像失败,错误信息:${t.message}", - tag = VMUtils.genStartVMTaskId(vmSeqId), - containerHashId = "" - ) - log( - buildId = buildId, - message = "尝试使用本地镜像执行命令...", - tag = VMUtils.genStartVMTaskId(vmSeqId), - containerHashId = "" - ) - } - - val dockerBuildInfo = DockerHostBuildInfo( - projectId = projectId, - agentId = "", - pipelineId = pipelineId, - buildId = buildId, - vmSeqId = vmSeqId.toInt(), - secretKey = "", - status = PipelineTaskStatus.RUNNING.status, - imageName = imageName, - containerId = "", - wsInHost = true, - poolNo = if (dockerRunParam.poolNo == null) 0 else dockerRunParam.poolNo!!.toInt(), - registryUser = dockerRunParam.registryUser, - registryPwd = dockerRunParam.registryPwd, - imageType = ImageType.THIRD.type, - imagePublicFlag = false, - imageRDType = null, - containerHashId = "" - ) - // docker run - val env = mutableListOf() - env.addAll(DockerEnvLoader.loadEnv(dockerBuildInfo)) - env.add("bk_devops_start_source=dockerRun") // dockerRun启动标识 - dockerRunParam.env?.forEach { - env.add("${it.key}=${it.value ?: ""}") - } - logger.info("env is $env") - val binds = DockerBindLoader.loadBinds(dockerBuildInfo) - - val dockerRunPortBindingList = mutableListOf() - val hostIp = CommonUtils.getInnerIP() - val portBindings = Ports() - dockerRunParam.portList?.forEach { - val localPort = getAvailableHostPort() - if (localPort == 0) { - throw ContainerException( - errorCodeEnum = ErrorCodeEnum.NO_AVAILABLE_PORT_ERROR, - message = "No enough port to use in dockerRun. startPort: ${dockerHostConfig.dockerRunStartPort}" - ) - } - val tcpContainerPort: ExposedPort = ExposedPort.tcp(it) - portBindings.bind(tcpContainerPort, Ports.Binding.bindPort(localPort)) - dockerRunPortBindingList.add(DockerRunPortBinding(hostIp, it, localPort)) - } - - val containerName = - "dockerRun-${dockerBuildInfo.buildId}-${dockerBuildInfo.vmSeqId}-${RandomUtil.randomString()}" - - val container = if (dockerRunParam.command.isEmpty() || dockerRunParam.command.equals("[]")) { - httpLongDockerCli.createContainerCmd(imageName) - .withName(containerName) - .withEnv(env) - .withVolumes(DockerVolumeLoader.loadVolumes(dockerBuildInfo)) - .withHostConfig(HostConfig() - .withBinds(binds).withNetworkMode("bridge").withPortBindings(portBindings)) - .withWorkingDir(dockerHostConfig.volumeWorkspace) - .exec() - } else { - httpLongDockerCli.createContainerCmd(imageName) - .withName(containerName) - .withCmd(dockerRunParam.command) - .withEnv(env) - .withVolumes(DockerVolumeLoader.loadVolumes(dockerBuildInfo)) - .withHostConfig(HostConfig() - .withBinds(binds).withNetworkMode("bridge").withPortBindings(portBindings)) - .withWorkingDir(dockerHostConfig.volumeWorkspace) - .exec() - } - - logger.info("Created container $container") - val timestamp = (System.currentTimeMillis() / 1000).toInt() - httpLongDockerCli.startContainerCmd(container.id).exec() - - return Triple(container.id, timestamp, dockerRunPortBindingList) - } catch (er: Throwable) { - val errorLog = "[$buildId]|启动容器失败,错误信息:${er.message}" - logger.error(errorLog, er) - log(buildId, true, errorLog, VMUtils.genStartVMTaskId(vmSeqId), "") - alertApi.alert( - level = AlertLevel.HIGH.name, title = "Docker构建机创建容器失败", - message = "Docker构建机创建容器失败, 母机IP:${CommonUtils.getInnerIP()}, 失败信息:${er.message}" - ) - throw ContainerException( - errorCodeEnum = ErrorCodeEnum.CREATE_CONTAINER_ERROR, - message = "启动容器失败,错误信息:${er.message}" - ) - } finally { - if (!dockerRunParam.registryUser.isNullOrEmpty()) { - try { - httpLongDockerCli.removeImageCmd(dockerRunParam.imageName) - logger.info("Delete local image successfully......") - } catch (e: java.lang.Exception) { - logger.info("the exception of deleteing local image is ${e.message}") - } finally { - logger.info("Docker run end......") - } - } - } - } - - fun getDockerLogs(containerId: String, lastLogTime: Int): List { - val logs = ArrayList() - val logContainerCmd = httpLongDockerCli.logContainerCmd(containerId) - .withStdOut(true) - .withStdErr(true) - .withSince(lastLogTime) - .withTimestamps(true) - try { - logContainerCmd.exec(object : LogContainerResultCallback() { - override fun onNext(item: Frame) { - logs.add(item.toString()) - } - }).awaitCompletion() - } catch (e: InterruptedException) { - logger.error("Get docker run log exception: ", e) - } - return logs - } - - fun getDockerRunExitCode(containerId: String): Int? { - return try { - httpLongDockerCli.waitContainerCmd(containerId) - .exec(WaitContainerResultCallback()) - .awaitStatusCode(10, TimeUnit.SECONDS) - } catch (e: Exception) { - logger.error("[$containerId]| getDockerRunExitCode error.", e) - Constants.DOCKER_EXIST_CODE - } - } - - /** - * 监控系统负载,超过一定阈值,对于占用负载较高的容器,主动降低负载 - */ - fun monitorSystemLoad() { - logger.info("Monitor|cpu: ${SigarUtil.getAverageLongCpuLoad()}, mem: ${SigarUtil.getAverageLongMemLoad()}") - if (SigarUtil.getAverageLongCpuLoad() > dockerHostConfig.elasticitySystemCpuThreshold ?: 80 || - SigarUtil.getAverageLongMemLoad() > dockerHostConfig.elasticitySystemMemThreshold ?: 80 - ) { - checkContainerStats() - } - } - - private fun checkContainerStats() { - val containerInfo = httpLongDockerCli.listContainersCmd().withStatusFilter(setOf("running")).exec() - for (container in containerInfo) { - val statistics = getContainerStats(container.id) - if (statistics != null) { - val systemCpuUsage = statistics.cpuStats.systemCpuUsage ?: 0 - val cpuUsage = statistics.cpuStats.cpuUsage!!.totalUsage ?: 0 - val preSystemCpuUsage = statistics.preCpuStats.systemCpuUsage ?: 0 - val preCpuUsage = statistics.preCpuStats.cpuUsage!!.totalUsage ?: 0 - val cpuUsagePer = if ((systemCpuUsage - preSystemCpuUsage) > 0) { - ((cpuUsage - preCpuUsage) * 100) / (systemCpuUsage - preSystemCpuUsage) - } else { - 0 - } - - // 优先判断CPU - val elasticityCpuThreshold = dockerHostConfig.elasticityCpuThreshold ?: 80 - if (cpuUsagePer >= elasticityCpuThreshold) { - // 上报负载超额预警到数据平台 - dockerHostBuildLogResourceApi.sendFormatLog(mapOf( - "containerName" to container.names[0], - "containerId" to container.id, - "cpuUsagePer" to cpuUsagePer.toString(), - "memUsagePer" to "", - "statistics" to JsonUtil.toJson(statistics) - )) - - // 重置容器负载 - resetContainer(container.id) - continue - } - - if (statistics.memoryStats != null && - statistics.memoryStats.usage != null && - statistics.memoryStats.limit != null) { - val memUsage = statistics.memoryStats.usage!! * 100 / statistics.memoryStats.limit!! - val elasticityMemThreshold = dockerHostConfig.elasticityMemThreshold ?: 80 - if (memUsage >= elasticityMemThreshold) { - // 上报负载超额预警到数据平台 - dockerHostBuildLogResourceApi.sendFormatLog(mapOf( - "containerName" to container.names[0], - "containerId" to container.id, - "cpuUsagePer" to cpuUsagePer.toString(), - "memUsagePer" to memUsage.toString(), - "statistics" to JsonUtil.toJson(statistics) - )) - - resetContainer(container.id) - } - } - } - } - } - - private fun getContainerStats(containerId: String): Statistics? { - val asyncResultCallback = InvocationBuilder.AsyncResultCallback() - httpDockerCli.statsCmd(containerId).withNoStream(true).exec(asyncResultCallback) - return try { - val stats = asyncResultCallback.awaitResult() - stats - } catch (e: Exception) { - logger.error("containerId: $containerId get containerStats error.", e) - null - } finally { - asyncResultCallback.close() - } - } - - private fun resetContainer(containerId: String) { - val memReservation = dockerHostConfig.elasticityMemReservation ?: 32 * 1024 * 1024 * 1024L - val cpuPeriod = dockerHostConfig.elasticityCpuPeriod ?: 10000 - val cpuQuota = dockerHostConfig.elasticityCpuQuota ?: 80000 - httpDockerCli.updateContainerCmd(containerId) - .withMemoryReservation(memReservation) - .withCpuPeriod(cpuPeriod) - .withCpuQuota(cpuQuota).exec() - logger.info("<<<< Trigger container reset, containerId: $containerId," + - " memReservation: $memReservation, cpuPeriod: $cpuPeriod, cpuQuota: $cpuQuota") - } - - fun clearContainers() { - val containerInfo = httpLongDockerCli.listContainersCmd().withStatusFilter(setOf("exited")).exec() - for (container in containerInfo) { - try { - val finishTime = httpLongDockerCli.inspectContainerCmd(container.id).exec().state.finishedAt - // 是否已退出30分钟 - if (checkFinishTime(finishTime)) { - logger.info("Clear container, containerId: ${container.id}") - httpLongDockerCli.removeContainerCmd(container.id).exec() - } - } catch (e: Exception) { - logger.error("Clear container failed, containerId: ${container.id}", e) - } - } - } - - fun clearDockerRunTimeoutContainers() { - val containerInfo = httpLongDockerCli.listContainersCmd().withStatusFilter(setOf("running")).exec() - for (container in containerInfo) { - try { - val startTime = httpLongDockerCli.inspectContainerCmd(container.id).exec().state.startedAt - val envs = httpLongDockerCli.inspectContainerCmd(container.id).exec().config.env - // 是否是dockerRun启动的并且已运行超过8小时 - if (envs != null && envs.contains("bk_devops_start_source=dockerRun") && checkStartTime(startTime)) { - logger.info("Clear dockerRun timeout container, containerId: ${container.id}") - httpLongDockerCli.stopContainerCmd(container.id).withTimeout(15).exec() - } - } catch (e: Exception) { - logger.error("Clear dockerRun timeout container failed, containerId: ${container.id}", e) - } - } - } - - @PostConstruct - fun loadLocalImages() { - try { - val imageList = httpLongDockerCli.listImagesCmd().withShowAll(true).exec() - logger.info("load local images, image count: ${imageList.size}") - imageList.forEach c@{ - it.repoTags?.forEach { image -> - LocalImageCache.saveOrUpdate(image) - } - } - } catch (e: java.lang.Exception) { - logger.error("load local image, exception, msg: ${e.message}") - } - } - - fun clearLocalImages() { - val danglingImages = httpLongDockerCli.listImagesCmd().withDanglingFilter(true).withShowAll(true).exec() - danglingImages.forEach { - try { - httpLongDockerCli.removeImageCmd(it.id).exec() - logger.info("remove local dangling image success, image id: ${it.id}") - } catch (e: java.lang.Exception) { - logger.error("remove local dangling image exception ${e.message}") - } - } - - val publicImages = getPublicImages() - val imageList = httpLongDockerCli.listImagesCmd().withShowAll(true).exec() - imageList.forEach c@{ - if (it.repoTags == null || it.repoTags.isEmpty()) { - return@c - } - it.repoTags.forEach t@{ image -> - if (publicImages.contains(image)) { - logger.info("skip public image: $image") - return@t - } - - val lastUsedDate = LocalImageCache.getDate(image) - if (null != lastUsedDate) { - val days = TimeUnit.MILLISECONDS.toDays(Date().time - lastUsedDate.time) - if (days >= dockerHostConfig.localImageCacheDays) { - logger.info("remove local image, ${it.repoTags}") - try { - httpLongDockerCli.removeImageCmd(image).exec() - logger.info("remove local image success, image: $image") - } catch (e: java.lang.Exception) { - logger.error("remove local image exception ${e.message}") - } - return@c - } - } - } - } - } - - fun isContainerRunning(containerId: String): Boolean { - try { - logger.info("Check container: $containerId start.") - val inspectContainerResponse = httpLongDockerCli.inspectContainerCmd(containerId).exec() ?: return false - logger.info("Check container: $containerId status: ${inspectContainerResponse.state}") - return inspectContainerResponse.state.running ?: false - } catch (e: Exception) { - logger.error("check container: $containerId status failed.", e) - return false - } - } - - fun getContainerState(containerId: String): InspectContainerResponse.ContainerState? { - try { - logger.info("Get containerState: $containerId start.") - val inspectContainerResponse = httpDockerCli.inspectContainerCmd(containerId).exec() ?: return null - logger.info("Get containerState: $containerId state: ${inspectContainerResponse.state}") - return inspectContainerResponse.state - } catch (e: Exception) { - logger.error("check container: $containerId state failed, return ", e) - return null - } - } - - fun refreshDockerIpStatus(): Boolean? { - val port = environment.getProperty("local.server.port") - return dockerHostBuildApi.refreshDockerIpStatus(port, getContainerNum())!!.data - } - - private fun getPublicImages(): List { - val result = mutableListOf() - val publicImages = dockerHostBuildApi.getPublicImages().data!! - publicImages.filter { it.publicFlag && it.rdType == ImageRDTypeEnum.SELF_DEVELOPED }.forEach { - result.add("${it.repoUrl}/${it.repoName}:${it.repoTag}") - } - return result - } - - private fun getImageNameWithTag( - repoAddr: String, - projectId: String, - imageName: String, - imageTag: String, - outer: Boolean = false - ): String { - return if (outer) { - "$repoAddr/$imageName:$imageTag" - } else { - "$repoAddr/paas/$projectId/$imageName:$imageTag" - } - } - - private fun getWorkspace(pipelineId: String, vmSeqId: Int, poolNo: String): String { - return "${dockerHostConfig.hostPathWorkspace}/$pipelineId/${getTailPath(vmSeqId, poolNo.toInt())}/" - } - - private fun getTailPath(vmSeqId: Int, poolNo: Int): String { - return if (poolNo > 1) { - "$vmSeqId" + "_$poolNo" - } else { - vmSeqId.toString() - } - } - - private fun checkFinishTime(utcTime: String?): Boolean { - if (utcTime != null && utcTime.isNotEmpty()) { - val array = utcTime.split(".") - val utcTimeLocal = array[0] + "Z" - val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") - sdf.timeZone = TimeZone.getTimeZone("UTC") - - val date = sdf.parse(utcTimeLocal) - val finishTimestamp = date.time - val nowTimestamp = System.currentTimeMillis() - return (nowTimestamp - finishTimestamp) > (30 * 60 * 1000) - } - - return true - } - - private fun checkStartTime(utcTime: String?): Boolean { - if (utcTime != null && utcTime.isNotEmpty()) { - val array = utcTime.split(".") - val utcTimeLocal = array[0] + "Z" - val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") - sdf.timeZone = TimeZone.getTimeZone("UTC") - - val date = sdf.parse(utcTimeLocal) - val startTimestamp = date.time - val nowTimestamp = System.currentTimeMillis() - return (nowTimestamp - startTimestamp) > (8 * 3600 * 1000) - } - - return false - } - - private fun getAvailableHostPort(): Int { - val startPort = dockerHostConfig.dockerRunStartPort ?: 20000 - for (i in startPort..(startPort + 1000)) { - if (!CommonUtils.isPortUsing("127.0.0.1", i)) { - return i - } else { - continue - } - } - - return 0 - } - - inner class MyBuildImageResultCallback internal constructor( - private val buildId: String, - private val elementId: String?, - private val dockerHostBuildApi: DockerHostBuildResourceApi - ) : BuildImageResultCallback() { - override fun onNext(item: BuildResponseItem?) { - val text = item?.stream - if (null != text) { - dockerHostBuildApi.postLog( - buildId, - false, - StringUtils.removeEnd(text, "\n"), - elementId - ) - } - - super.onNext(item) - } - } - - inner class MyPushImageResultCallback internal constructor( - private val buildId: String, - private val elementId: String?, - private val dockerHostBuildApi: DockerHostBuildResourceApi - ) : PushImageResultCallback() { - private val totalList = mutableListOf() - private val step = mutableMapOf() - override fun onNext(item: PushResponseItem?) { - val text = item?.progressDetail - if (null != text && text.current != null && text.total != null && text.total != 0L) { - val lays = if (!totalList.contains(text.total!!)) { - totalList.add(text.total!!) - totalList.size + 1 - } else { - totalList.indexOf(text.total!!) + 1 - } - var currentProgress = text.current!! * 100 / text.total!! - if (currentProgress > 100) { - currentProgress = 100 - } - if (currentProgress >= step[lays]?.plus(25) ?: 5) { - dockerHostBuildApi.postLog( - buildId, - false, - "正在推送镜像,第${lays}层,进度:$currentProgress%", - elementId - ) - step[lays] = currentProgress - } - } - super.onNext(item) - } - } -} +/* + * 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.dockerhost.services + +import com.github.dockerjava.api.DockerClient +import com.github.dockerjava.api.command.BuildImageResultCallback +import com.github.dockerjava.api.command.InspectContainerResponse +import com.github.dockerjava.api.exception.NotFoundException +import com.github.dockerjava.api.exception.UnauthorizedException +import com.github.dockerjava.api.model.AuthConfig +import com.github.dockerjava.api.model.AuthConfigurations +import com.github.dockerjava.api.model.BuildResponseItem +import com.github.dockerjava.api.model.ExposedPort +import com.github.dockerjava.api.model.Frame +import com.github.dockerjava.api.model.HostConfig +import com.github.dockerjava.api.model.Ports +import com.github.dockerjava.api.model.PushResponseItem +import com.github.dockerjava.api.model.Statistics +import com.github.dockerjava.core.DefaultDockerClientConfig +import com.github.dockerjava.core.DockerClientBuilder +import com.github.dockerjava.core.InvocationBuilder +import com.github.dockerjava.core.command.LogContainerResultCallback +import com.github.dockerjava.core.command.PushImageResultCallback +import com.github.dockerjava.core.command.WaitContainerResultCallback +import com.github.dockerjava.okhttp.OkDockerHttpClient +import com.github.dockerjava.transport.DockerHttpClient +import com.tencent.devops.common.api.constant.CommonMessageCode +import com.tencent.devops.common.api.pojo.Result +import com.tencent.devops.common.api.util.JsonUtil +import com.tencent.devops.common.pipeline.type.docker.ImageType +import com.tencent.devops.common.web.mq.alert.AlertLevel +import com.tencent.devops.dispatch.docker.pojo.DockerHostBuildInfo +import com.tencent.devops.dispatch.pojo.enums.PipelineTaskStatus +import com.tencent.devops.dockerhost.common.Constants +import com.tencent.devops.dockerhost.common.DockerExitCodeEnum +import com.tencent.devops.dockerhost.common.ErrorCodeEnum +import com.tencent.devops.dockerhost.config.DockerHostConfig +import com.tencent.devops.dockerhost.dispatch.AlertApi +import com.tencent.devops.dockerhost.dispatch.DockerHostBuildLogResourceApi +import com.tencent.devops.dockerhost.dispatch.DockerHostBuildResourceApi +import com.tencent.devops.dockerhost.docker.DockerBindLoader +import com.tencent.devops.dockerhost.docker.DockerEnvLoader +import com.tencent.devops.dockerhost.docker.DockerVolumeLoader +import com.tencent.devops.dockerhost.exception.ContainerException +import com.tencent.devops.dockerhost.exception.NoSuchImageException +import com.tencent.devops.dockerhost.pojo.CheckImageRequest +import com.tencent.devops.dockerhost.pojo.CheckImageResponse +import com.tencent.devops.dockerhost.pojo.DockerBuildParam +import com.tencent.devops.dockerhost.pojo.DockerRunParam +import com.tencent.devops.dockerhost.pojo.DockerRunPortBinding +import com.tencent.devops.dockerhost.utils.CommonUtils +import com.tencent.devops.dockerhost.utils.ENTRY_POINT_CMD +import com.tencent.devops.dockerhost.utils.RandomUtil +import com.tencent.devops.dockerhost.utils.SigarUtil +import com.tencent.devops.process.engine.common.VMUtils +import com.tencent.devops.store.pojo.image.enums.ImageRDTypeEnum +import org.apache.commons.lang3.StringUtils +import org.slf4j.LoggerFactory +import org.springframework.core.env.Environment +import org.springframework.stereotype.Component +import java.io.File +import java.io.IOException +import java.nio.file.Paths +import java.text.SimpleDateFormat +import java.util.Date +import java.util.TimeZone +import java.util.concurrent.TimeUnit +import javax.annotation.PostConstruct + +@Suppress("ALL") +@Component +class DockerHostBuildService( + private val dockerHostConfig: DockerHostConfig, + private val environment: Environment, + private val dockerHostBuildApi: DockerHostBuildResourceApi, + private val dockerHostBuildLogResourceApi: DockerHostBuildLogResourceApi, + private val alertApi: AlertApi +) : AbstractDockerHostBuildService(dockerHostConfig, dockerHostBuildApi) { + + companion object { + private val logger = LoggerFactory.getLogger(DockerHostBuildService::class.java) + } + + fun checkImage( + buildId: String, + checkImageRequest: CheckImageRequest, + containerId: String?, + containerHashId: String? + ): Result { + logger.info("checkImage buildId: $buildId, checkImageRequest: $checkImageRequest") + // 判断用户录入的镜像信息是否能正常拉取到镜像 + val imageName = checkImageRequest.imageName + try { + val pullImageResult = createPullImage( + imageType = checkImageRequest.imageType, + imageName = checkImageRequest.imageName, + registryUser = checkImageRequest.registryUser, + registryPwd = checkImageRequest.registryPwd, + buildId = buildId, + containerId = containerId, + containerHashId = containerHashId + ) + logger.info("pullImageResult: $pullImageResult") + if (pullImageResult.isNotOk()) { + return Result(pullImageResult.status, pullImageResult.message, null) + } + } catch (t: Throwable) { + logger.warn("Fail to pull the image $imageName of build $buildId", t) + log(buildId, "pull image fail,error is:${t.message}", containerId, containerHashId) + return Result(CommonMessageCode.SYSTEM_ERROR.toInt(), t.message, null) + } + val dockerImageName = CommonUtils.normalizeImageName(checkImageRequest.imageName) + // 查询镜像详细信息 + val imageInfo = httpLongDockerCli.inspectImageCmd(dockerImageName).exec() + logger.info("imageInfo: $imageInfo") + val checkImageResponse = CheckImageResponse( + author = imageInfo.author, + comment = imageInfo.comment, + size = imageInfo.size!!, + virtualSize = imageInfo.virtualSize, + repoTags = imageInfo.repoTags!! + ) + return Result(checkImageResponse) + } + + override fun createContainer(dockerHostBuildInfo: DockerHostBuildInfo): String { + val imageName = CommonUtils.normalizeImageName(dockerHostBuildInfo.imageName) + // 执行docker pull + createPullImage(dockerHostBuildInfo) + + // 执行docker run + val containerId = createDockerRun(dockerHostBuildInfo, imageName) + + // 等待一段时间,检查一下agent是否正常启动 + waitAgentUp(dockerHostBuildInfo, containerId) + + return containerId + } + + override fun stopContainer(dockerHostBuildInfo: DockerHostBuildInfo) { + try { + // docker stop + val containerInfo = httpLongDockerCli.inspectContainerCmd(dockerHostBuildInfo.containerId).exec() + if ("exited" != containerInfo.state.status) { + httpLongDockerCli.stopContainerCmd(dockerHostBuildInfo.containerId).withTimeout(15).exec() + } + } catch (e: Throwable) { + logger.error("Stop the container failed, containerId: ${dockerHostBuildInfo.containerId}, error msg: $e") + } + + try { + // docker rm + httpLongDockerCli.removeContainerCmd(dockerHostBuildInfo.containerId).exec() + } catch (e: Throwable) { + logger.error("Stop the container failed, containerId: ${dockerHostBuildInfo.containerId}, error msg: $e") + } finally { + // 找出所有跟本次构建关联的dockerRun启动容器并停止容器 + val containerInfo = httpLongDockerCli.listContainersCmd().withStatusFilter(setOf("running")).exec() + for (container in containerInfo) { + try { + // logger.info("${dockerBuildInfo.buildId}|${dockerBuildInfo.vmSeqId} containerName: ${container.names[0]}") + val containerName = container.names[0] + if (containerName.contains(getDockerRunStopPattern(dockerHostBuildInfo))) { + logger.info("${dockerHostBuildInfo.buildId}|${dockerHostBuildInfo.vmSeqId} " + + "stop dockerRun container, containerId: ${container.id}") + httpLongDockerCli.stopContainerCmd(container.id).withTimeout(15).exec() + } + } catch (e: Exception) { + logger.error("${dockerHostBuildInfo.buildId}|${dockerHostBuildInfo.vmSeqId} " + + "Stop dockerRun container failed, containerId: ${container.id}", e) + } + } + } + } + + private fun createDockerRun(dockerBuildInfo: DockerHostBuildInfo, imageName: String): String { + try { + // docker run + val binds = DockerBindLoader.loadBinds(dockerBuildInfo) + + val containerName = + "dispatch-${dockerBuildInfo.buildId}-${dockerBuildInfo.vmSeqId}-${RandomUtil.randomString()}" + val container = httpLongDockerCli.createContainerCmd(imageName) + .withName(containerName) + .withCmd("/bin/sh", ENTRY_POINT_CMD) + .withEnv(DockerEnvLoader.loadEnv(dockerBuildInfo)) + .withVolumes(DockerVolumeLoader.loadVolumes(dockerBuildInfo)) + .withHostConfig(HostConfig().withBinds(binds).withNetworkMode("bridge")) + .exec() + + logger.info("Created container $container") + httpLongDockerCli.startContainerCmd(container.id).exec() + + return container.id + } catch (er: Throwable) { + logger.error(er.toString()) + logger.error(er.cause.toString()) + logger.error(er.message) + log( + buildId = dockerBuildInfo.buildId, + red = true, + message = "启动构建环境失败,错误信息:${er.message}", + tag = VMUtils.genStartVMTaskId(dockerBuildInfo.vmSeqId.toString()), + containerHashId = dockerBuildInfo.containerHashId + ) + if (er is NotFoundException) { + throw NoSuchImageException("Create container failed: ${er.message}") + } else { + alertApi.alert( + AlertLevel.HIGH.name, "Docker构建机创建容器失败", "Docker构建机创建容器失败, " + + "母机IP:${CommonUtils.getInnerIP()}, 失败信息:${er.message}" + ) + throw ContainerException( + errorCodeEnum = ErrorCodeEnum.CREATE_CONTAINER_ERROR, + message = "[${dockerBuildInfo.buildId}]|Create container failed" + ) + } + } + } + + private fun waitAgentUp(dockerBuildInfo: DockerHostBuildInfo, containerId: String) { + var exitCode = 0L + try { + // 等待5s,看agent是否正常启动 + Thread.sleep(5000) + val containerState = getContainerState(containerId) + logger.info("containerState: $containerState") + if (containerState != null) { + exitCode = containerState.exitCodeLong ?: 0L + } + } catch (e: Exception) { + logger.error("[${dockerBuildInfo.buildId}]|[${dockerBuildInfo.vmSeqId}] waitAgentUp failed. containerId: $containerId", e) + } + + if (exitCode != 0L && DockerExitCodeEnum.getValue(exitCode) != null) { + val errorCodeEnum = DockerExitCodeEnum.getValue(exitCode)!!.errorCodeEnum + logger.error("[${dockerBuildInfo.buildId}]|[${dockerBuildInfo.vmSeqId}] waitAgentUp failed. " + + "${errorCodeEnum.formatErrorMessage}. containerId: $containerId") + throw ContainerException( + errorCodeEnum = errorCodeEnum, + message = "Failed to wait agent up. ${errorCodeEnum.formatErrorMessage}" + ) + } + } + + private fun getDockerRunStopPattern(dockerBuildInfo: DockerHostBuildInfo): String { + // 用户取消操作 + return if (dockerBuildInfo.vmSeqId == 0) { + "dockerRun-${dockerBuildInfo.buildId}" + } else { + "dockerRun-${dockerBuildInfo.buildId}-${dockerBuildInfo.vmSeqId}" + } + } + + fun getContainerNum(): Int { + try { + val dockerInfo = httpLongDockerCli.infoCmd().exec() + return dockerInfo.containersRunning ?: 0 + } catch (e: Throwable) { + logger.error("Get container num failed") + } + return 0 + } + + fun dockerBuildAndPushImage( + projectId: String, + pipelineId: String, + vmSeqId: String, + dockerBuildParam: DockerBuildParam, + buildId: String, + elementId: String?, + outer: Boolean + ): Pair { + lateinit var dockerClient: DockerClient + try { + val repoAddr = dockerBuildParam.repoAddr + val userName = dockerBuildParam.userName + val password = dockerBuildParam.password + val config = DefaultDockerClientConfig.createDefaultConfigBuilder() + .withDockerConfig(dockerHostConfig.dockerConfig) + .withApiVersion(dockerHostConfig.apiVersion) + .withRegistryUrl(repoAddr) + .withRegistryUsername(userName) + .withRegistryPassword(password) + .build() + + val longHttpClient: DockerHttpClient = OkDockerHttpClient.Builder() + .dockerHost(config.dockerHost) + .sslConfig(config.sslConfig) + .connectTimeout(5000) + .readTimeout(300000) + .build() + + dockerClient = DockerClientBuilder.getInstance(config).withDockerHttpClient(longHttpClient).build() + val authConfig = AuthConfig() + .withUsername(userName) + .withPassword(password) + .withRegistryAddress(repoAddr) + + val authConfigurations = AuthConfigurations() + authConfigurations.addConfig(authConfig) + + val ticket = dockerBuildParam.ticket + val args = dockerBuildParam.args + ticket.forEach { + val baseConfig = AuthConfig() + .withUsername(it.second) + .withPassword(it.third) + .withRegistryAddress(it.first) + authConfigurations.addConfig(baseConfig) + } + + val workspace = getWorkspace(pipelineId, vmSeqId.toInt(), dockerBuildParam.poolNo ?: "0") + val buildDir = Paths.get(workspace + dockerBuildParam.buildDir).normalize().toString() + val dockerfilePath = Paths.get(workspace + dockerBuildParam.dockerFile).normalize().toString() + val baseDirectory = File(buildDir) + val dockerfile = File(dockerfilePath) +/* val imageNameTag = + getImageNameWithTag( + repoAddr = repoAddr, + projectId = projectId, + imageName = dockerBuildParam.imageName, + imageTag = dockerBuildParam.imageTag, + outer = outer + )*/ + + val imageNameTagSet = mutableSetOf() + if (dockerBuildParam.imageTagList.isNotEmpty()) { + dockerBuildParam.imageTagList.forEach { + imageNameTagSet.add(getImageNameWithTag( + repoAddr = repoAddr, + projectId = projectId, + imageName = dockerBuildParam.imageName, + imageTag = it, + outer = outer + )) + } + } else { + imageNameTagSet.add(getImageNameWithTag( + repoAddr = repoAddr, + projectId = projectId, + imageName = dockerBuildParam.imageName, + imageTag = dockerBuildParam.imageTag, + outer = outer + )) + } + + logger.info("Build docker image, workspace: $workspace, buildDir:$buildDir, dockerfile: $dockerfilePath") + logger.info("Build docker image, imageNameTag: $imageNameTagSet") + val step = dockerClient.buildImageCmd().withNoCache(true) + .withPull(true) + .withBuildAuthConfigs(authConfigurations) + .withBaseDirectory(baseDirectory) + .withDockerfile(dockerfile) + .withTags(imageNameTagSet) + args.map { it.trim().split("=") }.forEach { + step.withBuildArg(it.first(), it.last()) + } + step.exec(MyBuildImageResultCallback(buildId, elementId, dockerHostBuildApi)) + .awaitImageId() + + imageNameTagSet.parallelStream().forEach { + logger.info("Build image success, now push to repo, image name and tag: $it") + dockerClient.pushImageCmd(it) + .withAuthConfig(authConfig) + .exec(MyPushImageResultCallback(buildId, elementId, dockerHostBuildApi)) + .awaitCompletion() + + logger.info("Push image success, now remove local image, image name and tag: $it") + try { + httpLongDockerCli.removeImageCmd(it).exec() + logger.info("Remove local image success") + } catch (e: Throwable) { + logger.error("Docker rmi failed, msg: ${e.message}") + } + } + + return Pair(true, null) + } catch (e: Throwable) { + logger.error("Docker build and push failed, exception: ", e) + val cause = if (e.cause != null && e.cause!!.message != null) { + e.cause!!.message!!.removePrefix(getWorkspace(pipelineId = pipelineId, + vmSeqId = vmSeqId.toInt(), + poolNo = dockerBuildParam.poolNo ?: "0") + ) + } else { + "" + } + + return Pair(false, e.message + if (cause.isBlank()) "" else " cause:【$cause】") + } finally { + try { + dockerClient.close() + } catch (e: IOException) { + logger.error("docker client close exception: ${e.message}") + } + } + } + + fun dockerRun( + projectId: String, + pipelineId: String, + vmSeqId: String, + buildId: String, + dockerRunParam: DockerRunParam + ): Triple> { + try { + val imageName = CommonUtils.normalizeImageName(dockerRunParam.imageName) + // docker pull + try { + LocalImageCache.saveOrUpdate(imageName) + createPullImage( + imageType = ImageType.THIRD.type, + imageName = dockerRunParam.imageName, + registryUser = dockerRunParam.registryUser, + registryPwd = dockerRunParam.registryPwd, + buildId = buildId, + containerId = vmSeqId, + containerHashId = "" + ) + } catch (t: UnauthorizedException) { + val errorMessage = "无权限拉取镜像:$imageName,请检查凭证" + logger.error(errorMessage, t) + // 直接失败,禁止使用本地镜像 + throw NotFoundException(errorMessage) + } catch (t: NotFoundException) { + val errorMessage = "仓库中镜像不存在:$imageName,请检查凭证" + logger.error(errorMessage, t) + // 直接失败,禁止使用本地镜像 + throw NotFoundException(errorMessage) + } catch (t: Throwable) { + logger.warn("Fail to pull the image $imageName of build $buildId", t, "") + log( + buildId = buildId, + message = "拉取镜像失败,错误信息:${t.message}", + tag = VMUtils.genStartVMTaskId(vmSeqId), + containerHashId = "" + ) + log( + buildId = buildId, + message = "尝试使用本地镜像执行命令...", + tag = VMUtils.genStartVMTaskId(vmSeqId), + containerHashId = "" + ) + } + + val dockerBuildInfo = DockerHostBuildInfo( + projectId = projectId, + agentId = "", + pipelineId = pipelineId, + buildId = buildId, + vmSeqId = vmSeqId.toInt(), + secretKey = "", + status = PipelineTaskStatus.RUNNING.status, + imageName = imageName, + containerId = "", + wsInHost = true, + poolNo = if (dockerRunParam.poolNo == null) 0 else dockerRunParam.poolNo!!.toInt(), + registryUser = dockerRunParam.registryUser, + registryPwd = dockerRunParam.registryPwd, + imageType = ImageType.THIRD.type, + imagePublicFlag = false, + imageRDType = null, + containerHashId = "" + ) + // docker run + val env = mutableListOf() + env.addAll(DockerEnvLoader.loadEnv(dockerBuildInfo)) + env.add("bk_devops_start_source=dockerRun") // dockerRun启动标识 + dockerRunParam.env?.forEach { + env.add("${it.key}=${it.value ?: ""}") + } + logger.info("env is $env") + val binds = DockerBindLoader.loadBinds(dockerBuildInfo) + + val dockerRunPortBindingList = mutableListOf() + val hostIp = CommonUtils.getInnerIP() + val portBindings = Ports() + dockerRunParam.portList?.forEach { + val localPort = getAvailableHostPort() + if (localPort == 0) { + throw ContainerException( + errorCodeEnum = ErrorCodeEnum.NO_AVAILABLE_PORT_ERROR, + message = "No enough port to use in dockerRun. startPort: ${dockerHostConfig.dockerRunStartPort}" + ) + } + val tcpContainerPort: ExposedPort = ExposedPort.tcp(it) + portBindings.bind(tcpContainerPort, Ports.Binding.bindPort(localPort)) + dockerRunPortBindingList.add(DockerRunPortBinding(hostIp, it, localPort)) + } + + val containerName = + "dockerRun-${dockerBuildInfo.buildId}-${dockerBuildInfo.vmSeqId}-${RandomUtil.randomString()}" + + val container = if (dockerRunParam.command.isEmpty() || dockerRunParam.command.equals("[]")) { + httpLongDockerCli.createContainerCmd(imageName) + .withName(containerName) + .withEnv(env) + .withVolumes(DockerVolumeLoader.loadVolumes(dockerBuildInfo)) + .withHostConfig(HostConfig() + .withBinds(binds).withNetworkMode("bridge").withPortBindings(portBindings)) + .withWorkingDir(dockerHostConfig.volumeWorkspace) + .exec() + } else { + httpLongDockerCli.createContainerCmd(imageName) + .withName(containerName) + .withCmd(dockerRunParam.command) + .withEnv(env) + .withVolumes(DockerVolumeLoader.loadVolumes(dockerBuildInfo)) + .withHostConfig(HostConfig() + .withBinds(binds).withNetworkMode("bridge").withPortBindings(portBindings)) + .withWorkingDir(dockerHostConfig.volumeWorkspace) + .exec() + } + + logger.info("Created container $container") + val timestamp = (System.currentTimeMillis() / 1000).toInt() + httpLongDockerCli.startContainerCmd(container.id).exec() + + return Triple(container.id, timestamp, dockerRunPortBindingList) + } catch (er: Throwable) { + val errorLog = "[$buildId]|启动容器失败,错误信息:${er.message}" + logger.error(errorLog, er) + log(buildId, true, errorLog, VMUtils.genStartVMTaskId(vmSeqId), "") + alertApi.alert( + level = AlertLevel.HIGH.name, title = "Docker构建机创建容器失败", + message = "Docker构建机创建容器失败, 母机IP:${CommonUtils.getInnerIP()}, 失败信息:${er.message}" + ) + throw ContainerException( + errorCodeEnum = ErrorCodeEnum.CREATE_CONTAINER_ERROR, + message = "启动容器失败,错误信息:${er.message}" + ) + } finally { + if (!dockerRunParam.registryUser.isNullOrEmpty()) { + try { + httpLongDockerCli.removeImageCmd(dockerRunParam.imageName) + logger.info("Delete local image successfully......") + } catch (e: java.lang.Exception) { + logger.info("the exception of deleteing local image is ${e.message}") + } finally { + logger.info("Docker run end......") + } + } + } + } + + fun getDockerLogs(containerId: String, lastLogTime: Int): List { + val logs = ArrayList() + val logContainerCmd = httpLongDockerCli.logContainerCmd(containerId) + .withStdOut(true) + .withStdErr(true) + .withSince(lastLogTime) + .withTimestamps(true) + try { + logContainerCmd.exec(object : LogContainerResultCallback() { + override fun onNext(item: Frame) { + logs.add(item.toString()) + } + }).awaitCompletion() + } catch (e: InterruptedException) { + logger.error("Get docker run log exception: ", e) + } + return logs + } + + fun getDockerRunExitCode(containerId: String): Int? { + return try { + httpLongDockerCli.waitContainerCmd(containerId) + .exec(WaitContainerResultCallback()) + .awaitStatusCode(10, TimeUnit.SECONDS) + } catch (e: Exception) { + logger.error("[$containerId]| getDockerRunExitCode error.", e) + Constants.DOCKER_EXIST_CODE + } + } + + /** + * 监控系统负载,超过一定阈值,对于占用负载较高的容器,主动降低负载 + */ + fun monitorSystemLoad() { + logger.info("Monitor|cpu: ${SigarUtil.getAverageLongCpuLoad()}, mem: ${SigarUtil.getAverageLongMemLoad()}") + if (SigarUtil.getAverageLongCpuLoad() > dockerHostConfig.elasticitySystemCpuThreshold ?: 80 || + SigarUtil.getAverageLongMemLoad() > dockerHostConfig.elasticitySystemMemThreshold ?: 80 + ) { + checkContainerStats() + } + } + + private fun checkContainerStats() { + val containerInfo = httpLongDockerCli.listContainersCmd().withStatusFilter(setOf("running")).exec() + for (container in containerInfo) { + val statistics = getContainerStats(container.id) + if (statistics != null) { + val systemCpuUsage = statistics.cpuStats.systemCpuUsage ?: 0 + val cpuUsage = statistics.cpuStats.cpuUsage!!.totalUsage ?: 0 + val preSystemCpuUsage = statistics.preCpuStats.systemCpuUsage ?: 0 + val preCpuUsage = statistics.preCpuStats.cpuUsage!!.totalUsage ?: 0 + val cpuUsagePer = if ((systemCpuUsage - preSystemCpuUsage) > 0) { + ((cpuUsage - preCpuUsage) * 100) / (systemCpuUsage - preSystemCpuUsage) + } else { + 0 + } + + // 优先判断CPU + val elasticityCpuThreshold = dockerHostConfig.elasticityCpuThreshold ?: 80 + if (cpuUsagePer >= elasticityCpuThreshold) { + // 上报负载超额预警到数据平台 + dockerHostBuildLogResourceApi.sendFormatLog(mapOf( + "containerName" to container.names[0], + "containerId" to container.id, + "cpuUsagePer" to cpuUsagePer.toString(), + "memUsagePer" to "", + "statistics" to JsonUtil.toJson(statistics) + )) + + // 重置容器负载 + resetContainer(container.id) + continue + } + + if (statistics.memoryStats != null && + statistics.memoryStats.usage != null && + statistics.memoryStats.limit != null) { + val memUsage = statistics.memoryStats.usage!! * 100 / statistics.memoryStats.limit!! + val elasticityMemThreshold = dockerHostConfig.elasticityMemThreshold ?: 80 + if (memUsage >= elasticityMemThreshold) { + // 上报负载超额预警到数据平台 + dockerHostBuildLogResourceApi.sendFormatLog(mapOf( + "containerName" to container.names[0], + "containerId" to container.id, + "cpuUsagePer" to cpuUsagePer.toString(), + "memUsagePer" to memUsage.toString(), + "statistics" to JsonUtil.toJson(statistics) + )) + + resetContainer(container.id) + } + } + } + } + } + + private fun getContainerStats(containerId: String): Statistics? { + val asyncResultCallback = InvocationBuilder.AsyncResultCallback() + httpDockerCli.statsCmd(containerId).withNoStream(true).exec(asyncResultCallback) + return try { + val stats = asyncResultCallback.awaitResult() + stats + } catch (e: Exception) { + logger.error("containerId: $containerId get containerStats error.", e) + null + } finally { + asyncResultCallback.close() + } + } + + private fun resetContainer(containerId: String) { + val memReservation = dockerHostConfig.elasticityMemReservation ?: 32 * 1024 * 1024 * 1024L + val cpuPeriod = dockerHostConfig.elasticityCpuPeriod ?: 10000 + val cpuQuota = dockerHostConfig.elasticityCpuQuota ?: 80000 + httpDockerCli.updateContainerCmd(containerId) + .withMemoryReservation(memReservation) + .withCpuPeriod(cpuPeriod) + .withCpuQuota(cpuQuota).exec() + logger.info("<<<< Trigger container reset, containerId: $containerId," + + " memReservation: $memReservation, cpuPeriod: $cpuPeriod, cpuQuota: $cpuQuota") + } + + fun clearContainers() { + val containerInfo = httpLongDockerCli.listContainersCmd().withStatusFilter(setOf("exited")).exec() + for (container in containerInfo) { + try { + val finishTime = httpLongDockerCli.inspectContainerCmd(container.id).exec().state.finishedAt + // 是否已退出30分钟 + if (checkFinishTime(finishTime)) { + logger.info("Clear container, containerId: ${container.id}") + httpLongDockerCli.removeContainerCmd(container.id).exec() + } + } catch (e: Exception) { + logger.error("Clear container failed, containerId: ${container.id}", e) + } + } + } + + fun clearDockerRunTimeoutContainers() { + val containerInfo = httpLongDockerCli.listContainersCmd().withStatusFilter(setOf("running")).exec() + for (container in containerInfo) { + try { + val startTime = httpLongDockerCli.inspectContainerCmd(container.id).exec().state.startedAt + val envs = httpLongDockerCli.inspectContainerCmd(container.id).exec().config.env + // 是否是dockerRun启动的并且已运行超过8小时 + if (envs != null && envs.contains("bk_devops_start_source=dockerRun") && checkStartTime(startTime)) { + logger.info("Clear dockerRun timeout container, containerId: ${container.id}") + httpLongDockerCli.stopContainerCmd(container.id).withTimeout(15).exec() + } + } catch (e: Exception) { + logger.error("Clear dockerRun timeout container failed, containerId: ${container.id}", e) + } + } + } + + @PostConstruct + fun loadLocalImages() { + try { + val imageList = httpLongDockerCli.listImagesCmd().withShowAll(true).exec() + logger.info("load local images, image count: ${imageList.size}") + imageList.forEach c@{ + it.repoTags?.forEach { image -> + LocalImageCache.saveOrUpdate(image) + } + } + } catch (e: java.lang.Exception) { + logger.error("load local image, exception, msg: ${e.message}") + } + } + + fun clearLocalImages() { + val danglingImages = httpLongDockerCli.listImagesCmd().withDanglingFilter(true).withShowAll(true).exec() + danglingImages.forEach { + try { + httpLongDockerCli.removeImageCmd(it.id).exec() + logger.info("remove local dangling image success, image id: ${it.id}") + } catch (e: java.lang.Exception) { + logger.error("remove local dangling image exception ${e.message}") + } + } + + val publicImages = getPublicImages() + val imageList = httpLongDockerCli.listImagesCmd().withShowAll(true).exec() + imageList.forEach c@{ + if (it.repoTags == null || it.repoTags.isEmpty()) { + return@c + } + it.repoTags.forEach t@{ image -> + if (publicImages.contains(image)) { + logger.info("skip public image: $image") + return@t + } + + val lastUsedDate = LocalImageCache.getDate(image) + if (null != lastUsedDate) { + val days = TimeUnit.MILLISECONDS.toDays(Date().time - lastUsedDate.time) + if (days >= dockerHostConfig.localImageCacheDays) { + logger.info("remove local image, ${it.repoTags}") + try { + httpLongDockerCli.removeImageCmd(image).exec() + logger.info("remove local image success, image: $image") + } catch (e: java.lang.Exception) { + logger.error("remove local image exception ${e.message}") + } + return@c + } + } + } + } + } + + fun isContainerRunning(containerId: String): Boolean { + try { + logger.info("Check container: $containerId start.") + val inspectContainerResponse = httpLongDockerCli.inspectContainerCmd(containerId).exec() ?: return false + logger.info("Check container: $containerId status: ${inspectContainerResponse.state}") + return inspectContainerResponse.state.running ?: false + } catch (e: Exception) { + logger.error("check container: $containerId status failed.", e) + return false + } + } + + fun getContainerState(containerId: String): InspectContainerResponse.ContainerState? { + try { + logger.info("Get containerState: $containerId start.") + val inspectContainerResponse = httpDockerCli.inspectContainerCmd(containerId).exec() ?: return null + logger.info("Get containerState: $containerId state: ${inspectContainerResponse.state}") + return inspectContainerResponse.state + } catch (e: Exception) { + logger.error("check container: $containerId state failed, return ", e) + return null + } + } + + fun refreshDockerIpStatus(): Boolean? { + val port = environment.getProperty("local.server.port") + return dockerHostBuildApi.refreshDockerIpStatus(port!!, getContainerNum())!!.data + } + + private fun getPublicImages(): List { + val result = mutableListOf() + val publicImages = dockerHostBuildApi.getPublicImages().data!! + publicImages.filter { it.publicFlag && it.rdType == ImageRDTypeEnum.SELF_DEVELOPED }.forEach { + result.add("${it.repoUrl}/${it.repoName}:${it.repoTag}") + } + return result + } + + private fun getImageNameWithTag( + repoAddr: String, + projectId: String, + imageName: String, + imageTag: String, + outer: Boolean = false + ): String { + return if (outer) { + "$repoAddr/$imageName:$imageTag" + } else { + "$repoAddr/paas/$projectId/$imageName:$imageTag" + } + } + + private fun getWorkspace(pipelineId: String, vmSeqId: Int, poolNo: String): String { + return "${dockerHostConfig.hostPathWorkspace}/$pipelineId/${getTailPath(vmSeqId, poolNo.toInt())}/" + } + + private fun getTailPath(vmSeqId: Int, poolNo: Int): String { + return if (poolNo > 1) { + "$vmSeqId" + "_$poolNo" + } else { + vmSeqId.toString() + } + } + + private fun checkFinishTime(utcTime: String?): Boolean { + if (utcTime != null && utcTime.isNotEmpty()) { + val array = utcTime.split(".") + val utcTimeLocal = array[0] + "Z" + val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") + sdf.timeZone = TimeZone.getTimeZone("UTC") + + val date = sdf.parse(utcTimeLocal) + val finishTimestamp = date.time + val nowTimestamp = System.currentTimeMillis() + return (nowTimestamp - finishTimestamp) > (30 * 60 * 1000) + } + + return true + } + + private fun checkStartTime(utcTime: String?): Boolean { + if (utcTime != null && utcTime.isNotEmpty()) { + val array = utcTime.split(".") + val utcTimeLocal = array[0] + "Z" + val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") + sdf.timeZone = TimeZone.getTimeZone("UTC") + + val date = sdf.parse(utcTimeLocal) + val startTimestamp = date.time + val nowTimestamp = System.currentTimeMillis() + return (nowTimestamp - startTimestamp) > (8 * 3600 * 1000) + } + + return false + } + + private fun getAvailableHostPort(): Int { + val startPort = dockerHostConfig.dockerRunStartPort ?: 20000 + for (i in startPort..(startPort + 1000)) { + if (!CommonUtils.isPortUsing("127.0.0.1", i)) { + return i + } else { + continue + } + } + + return 0 + } + + inner class MyBuildImageResultCallback internal constructor( + private val buildId: String, + private val elementId: String?, + private val dockerHostBuildApi: DockerHostBuildResourceApi + ) : BuildImageResultCallback() { + override fun onNext(item: BuildResponseItem?) { + val text = item?.stream + if (null != text) { + dockerHostBuildApi.postLog( + buildId, + false, + StringUtils.removeEnd(text, "\n"), + elementId + ) + } + + super.onNext(item) + } + } + + inner class MyPushImageResultCallback internal constructor( + private val buildId: String, + private val elementId: String?, + private val dockerHostBuildApi: DockerHostBuildResourceApi + ) : PushImageResultCallback() { + private val totalList = mutableListOf() + private val step = mutableMapOf() + override fun onNext(item: PushResponseItem?) { + val text = item?.progressDetail + if (null != text && text.current != null && text.total != null && text.total != 0L) { + val lays = if (!totalList.contains(text.total!!)) { + totalList.add(text.total!!) + totalList.size + 1 + } else { + totalList.indexOf(text.total!!) + 1 + } + var currentProgress = text.current!! * 100 / text.total!! + if (currentProgress > 100) { + currentProgress = 100 + } + if (currentProgress >= step[lays]?.plus(25) ?: 5) { + dockerHostBuildApi.postLog( + buildId, + false, + "正在推送镜像,第${lays}层,进度:$currentProgress%", + elementId + ) + step[lays] = currentProgress + } + } + super.onNext(item) + } + } +} diff --git a/src/backend/ci/core/environment/build.gradle.kts b/src/backend/ci/core/environment/build.gradle.kts index 71153054c15..aad984c00c1 100644 --- a/src/backend/ci/core/environment/build.gradle.kts +++ b/src/backend/ci/core/environment/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.environment" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.environment" +} diff --git a/src/backend/ci/core/image/build.gradle.kts b/src/backend/ci/core/image/build.gradle.kts index 54cf0b1bbc2..aa9e76e4efe 100644 --- a/src/backend/ci/core/image/build.gradle.kts +++ b/src/backend/ci/core/image/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.image" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.image" +} diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/cron/impl/IndexCleanJobESImpl.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/cron/impl/IndexCleanJobESImpl.kt index 24a223bad66..df336429cef 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/cron/impl/IndexCleanJobESImpl.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/cron/impl/IndexCleanJobESImpl.kt @@ -1,154 +1,154 @@ -/* - * 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.log.cron.impl - -import com.tencent.devops.common.api.exception.OperationException -import com.tencent.devops.common.redis.RedisLock -import com.tencent.devops.common.redis.RedisOperation -import com.tencent.devops.log.client.LogClient -import com.tencent.devops.log.configuration.StorageProperties -import com.tencent.devops.log.cron.IndexCleanJob -import com.tencent.devops.log.util.IndexNameUtils.LOG_INDEX_PREFIX -import org.elasticsearch.action.admin.indices.close.CloseIndexRequest -import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest -import org.elasticsearch.client.indices.GetIndexRequest -import org.elasticsearch.client.RequestOptions -import org.elasticsearch.client.RestHighLevelClient -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty -import org.springframework.scheduling.annotation.Scheduled -import org.springframework.stereotype.Component -import java.time.LocalDateTime -import java.time.temporal.ChronoUnit - -@Component -@ConditionalOnProperty(prefix = "log.storage", name = ["type"], havingValue = "elasticsearch") -class IndexCleanJobESImpl @Autowired constructor( - private val storageProperties: StorageProperties, - private val client: LogClient, - private val redisOperation: RedisOperation -) : IndexCleanJob { - - private var closeIndexInDay = storageProperties.closeInDay ?: Int.MAX_VALUE - private var deleteIndexInDay = storageProperties.deleteInDay ?: Int.MAX_VALUE - - /** - * 2 am every day - */ - @Scheduled(cron = "0 0 2 * * ?") - override fun cleanIndex() { - logger.info("Start to clean index") - val redisLock = RedisLock(redisOperation, ES_INDEX_CLOSE_JOB_KEY, 20) - try { - if (!redisLock.tryLock()) { - logger.info("The other process is processing clean job, ignore") - return - } - closeESIndexes() - deleteESIndexes() - } catch (t: Throwable) { - logger.warn("Fail to clean the index", t) - } finally { - redisLock.unlock() - } - } - - override fun updateExpireIndexDay(expired: Int) { - logger.warn("Update the expire index day from $expired to ${this.closeIndexInDay}") - if (expired <= 10) { - logger.warn("The expired is illegal") - throw OperationException("Expired is illegal") - } - this.closeIndexInDay = expired - } - - override fun getExpireIndexDay() = closeIndexInDay - - private fun closeESIndexes() { - client.getActiveClients().forEach { c -> - val response = c.restClient - .indices() - .get(GetIndexRequest("$LOG_INDEX_PREFIX*"), RequestOptions.DEFAULT) - val indexNames = response.indices - logger.info("Get all indices in es[${c.clusterName}] line: $indexNames") - if (indexNames.isEmpty()) { - return - } - - val deathLine = LocalDateTime.now() - .minus(closeIndexInDay.toLong(), ChronoUnit.DAYS) - logger.info("Get the death line - ($deathLine)") - indexNames.forEach { index -> - if (expire(deathLine, index)) { - closeESIndex(c.restClient, index) - } - } - } - } - - private fun closeESIndex(c: RestHighLevelClient, index: String) { - logger.info("[$index] Start to close ES index") - val resp = c.indices() - .close(CloseIndexRequest(index), RequestOptions.DEFAULT) - logger.info("Get the close es response - ${resp.isAcknowledged}") - } - - private fun deleteESIndexes() { - client.getActiveClients().forEach { c -> - val response = c.restClient - .indices() - .get(GetIndexRequest(), RequestOptions.DEFAULT) - - if (response.indices.isEmpty()) { - return - } - - val deathLine = LocalDateTime.now() - .minus(deleteIndexInDay.toLong(), ChronoUnit.DAYS) - logger.info("Get the death line - ($deathLine)") - response.indices.forEach { index -> - if (expire(deathLine, index)) { - deleteESIndex(c.restClient, index) - } - } - } - } - - private fun deleteESIndex(c: RestHighLevelClient, index: String) { - logger.info("[$index] Start to delete ES index") - val resp = c.indices() - .delete(DeleteIndexRequest(index), RequestOptions.DEFAULT) - logger.info("Get the delete es response - ${resp.isAcknowledged}") - } - - companion object { - private val logger = LoggerFactory.getLogger(IndexCleanJobESImpl::class.java) - private const val ES_INDEX_CLOSE_JOB_KEY = "log:es:index:close:job:lock:key" - } -} +/* + * 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.log.cron.impl + +import com.tencent.devops.common.api.exception.OperationException +import com.tencent.devops.common.redis.RedisLock +import com.tencent.devops.common.redis.RedisOperation +import com.tencent.devops.log.client.LogClient +import com.tencent.devops.log.configuration.StorageProperties +import com.tencent.devops.log.cron.IndexCleanJob +import com.tencent.devops.log.util.IndexNameUtils.LOG_INDEX_PREFIX +import org.elasticsearch.client.indices.CloseIndexRequest +import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest +import org.elasticsearch.client.indices.GetIndexRequest +import org.elasticsearch.client.RequestOptions +import org.elasticsearch.client.RestHighLevelClient +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty +import org.springframework.scheduling.annotation.Scheduled +import org.springframework.stereotype.Component +import java.time.LocalDateTime +import java.time.temporal.ChronoUnit + +@Component +@ConditionalOnProperty(prefix = "log.storage", name = ["type"], havingValue = "elasticsearch") +class IndexCleanJobESImpl @Autowired constructor( + private val storageProperties: StorageProperties, + private val client: LogClient, + private val redisOperation: RedisOperation +) : IndexCleanJob { + + private var closeIndexInDay = storageProperties.closeInDay ?: Int.MAX_VALUE + private var deleteIndexInDay = storageProperties.deleteInDay ?: Int.MAX_VALUE + + /** + * 2 am every day + */ + @Scheduled(cron = "0 0 2 * * ?") + override fun cleanIndex() { + logger.info("Start to clean index") + val redisLock = RedisLock(redisOperation, ES_INDEX_CLOSE_JOB_KEY, 20) + try { + if (!redisLock.tryLock()) { + logger.info("The other process is processing clean job, ignore") + return + } + closeESIndexes() + deleteESIndexes() + } catch (t: Throwable) { + logger.warn("Fail to clean the index", t) + } finally { + redisLock.unlock() + } + } + + override fun updateExpireIndexDay(expired: Int) { + logger.warn("Update the expire index day from $expired to ${this.closeIndexInDay}") + if (expired <= 10) { + logger.warn("The expired is illegal") + throw OperationException("Expired is illegal") + } + this.closeIndexInDay = expired + } + + override fun getExpireIndexDay() = closeIndexInDay + + private fun closeESIndexes() { + client.getActiveClients().forEach { c -> + val response = c.restClient + .indices() + .get(GetIndexRequest("$LOG_INDEX_PREFIX*"), RequestOptions.DEFAULT) + val indexNames = response.indices + logger.info("Get all indices in es[${c.clusterName}] line: $indexNames") + if (indexNames.isEmpty()) { + return + } + + val deathLine = LocalDateTime.now() + .minus(closeIndexInDay.toLong(), ChronoUnit.DAYS) + logger.info("Get the death line - ($deathLine)") + indexNames.forEach { index -> + if (expire(deathLine, index)) { + closeESIndex(c.restClient, index) + } + } + } + } + + private fun closeESIndex(c: RestHighLevelClient, index: String) { + logger.info("[$index] Start to close ES index") + val resp = c.indices() + .close(CloseIndexRequest(index), RequestOptions.DEFAULT) + logger.info("Get the close es response - ${resp.isAcknowledged}") + } + + private fun deleteESIndexes() { + client.getActiveClients().forEach { c -> + val response = c.restClient + .indices() + .get(GetIndexRequest(), RequestOptions.DEFAULT) + + if (response.indices.isEmpty()) { + return + } + + val deathLine = LocalDateTime.now() + .minus(deleteIndexInDay.toLong(), ChronoUnit.DAYS) + logger.info("Get the death line - ($deathLine)") + response.indices.forEach { index -> + if (expire(deathLine, index)) { + deleteESIndex(c.restClient, index) + } + } + } + } + + private fun deleteESIndex(c: RestHighLevelClient, index: String) { + logger.info("[$index] Start to delete ES index") + val resp = c.indices() + .delete(DeleteIndexRequest(index), RequestOptions.DEFAULT) + logger.info("Get the delete es response - ${resp.isAcknowledged}") + } + + companion object { + private val logger = LoggerFactory.getLogger(IndexCleanJobESImpl::class.java) + private const val ES_INDEX_CLOSE_JOB_KEY = "log:es:index:close:job:lock:key" + } +} diff --git a/src/backend/ci/core/log/build.gradle.kts b/src/backend/ci/core/log/build.gradle.kts index d4eba2f19da..2790d798f20 100644 --- a/src/backend/ci/core/log/build.gradle.kts +++ b/src/backend/ci/core/log/build.gradle.kts @@ -27,12 +27,4 @@ subprojects { group = "com.tencent.bk.devops.ci.log" - dependencies { - // FIXME 解决依赖冲突:process要求lucene-8.6.0,es-rest-client7.0.0要求lucene-8.0.0 - api("org.apache.lucene:lucene-core:8.0.0") - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } } diff --git a/src/backend/ci/core/misc/build.gradle.kts b/src/backend/ci/core/misc/build.gradle.kts index c38059d89ca..f92243f92cc 100644 --- a/src/backend/ci/core/misc/build.gradle.kts +++ b/src/backend/ci/core/misc/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.misc" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - api("junit:junit") - api("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.misc" +} diff --git a/src/backend/ci/core/monitoring/build.gradle.kts b/src/backend/ci/core/monitoring/build.gradle.kts index 9db21311561..12fd3cd975e 100644 --- a/src/backend/ci/core/monitoring/build.gradle.kts +++ b/src/backend/ci/core/monitoring/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.monitoring" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.monitoring" +} diff --git a/src/backend/ci/core/notify/build.gradle.kts b/src/backend/ci/core/notify/build.gradle.kts index a7e7dd8ee29..fe171257971 100644 --- a/src/backend/ci/core/notify/build.gradle.kts +++ b/src/backend/ci/core/notify/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.notify" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.notify" +} diff --git a/src/backend/ci/core/openapi/build.gradle.kts b/src/backend/ci/core/openapi/build.gradle.kts index 6c10657f8e8..3ce2d649a65 100644 --- a/src/backend/ci/core/openapi/build.gradle.kts +++ b/src/backend/ci/core/openapi/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.openapi" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.openapi" +} diff --git a/src/backend/ci/core/plugin/build.gradle.kts b/src/backend/ci/core/plugin/build.gradle.kts index 88f90c44c96..ffc3453e59c 100644 --- a/src/backend/ci/core/plugin/build.gradle.kts +++ b/src/backend/ci/core/plugin/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.plugin" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.plugin" +} diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/jmx/api/ProcessJmxApi.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/jmx/api/ProcessJmxApi.kt index 042f1e3972f..1f7dd7b5456 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/jmx/api/ProcessJmxApi.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/jmx/api/ProcessJmxApi.kt @@ -1,89 +1,89 @@ -/* - * 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.process.jmx.api - -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.jmx.export.MBeanExporter -import org.springframework.stereotype.Component -import java.util.HashMap -import javax.management.ObjectName - -@Suppress("ALL") -@Component -class ProcessJmxApi @Autowired constructor(private val mBeanExporter: MBeanExporter) { - - private val apis = HashMap() - - fun execute(api: String, elapse: Long) { - try { - getBean(api).execute(elapse) - } catch (ignored: Throwable) { - logger.warn("Fail to record the api performance of api $api", ignored) - } - } - - private fun getBean(api: String): APIPerformanceBean { - var bean = apis[api] - if (bean == null) { - synchronized(this) { - bean = apis[api] - if (bean == null) { - bean = APIPerformanceBean(api) - val name = "com.tencent.devops.process:type=apiPerformance,name=$api" - logger.info("Register $api api performance mbean") - mBeanExporter.registerManagedResource(bean, ObjectName(name)) - apis[api] = bean!! - } - } - } - return bean!! - } - - companion object { - private val logger = LoggerFactory.getLogger(ProcessJmxApi::class.java) - - val LIST_PIPELINES = "listPipelines" - val LIST_PIPELINES_STATUS = "listPipelinesStatus" - val LIST_BUILDS_DETAIL = "listBuildsDetail" - - val PIPELINE_CREATE = "pipelineCreate" - val PIPELINE_EDIT = "pipelineEdit" - val PIPELINE_DELETE = "pipelineDelete" - - val LIST_APP_PIPELINES = "listAppPipelines" - val LIST_PERMISSION_PIPELINES = "listPermPipelines" - val LIST_NEW_PIPELINES = "listNewPipelines" - val LIST_NEW_PIPELINES_STATUS = "listNewPipelinesStatus" - val LIST_NEW_BUILDS_DETAIL = "listNewBuildsDetail" - - val NEW_PIPELINE_CREATE = "newPipelineCreate" - val NEW_PIPELINE_EDIT = "newPipelineEdit" - val NEW_PIPELINE_DELETE = "newPipelineDelete" - } -} +/* + * 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.process.jmx.api + +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.jmx.export.MBeanExporter +import org.springframework.stereotype.Component +import java.util.HashMap +import javax.management.ObjectName + +@Suppress("ALL") +@Component +class ProcessJmxApi @Autowired constructor(private val mBeanExporter: MBeanExporter) { + + private val apis = HashMap() + + fun execute(api: String, elapse: Long) { + try { + getBean(api).execute(elapse) + } catch (ignored: Throwable) { + logger.warn("Fail to record the api performance of api $api", ignored) + } + } + + private fun getBean(api: String): APIPerformanceBean { + var bean = apis[api] + if (bean == null) { + synchronized(this) { + bean = apis[api] + if (bean == null) { + bean = APIPerformanceBean(api) + val name = "com.tencent.devops.process:type=apiPerformance,name=$api" + logger.info("Register $api api performance mbean") + mBeanExporter.registerManagedResource(bean!!, ObjectName(name)) + apis[api] = bean!! + } + } + } + return bean!! + } + + companion object { + private val logger = LoggerFactory.getLogger(ProcessJmxApi::class.java) + + val LIST_PIPELINES = "listPipelines" + val LIST_PIPELINES_STATUS = "listPipelinesStatus" + val LIST_BUILDS_DETAIL = "listBuildsDetail" + + val PIPELINE_CREATE = "pipelineCreate" + val PIPELINE_EDIT = "pipelineEdit" + val PIPELINE_DELETE = "pipelineDelete" + + val LIST_APP_PIPELINES = "listAppPipelines" + val LIST_PERMISSION_PIPELINES = "listPermPipelines" + val LIST_NEW_PIPELINES = "listNewPipelines" + val LIST_NEW_PIPELINES_STATUS = "listNewPipelinesStatus" + val LIST_NEW_BUILDS_DETAIL = "listNewBuildsDetail" + + val NEW_PIPELINE_CREATE = "newPipelineCreate" + val NEW_PIPELINE_EDIT = "newPipelineEdit" + val NEW_PIPELINE_DELETE = "newPipelineDelete" + } +} diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/jmx/elements/JmxElements.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/jmx/elements/JmxElements.kt index 1e8143ece19..52c518de606 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/jmx/elements/JmxElements.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/jmx/elements/JmxElements.kt @@ -1,79 +1,79 @@ -/* - * 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.process.jmx.elements - -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.jmx.export.MBeanExporter -import org.springframework.stereotype.Component -import java.util.HashMap -import javax.management.ObjectName - -@Suppress("ALL") -@Component -class JmxElements @Autowired constructor(private val mbeanExporter: MBeanExporter) { - - private val types = HashMap() - - fun execute(elementType: String) { - try { - getBean(elementType).execute() - } catch (ignored: Throwable) { - logger.warn("Fail to record the element execution", ignored) - } - } - - fun fail(elementType: String) { - try { - getBean(elementType).fail() - } catch (ignored: Throwable) { - logger.warn("Fail to record the failure element execution", ignored) - } - } - - private fun getBean(elementType: String): ElementBean { - var bean = types[elementType] - if (bean == null) { - synchronized(this) { - bean = types[elementType] - if (bean == null) { - bean = ElementBean(elementType) - val name = "com.tencent.devops.process:type=elements,name=$elementType" - logger.info("Register $elementType mbean") - mbeanExporter.registerManagedResource(bean, ObjectName(name)) - types[elementType] = bean!! - } - } - } - return bean!! - } - - companion object { - private val logger = LoggerFactory.getLogger(JmxElements::class.java) - } -} +/* + * 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.process.jmx.elements + +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.jmx.export.MBeanExporter +import org.springframework.stereotype.Component +import java.util.HashMap +import javax.management.ObjectName + +@Suppress("ALL") +@Component +class JmxElements @Autowired constructor(private val mbeanExporter: MBeanExporter) { + + private val types = HashMap() + + fun execute(elementType: String) { + try { + getBean(elementType).execute() + } catch (ignored: Throwable) { + logger.warn("Fail to record the element execution", ignored) + } + } + + fun fail(elementType: String) { + try { + getBean(elementType).fail() + } catch (ignored: Throwable) { + logger.warn("Fail to record the failure element execution", ignored) + } + } + + private fun getBean(elementType: String): ElementBean { + var bean = types[elementType] + if (bean == null) { + synchronized(this) { + bean = types[elementType] + if (bean == null) { + bean = ElementBean(elementType) + val name = "com.tencent.devops.process:type=elements,name=$elementType" + logger.info("Register $elementType mbean") + mbeanExporter.registerManagedResource(bean!!, ObjectName(name)) + types[elementType] = bean!! + } + } + } + return bean!! + } + + companion object { + private val logger = LoggerFactory.getLogger(JmxElements::class.java) + } +} diff --git a/src/backend/ci/core/process/build.gradle.kts b/src/backend/ci/core/process/build.gradle.kts index 27ed5ceb87b..887d3a0e142 100644 --- a/src/backend/ci/core/process/build.gradle.kts +++ b/src/backend/ci/core/process/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.process" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.process" +} diff --git a/src/backend/ci/core/process/plugin-load/src/main/kotlin/com/tencent/devops/process/plugin/load/ContainerBizPluginLoader.kt b/src/backend/ci/core/process/plugin-load/src/main/kotlin/com/tencent/devops/process/plugin/load/ContainerBizPluginLoader.kt index da96539fd8f..df508c5fbc1 100644 --- a/src/backend/ci/core/process/plugin-load/src/main/kotlin/com/tencent/devops/process/plugin/load/ContainerBizPluginLoader.kt +++ b/src/backend/ci/core/process/plugin-load/src/main/kotlin/com/tencent/devops/process/plugin/load/ContainerBizPluginLoader.kt @@ -1,58 +1,58 @@ -/* - * 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.process.plugin.load - -import com.tencent.devops.common.pipeline.container.Container -import com.tencent.devops.process.plugin.ContainerBizPlugin -import com.tencent.devops.process.plugin.annotation.ContainerBiz -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.config.BeanPostProcessor -import org.springframework.core.annotation.AnnotationUtils -import org.springframework.stereotype.Component - -@Component -class ContainerBizPluginLoader : BeanPostProcessor { - - private val logger = LoggerFactory.getLogger(ContainerBizPluginLoader::class.java) - - override fun postProcessBeforeInitialization(bean: Any?, p1: String?): Any { - return bean!! - } - - override fun postProcessAfterInitialization(bean: Any?, p1: String?): Any { - val containerBiz = AnnotationUtils.findAnnotation(bean!!::class.java, ContainerBiz::class.java) - if (containerBiz != null) { - if (bean is ContainerBizPlugin) { - ContainerBizRegistrar.register(bean) - } else { - logger.warn("${bean::class.java} is not match for $containerBiz") - } - } - return bean - } -} +/* + * 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.process.plugin.load + +import com.tencent.devops.common.pipeline.container.Container +import com.tencent.devops.process.plugin.ContainerBizPlugin +import com.tencent.devops.process.plugin.annotation.ContainerBiz +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.config.BeanPostProcessor +import org.springframework.core.annotation.AnnotationUtils +import org.springframework.stereotype.Component + +@Component +class ContainerBizPluginLoader : BeanPostProcessor { + + private val logger = LoggerFactory.getLogger(ContainerBizPluginLoader::class.java) + + override fun postProcessBeforeInitialization(bean: Any, p1: String): Any { + return bean + } + + override fun postProcessAfterInitialization(bean: Any, p1: String): Any { + val containerBiz = AnnotationUtils.findAnnotation(bean::class.java, ContainerBiz::class.java) + if (containerBiz != null) { + if (bean is ContainerBizPlugin) { + ContainerBizRegistrar.register(bean) + } else { + logger.warn("${bean::class.java} is not match for $containerBiz") + } + } + return bean + } +} diff --git a/src/backend/ci/core/process/plugin-load/src/main/kotlin/com/tencent/devops/process/plugin/load/ElementBizPluginLoader.kt b/src/backend/ci/core/process/plugin-load/src/main/kotlin/com/tencent/devops/process/plugin/load/ElementBizPluginLoader.kt index 284bb620cdd..b03927d97e7 100644 --- a/src/backend/ci/core/process/plugin-load/src/main/kotlin/com/tencent/devops/process/plugin/load/ElementBizPluginLoader.kt +++ b/src/backend/ci/core/process/plugin-load/src/main/kotlin/com/tencent/devops/process/plugin/load/ElementBizPluginLoader.kt @@ -1,58 +1,58 @@ -/* - * 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.process.plugin.load - -import com.tencent.devops.common.pipeline.pojo.element.Element -import com.tencent.devops.process.plugin.ElementBizPlugin -import com.tencent.devops.process.plugin.annotation.ElementBiz -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.config.BeanPostProcessor -import org.springframework.core.annotation.AnnotationUtils -import org.springframework.stereotype.Component - -@Component -class ElementBizPluginLoader : BeanPostProcessor { - - private val logger = LoggerFactory.getLogger(ElementBizPluginLoader::class.java) - - override fun postProcessBeforeInitialization(bean: Any?, p1: String?): Any { - return bean!! - } - - override fun postProcessAfterInitialization(bean: Any?, p1: String?): Any { - val elementBiz = AnnotationUtils.findAnnotation(bean!!::class.java, ElementBiz::class.java) - if (elementBiz != null) { - if (bean is ElementBizPlugin) { - ElementBizRegistrar.register(bean) - } else { - logger.warn("${bean::class.java} is not match for $elementBiz") - } - } - return bean - } -} +/* + * 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.process.plugin.load + +import com.tencent.devops.common.pipeline.pojo.element.Element +import com.tencent.devops.process.plugin.ElementBizPlugin +import com.tencent.devops.process.plugin.annotation.ElementBiz +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.config.BeanPostProcessor +import org.springframework.core.annotation.AnnotationUtils +import org.springframework.stereotype.Component + +@Component +class ElementBizPluginLoader : BeanPostProcessor { + + private val logger = LoggerFactory.getLogger(ElementBizPluginLoader::class.java) + + override fun postProcessBeforeInitialization(bean: Any, p1: String): Any { + return bean + } + + override fun postProcessAfterInitialization(bean: Any, p1: String): Any { + val elementBiz = AnnotationUtils.findAnnotation(bean::class.java, ElementBiz::class.java) + if (elementBiz != null) { + if (bean is ElementBizPlugin) { + ElementBizRegistrar.register(bean) + } else { + logger.warn("${bean::class.java} is not match for $elementBiz") + } + } + return bean + } +} diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/jmx/api/ProjectJmxApi.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/jmx/api/ProjectJmxApi.kt index 6bdaea05d9f..16bcb924e41 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/jmx/api/ProjectJmxApi.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/jmx/api/ProjectJmxApi.kt @@ -1,74 +1,74 @@ -/* - * 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.project.jmx.api - -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.jmx.export.MBeanExporter -import org.springframework.stereotype.Component -import java.util.HashMap -import javax.management.ObjectName - -@Component -class ProjectJmxApi @Autowired constructor(private val mBeanExporter: MBeanExporter) { - - private val apis = HashMap() - - fun execute(api: String, elapse: Long, success: Boolean) { - try { - getBean(api).execute(elapse, success) - } catch (ignored: Throwable) { - logger.warn("Fail to record the api performance of api $api", ignored) - } - } - - private fun getBean(api: String): APIPerformanceBean { - var bean = apis[api] - if (bean == null) { - synchronized(this) { - bean = apis[api] - if (bean == null) { - bean = APIPerformanceBean() - val name = "com.tencent.devops.project:type=apiPerformance,name=$api" - logger.info("Register $api api performance mbean") - mBeanExporter.registerManagedResource(bean, ObjectName(name)) - apis[api] = bean!! - } - } - } - return bean!! - } - - companion object { - private val logger = LoggerFactory.getLogger(ProjectJmxApi::class.java) - - const val PROJECT_LIST = "project_list" - const val PROJECT_CREATE = "project_create" - const val PROJECT_UPDATE = "project_update" - } -} +/* + * 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.project.jmx.api + +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.jmx.export.MBeanExporter +import org.springframework.stereotype.Component +import java.util.HashMap +import javax.management.ObjectName + +@Component +class ProjectJmxApi @Autowired constructor(private val mBeanExporter: MBeanExporter) { + + private val apis = HashMap() + + fun execute(api: String, elapse: Long, success: Boolean) { + try { + getBean(api).execute(elapse, success) + } catch (ignored: Throwable) { + logger.warn("Fail to record the api performance of api $api", ignored) + } + } + + private fun getBean(api: String): APIPerformanceBean { + var bean = apis[api] + if (bean == null) { + synchronized(this) { + bean = apis[api] + if (bean == null) { + bean = APIPerformanceBean() + val name = "com.tencent.devops.project:type=apiPerformance,name=$api" + logger.info("Register $api api performance mbean") + mBeanExporter.registerManagedResource(bean!!, ObjectName(name)) + apis[api] = bean!! + } + } + } + return bean!! + } + + companion object { + private val logger = LoggerFactory.getLogger(ProjectJmxApi::class.java) + + const val PROJECT_LIST = "project_list" + const val PROJECT_CREATE = "project_create" + const val PROJECT_UPDATE = "project_update" + } +} diff --git a/src/backend/ci/core/project/build.gradle.kts b/src/backend/ci/core/project/build.gradle.kts index eae2c339633..e1b8ac6a565 100644 --- a/src/backend/ci/core/project/build.gradle.kts +++ b/src/backend/ci/core/project/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.project" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.project" +} diff --git a/src/backend/ci/core/quality/build.gradle.kts b/src/backend/ci/core/quality/build.gradle.kts index 15877793568..423001bd464 100644 --- a/src/backend/ci/core/quality/build.gradle.kts +++ b/src/backend/ci/core/quality/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.quality" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.quality" +} diff --git a/src/backend/ci/core/repository/build.gradle.kts b/src/backend/ci/core/repository/build.gradle.kts index 6bb4452604f..f1253d458bd 100644 --- a/src/backend/ci/core/repository/build.gradle.kts +++ b/src/backend/ci/core/repository/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.repository" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.repository" +} diff --git a/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/config/SignExecutorConfig.kt b/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/config/SignExecutorConfig.kt index 0edddfa435e..3aa7c326e68 100644 --- a/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/config/SignExecutorConfig.kt +++ b/src/backend/ci/core/sign/biz-sign/src/main/kotlin/com/tencent/devops/sign/config/SignExecutorConfig.kt @@ -1,58 +1,58 @@ -/* - * 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.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.scheduling.annotation.EnableAsync -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor -import java.util.concurrent.Executor -import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy - -@Configuration -@EnableAsync -@Suppress("ALL") -class SignExecutorConfig { - - @Bean(name = ["asyncSignExecutor"]) - fun asyncExecutor(): Executor { - val executor = ThreadPoolTaskExecutor() - executor.corePoolSize = 10 - executor.maxPoolSize = 15 - executor.setQueueCapacity(25) - executor.keepAliveSeconds = 200 - executor.threadNamePrefix = "asyncSign-" - executor.setRejectedExecutionHandler(CallerRunsPolicy()) - // 等待所有任务都完成再继续销毁其他的Bean - executor.setWaitForTasksToCompleteOnShutdown(true) - // 线程池中任务的等待时间,如果超过这个时候还没有销毁就强制销毁,以确保应用最后能够被关闭,而不是阻塞住 - executor.setAwaitTerminationSeconds(60) - executor.initialize() - return executor - } -} +/* + * 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.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.scheduling.annotation.EnableAsync +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor +import java.util.concurrent.Executor +import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy + +@Configuration +@EnableAsync +@Suppress("ALL") +class SignExecutorConfig { + + @Bean(name = ["asyncSignExecutor"]) + fun asyncExecutor(): Executor { + val executor = ThreadPoolTaskExecutor() + executor.corePoolSize = 10 + executor.maxPoolSize = 15 + executor.setQueueCapacity(25) + executor.keepAliveSeconds = 200 + executor.setThreadNamePrefix("asyncSign-") + executor.setRejectedExecutionHandler(CallerRunsPolicy()) + // 等待所有任务都完成再继续销毁其他的Bean + executor.setWaitForTasksToCompleteOnShutdown(true) + // 线程池中任务的等待时间,如果超过这个时候还没有销毁就强制销毁,以确保应用最后能够被关闭,而不是阻塞住 + executor.setAwaitTerminationSeconds(60) + executor.initialize() + return executor + } +} diff --git a/src/backend/ci/core/sign/build.gradle.kts b/src/backend/ci/core/sign/build.gradle.kts index 6a502bd2ed3..43b22e3f106 100644 --- a/src/backend/ci/core/sign/build.gradle.kts +++ b/src/backend/ci/core/sign/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.sign" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.sign" +} diff --git a/src/backend/ci/core/store/build.gradle.kts b/src/backend/ci/core/store/build.gradle.kts index 80a67f29356..60273768716 100644 --- a/src/backend/ci/core/store/build.gradle.kts +++ b/src/backend/ci/core/store/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.store" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.store" +} diff --git a/src/backend/ci/core/ticket/build.gradle.kts b/src/backend/ci/core/ticket/build.gradle.kts index 2459e1283cd..d6b79e81e3a 100644 --- a/src/backend/ci/core/ticket/build.gradle.kts +++ b/src/backend/ci/core/ticket/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.ticket" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.ticket" +} diff --git a/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/configuration/WebSocketConfig.kt b/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/configuration/WebSocketConfig.kt index 1b5e3fe8fa4..0fd77c6089a 100644 --- a/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/configuration/WebSocketConfig.kt +++ b/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/configuration/WebSocketConfig.kt @@ -1,104 +1,104 @@ -/* - * 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.websocket.configuration - -import com.tencent.devops.common.redis.RedisOperation -import com.tencent.devops.websocket.handler.BKHandshakeInterceptor -import com.tencent.devops.websocket.handler.SessionWebSocketHandlerDecoratorFactory -import com.tencent.devops.websocket.servcie.WebsocketService -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Value -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.messaging.simp.config.ChannelRegistration -import org.springframework.messaging.simp.config.MessageBrokerRegistry -import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer -import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker -import org.springframework.web.socket.config.annotation.StompEndpointRegistry -import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration - -@Suppress("ALL") -@Configuration -@EnableWebSocketMessageBroker -class WebSocketConfig @Autowired constructor( - private val bkHandshake: BKHandshakeInterceptor, - private val websocketService: WebsocketService, - private val redisOperation: RedisOperation -) : AbstractWebSocketMessageBrokerConfigurer() { - - @Value("\${thread.min:8}") - private val min: Int = 8 - - @Value("\${ws.cacheLimit:3600}") - private val cacheLimit: Int = 3600 - - companion object { - private val logger = LoggerFactory.getLogger(WebSocketConfig::class.java) - } - - override fun configureMessageBroker(config: MessageBrokerRegistry) { - config.setCacheLimit(cacheLimit) - config.enableSimpleBroker("/topic") - config.setApplicationDestinationPrefixes("/app") - } - - override fun registerStompEndpoints(registry: StompEndpointRegistry) { - registry.addEndpoint("/ws/user").addInterceptors(bkHandshake).setAllowedOrigins("*").withSockJS() - } - - @Override - override fun configureClientInboundChannel(registration: ChannelRegistration) { - var defaultCorePoolSize = min - if (defaultCorePoolSize < Runtime.getRuntime().availableProcessors() * 2) { - defaultCorePoolSize = Runtime.getRuntime().availableProcessors() * 2 - } - registration.taskExecutor().corePoolSize(defaultCorePoolSize) - .maxPoolSize(defaultCorePoolSize * 2) - .keepAliveSeconds(60) - } - - @Override - override fun configureClientOutboundChannel(registration: ChannelRegistration) { - var defaultCorePoolSize = min - if (defaultCorePoolSize < Runtime.getRuntime().availableProcessors() * 2) { - defaultCorePoolSize = Runtime.getRuntime().availableProcessors() * 2 - } - registration.taskExecutor().corePoolSize(defaultCorePoolSize).maxPoolSize(defaultCorePoolSize * 2) - } - - override fun configureWebSocketTransport(registration: WebSocketTransportRegistration?) { - registration?.addDecoratorFactory(wsHandlerDecoratorFactory()) - super.configureWebSocketTransport(registration) - } - - @Bean - fun wsHandlerDecoratorFactory(): SessionWebSocketHandlerDecoratorFactory? { - return SessionWebSocketHandlerDecoratorFactory(websocketService, redisOperation) - } -} +/* + * 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.websocket.configuration + +import com.tencent.devops.common.redis.RedisOperation +import com.tencent.devops.websocket.handler.BKHandshakeInterceptor +import com.tencent.devops.websocket.handler.SessionWebSocketHandlerDecoratorFactory +import com.tencent.devops.websocket.servcie.WebsocketService +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.messaging.simp.config.ChannelRegistration +import org.springframework.messaging.simp.config.MessageBrokerRegistry +import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer +import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker +import org.springframework.web.socket.config.annotation.StompEndpointRegistry +import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration + +@Suppress("ALL") +@Configuration +@EnableWebSocketMessageBroker +class WebSocketConfig @Autowired constructor( + private val bkHandshake: BKHandshakeInterceptor, + private val websocketService: WebsocketService, + private val redisOperation: RedisOperation +) : AbstractWebSocketMessageBrokerConfigurer() { + + @Value("\${thread.min:8}") + private val min: Int = 8 + + @Value("\${ws.cacheLimit:3600}") + private val cacheLimit: Int = 3600 + + companion object { + private val logger = LoggerFactory.getLogger(WebSocketConfig::class.java) + } + + override fun configureMessageBroker(config: MessageBrokerRegistry) { + config.setCacheLimit(cacheLimit) + config.enableSimpleBroker("/topic") + config.setApplicationDestinationPrefixes("/app") + } + + override fun registerStompEndpoints(registry: StompEndpointRegistry) { + registry.addEndpoint("/ws/user").addInterceptors(bkHandshake).setAllowedOrigins("*").withSockJS() + } + + @Override + override fun configureClientInboundChannel(registration: ChannelRegistration) { + var defaultCorePoolSize = min + if (defaultCorePoolSize < Runtime.getRuntime().availableProcessors() * 2) { + defaultCorePoolSize = Runtime.getRuntime().availableProcessors() * 2 + } + registration.taskExecutor().corePoolSize(defaultCorePoolSize) + .maxPoolSize(defaultCorePoolSize * 2) + .keepAliveSeconds(60) + } + + @Override + override fun configureClientOutboundChannel(registration: ChannelRegistration) { + var defaultCorePoolSize = min + if (defaultCorePoolSize < Runtime.getRuntime().availableProcessors() * 2) { + defaultCorePoolSize = Runtime.getRuntime().availableProcessors() * 2 + } + registration.taskExecutor().corePoolSize(defaultCorePoolSize).maxPoolSize(defaultCorePoolSize * 2) + } + + override fun configureWebSocketTransport(registration: WebSocketTransportRegistration) { + registration.addDecoratorFactory(wsHandlerDecoratorFactory()) + super.configureWebSocketTransport(registration) + } + + @Bean + fun wsHandlerDecoratorFactory(): SessionWebSocketHandlerDecoratorFactory { + return SessionWebSocketHandlerDecoratorFactory(websocketService, redisOperation) + } +} diff --git a/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/BKHandshakeInterceptor.kt b/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/BKHandshakeInterceptor.kt index 889b0b17f6c..cf96ade5fba 100644 --- a/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/BKHandshakeInterceptor.kt +++ b/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/BKHandshakeInterceptor.kt @@ -1,82 +1,82 @@ -/* - * 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.websocket.handler - -import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID -import com.tencent.devops.common.redis.RedisOperation -import com.tencent.devops.common.websocket.utils.RedisUtlis -import com.tencent.devops.websocket.servcie.WebsocketService -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.http.server.ServerHttpRequest -import org.springframework.http.server.ServerHttpResponse -import org.springframework.http.server.ServletServerHttpRequest -import org.springframework.stereotype.Component -import org.springframework.web.socket.WebSocketHandler -import org.springframework.web.socket.server.HandshakeInterceptor - -@Component -class BKHandshakeInterceptor @Autowired constructor( - val redisOperation: RedisOperation, - val websocketService: WebsocketService -) : HandshakeInterceptor { - companion object { - private val logger = LoggerFactory.getLogger(this::class.java) - } - - override fun afterHandshake( - request: ServerHttpRequest?, - response: ServerHttpResponse?, - wsHandler: WebSocketHandler?, - exception: Exception? - ) { - if (request is ServletServerHttpRequest) { - val sessionId = request.servletRequest.getParameter("sessionId") - val userId = request.servletRequest.getHeader(AUTH_HEADER_DEVOPS_USER_ID) - if (userId != null && sessionId != null) { - RedisUtlis.writeSessionIdByRedis(redisOperation, userId, sessionId) - logger.info( - "[WebSocket]-[$userId]-[$sessionId]-连接成功,redisData:${RedisUtlis.getSessionIdByUserId( - redisOperation, - userId - )}" - ) - websocketService.createTimeoutSession(sessionId, userId) - } - } - } - - override fun beforeHandshake( - request: ServerHttpRequest?, - response: ServerHttpResponse?, - wsHandler: WebSocketHandler?, - attributes: MutableMap? - ): Boolean { - return true - } -} +/* + * 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.websocket.handler + +import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID +import com.tencent.devops.common.redis.RedisOperation +import com.tencent.devops.common.websocket.utils.RedisUtlis +import com.tencent.devops.websocket.servcie.WebsocketService +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.server.ServerHttpRequest +import org.springframework.http.server.ServerHttpResponse +import org.springframework.http.server.ServletServerHttpRequest +import org.springframework.stereotype.Component +import org.springframework.web.socket.WebSocketHandler +import org.springframework.web.socket.server.HandshakeInterceptor + +@Component +class BKHandshakeInterceptor @Autowired constructor( + val redisOperation: RedisOperation, + val websocketService: WebsocketService +) : HandshakeInterceptor { + companion object { + private val logger = LoggerFactory.getLogger(this::class.java) + } + + override fun afterHandshake( + request: ServerHttpRequest, + response: ServerHttpResponse, + wsHandler: WebSocketHandler, + exception: Exception? + ) { + if (request is ServletServerHttpRequest) { + val sessionId = request.servletRequest.getParameter("sessionId") + val userId = request.servletRequest.getHeader(AUTH_HEADER_DEVOPS_USER_ID) + if (userId != null && sessionId != null) { + RedisUtlis.writeSessionIdByRedis(redisOperation, userId, sessionId) + logger.info( + "[WebSocket]-[$userId]-[$sessionId]-连接成功,redisData:${RedisUtlis.getSessionIdByUserId( + redisOperation, + userId + )}" + ) + websocketService.createTimeoutSession(sessionId, userId) + } + } + } + + override fun beforeHandshake( + request: ServerHttpRequest, + response: ServerHttpResponse, + wsHandler: WebSocketHandler, + attributes: MutableMap + ): Boolean { + return true + } +} diff --git a/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/SessionHandler.kt b/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/SessionHandler.kt index 49f3797948a..90b0fafee41 100644 --- a/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/SessionHandler.kt +++ b/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/SessionHandler.kt @@ -1,89 +1,85 @@ -/* - * 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.websocket.handler - -import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID -import com.tencent.devops.common.redis.RedisOperation -import com.tencent.devops.common.websocket.utils.RedisUtlis -import com.tencent.devops.websocket.servcie.WebsocketService -import com.tencent.devops.websocket.utils.HostUtils -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.web.socket.CloseStatus -import org.springframework.web.socket.WebSocketHandler -import org.springframework.web.socket.WebSocketSession -import org.springframework.web.socket.handler.WebSocketHandlerDecorator - -class SessionHandler @Autowired constructor( - delegate: WebSocketHandler?, - private val websocketService: WebsocketService, - private val redisOperation: RedisOperation -) : WebSocketHandlerDecorator(delegate) { - - // 链接关闭记录去除session - override fun afterConnectionClosed(session: WebSocketSession?, closeStatus: CloseStatus?) { - val uri = session?.uri - if (closeStatus?.code != CloseStatus.NORMAL.code && closeStatus?.code != CloseStatus.PROTOCOL_ERROR.code) { - logger.warn("websocket close abnormal, [$closeStatus] [${session?.uri}] [${session?.remoteAddress}]") - } - val sessionId = HostUtils.getRealSession(session?.uri?.query) - if (sessionId.isNullOrEmpty()) { - logger.warn("connection closed can not find sessionId, $uri| ${session?.remoteAddress}") - super.afterConnectionClosed(session, closeStatus) - } - val page = RedisUtlis.getPageFromSessionPageBySession(redisOperation, sessionId!!) - val userId = RedisUtlis.getUserBySession(redisOperation, sessionId) - if (userId.isNullOrEmpty()) { - logger.warn("connection closed can not find userId, $uri| ${session?.remoteAddress}| $sessionId") - super.afterConnectionClosed(session, closeStatus) - } else { - logger.info("connection closed closeStatus[$closeStatus] user[$userId] page[$page], session[$sessionId]") - websocketService.clearAllBySession(userId!!, sessionId) - } - - super.afterConnectionClosed(session, closeStatus) - } - - override fun afterConnectionEstablished(session: WebSocketSession?) { - val uri = session?.uri - val remoteId = session?.remoteAddress - if (session == null) { - logger.warn("connection warm: session is empty, $uri") - return super.afterConnectionEstablished(session) - } - val sessionId = uri?.query?.substringAfter("sessionId=") - val webUser = session.handshakeHeaders[AUTH_HEADER_DEVOPS_USER_ID] - websocketService.addCacheSession(sessionId!!) - logger.info("connection success: |$sessionId| $uri | $remoteId | $webUser ") - super.afterConnectionEstablished(session) - } - - companion object { - private val logger = LoggerFactory.getLogger(this::class.java) - } -} +/* + * 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.websocket.handler + +import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID +import com.tencent.devops.common.redis.RedisOperation +import com.tencent.devops.common.websocket.utils.RedisUtlis +import com.tencent.devops.websocket.servcie.WebsocketService +import com.tencent.devops.websocket.utils.HostUtils +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.web.socket.CloseStatus +import org.springframework.web.socket.WebSocketHandler +import org.springframework.web.socket.WebSocketSession +import org.springframework.web.socket.handler.WebSocketHandlerDecorator + +class SessionHandler @Autowired constructor( + delegate: WebSocketHandler, + private val websocketService: WebsocketService, + private val redisOperation: RedisOperation +) : WebSocketHandlerDecorator(delegate) { + + // 链接关闭记录去除session + override fun afterConnectionClosed(session: WebSocketSession, closeStatus: CloseStatus) { + val uri = session.uri + if (closeStatus.code != CloseStatus.NORMAL.code && closeStatus.code != CloseStatus.PROTOCOL_ERROR.code) { + logger.warn("websocket close abnormal, [$closeStatus] [${session.uri}] [${session.remoteAddress}]") + } + val sessionId = HostUtils.getRealSession(session.uri?.query) + if (sessionId.isNullOrEmpty()) { + logger.warn("connection closed can not find sessionId, $uri| ${session.remoteAddress}") + super.afterConnectionClosed(session, closeStatus) + } + val page = RedisUtlis.getPageFromSessionPageBySession(redisOperation, sessionId!!) + val userId = RedisUtlis.getUserBySession(redisOperation, sessionId) + if (userId.isNullOrEmpty()) { + logger.warn("connection closed can not find userId, $uri| ${session?.remoteAddress}| $sessionId") + super.afterConnectionClosed(session, closeStatus) + } else { + logger.info("connection closed closeStatus[$closeStatus] user[$userId] page[$page], session[$sessionId]") + websocketService.clearAllBySession(userId, sessionId) + } + + super.afterConnectionClosed(session, closeStatus) + } + + override fun afterConnectionEstablished(session: WebSocketSession) { + val uri = session.uri + val remoteId = session.remoteAddress + val sessionId = uri?.query?.substringAfter("sessionId=") + val webUser = session.handshakeHeaders[AUTH_HEADER_DEVOPS_USER_ID] + websocketService.addCacheSession(sessionId!!) + logger.info("connection success: |$sessionId| $uri | $remoteId | $webUser ") + super.afterConnectionEstablished(session) + } + + companion object { + private val logger = LoggerFactory.getLogger(this::class.java) + } +} diff --git a/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/SessionWebSocketHandlerDecoratorFactory.kt b/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/SessionWebSocketHandlerDecoratorFactory.kt index c136c719eda..3d7d05e853b 100644 --- a/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/SessionWebSocketHandlerDecoratorFactory.kt +++ b/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/handler/SessionWebSocketHandlerDecoratorFactory.kt @@ -1,44 +1,44 @@ -/* - * 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.websocket.handler - -import com.tencent.devops.common.redis.RedisOperation -import com.tencent.devops.websocket.servcie.WebsocketService -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.web.socket.WebSocketHandler -import org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory - -class SessionWebSocketHandlerDecoratorFactory @Autowired constructor( - private val websocketService: WebsocketService, - private val redisOperation: RedisOperation -) : WebSocketHandlerDecoratorFactory { - - override fun decorate(handler: WebSocketHandler?): WebSocketHandler { - return SessionHandler(handler, websocketService, redisOperation) - } -} +/* + * 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.websocket.handler + +import com.tencent.devops.common.redis.RedisOperation +import com.tencent.devops.websocket.servcie.WebsocketService +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.web.socket.WebSocketHandler +import org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory + +class SessionWebSocketHandlerDecoratorFactory @Autowired constructor( + private val websocketService: WebsocketService, + private val redisOperation: RedisOperation +) : WebSocketHandlerDecoratorFactory { + + override fun decorate(handler: WebSocketHandler): WebSocketHandler { + return SessionHandler(handler, websocketService, redisOperation) + } +} diff --git a/src/backend/ci/core/websocket/build.gradle.kts b/src/backend/ci/core/websocket/build.gradle.kts index b773448a695..170be78ca08 100644 --- a/src/backend/ci/core/websocket/build.gradle.kts +++ b/src/backend/ci/core/websocket/build.gradle.kts @@ -1,36 +1,30 @@ -/* - * 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. - */ - -subprojects { - group = "com.tencent.bk.devops.ci.websocket" - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} +/* + * 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. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.websocket" +} diff --git a/src/backend/ci/gradle.properties b/src/backend/ci/gradle.properties index 08a7461dda6..912cb83c84c 100644 --- a/src/backend/ci/gradle.properties +++ b/src/backend/ci/gradle.properties @@ -1,46 +1,47 @@ -# -# 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. -# -kotlin.incremental=true -systemProp.file.encoding=utf-8 -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -org.gradle.daemon=true -org.gradle.daemon.idleTimeout=3600000 -#systemProp.http.proxyHost= -#systemProp.http.proxyPort= -#systemProp.https.proxyHost= -#systemProp.https.proxyPort= -MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public -MAVEN_REPO_DEPLOY_URL= -MAVEN_REPO_USERNAME= -MAVEN_REPO_PASSWORD= -MAVEN_REPO_SNAPSHOT_URL= -MAVEN_REPO_SNAPSHOT_DEPLOY_URL= -MAVEN_REPO_SNAPSHOT_USERNAME= -MAVEN_REPO_SNAPSHOT_PASSWORD= -DB_HOST=127.0.0.1:3306 -DB_USERNAME=root -DB_PASSWORD=root -DB_PREFIX=devops_ci_ +# +# 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. +# +kotlin.incremental=true +systemProp.file.encoding=utf-8 +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m +org.gradle.daemon=true +org.gradle.daemon.idleTimeout=3600000 +#systemProp.http.proxyHost= +#systemProp.http.proxyPort= +#systemProp.https.proxyHost= +#systemProp.https.proxyPort= +MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public +MAVEN_REPO_DEPLOY_URL= +MAVEN_REPO_USERNAME= +MAVEN_REPO_PASSWORD= +MAVEN_REPO_SNAPSHOT_URL= +MAVEN_REPO_SNAPSHOT_DEPLOY_URL= +MAVEN_REPO_SNAPSHOT_USERNAME= +MAVEN_REPO_SNAPSHOT_PASSWORD= +DB_HOST=127.0.0.1:3306 +DB_USERNAME=root +DB_PASSWORD=root +DB_PREFIX=devops_ci_ +devopsBootVersion=0.0.3 diff --git a/src/backend/ci/settings.gradle.kts b/src/backend/ci/settings.gradle.kts index a7a615a0185..25df9c15887 100644 --- a/src/backend/ci/settings.gradle.kts +++ b/src/backend/ci/settings.gradle.kts @@ -27,6 +27,18 @@ rootProject.name = "bk-ci-backend" +pluginManagement { + val devopsBootVersion: String by settings + plugins { + id("com.tencent.devops.boot") version devopsBootVersion + } + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + } +} + // Single CI Service include(":boot-assembly") From b69402ffdef7cf48a059f73b068b0b2d9538fd9c Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 6 Jul 2021 12:24:58 +0800 Subject: [PATCH 006/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/gradle.properties | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/backend/ci/gradle.properties b/src/backend/ci/gradle.properties index 912cb83c84c..76b0d618f4b 100644 --- a/src/backend/ci/gradle.properties +++ b/src/backend/ci/gradle.properties @@ -25,9 +25,6 @@ # kotlin.incremental=true systemProp.file.encoding=utf-8 -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -org.gradle.daemon=true -org.gradle.daemon.idleTimeout=3600000 #systemProp.http.proxyHost= #systemProp.http.proxyPort= #systemProp.https.proxyHost= From e554e160317a24be643adb4e40320c8bd3588779 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 7 Jul 2021 10:54:58 +0800 Subject: [PATCH 007/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/boot-assembly/build.gradle.kts | 4 - src/backend/ci/build.gradle.kts | 3 +- src/backend/ci/buildSrc/build.gradle.kts | 6 +- .../kotlin/plugins/task-gen-jooq.gradle.kts | 3 +- .../task-spring-boot-package.gradle.kts | 70 --------- .../boot-artifactory/build.gradle.kts | 76 +++++----- .../ci/core/auth/boot-auth/build.gradle.kts | 66 ++++----- .../boot-dispatch-docker/build.gradle.kts | 72 +++++----- .../dispatch/boot-dispatch/build.gradle.kts | 72 +++++----- .../boot-dockerhost/build.gradle.kts | 4 - .../boot-environment/build.gradle.kts | 72 +++++----- .../ci/core/image/boot-image/build.gradle.kts | 72 +++++----- .../ci/core/log/boot-log/build.gradle.kts | 70 +++++---- .../ci/core/misc/boot-misc/build.gradle.kts | 76 +++++----- .../boot-monitoring/build.gradle.kts | 66 +++++---- .../core/notify/boot-notify/build.gradle.kts | 68 +++++---- .../openapi/boot-openapi/build.gradle.kts | 4 +- .../core/plugin/boot-plugin/build.gradle.kts | 72 +++++----- .../service/rule/PipelineRuleServiceTest.kt | 134 +++++++++--------- .../process/boot-process/build.gradle.kts | 82 ++++++----- .../project/boot-project/build.gradle.kts | 70 +++++---- .../quality/boot-quality/build.gradle.kts | 74 +++++----- .../boot-repository/build.gradle.kts | 75 +++++----- .../ci/core/sign/boot-sign/build.gradle.kts | 70 +++++---- .../ci/core/store/boot-store/build.gradle.kts | 68 +++++---- .../core/ticket/boot-ticket/build.gradle.kts | 72 +++++----- .../websocket/boot-websocket/build.gradle.kts | 4 +- src/backend/ci/gradle.properties | 1 + 28 files changed, 698 insertions(+), 828 deletions(-) delete mode 100644 src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts diff --git a/src/backend/ci/boot-assembly/build.gradle.kts b/src/backend/ci/boot-assembly/build.gradle.kts index c0a8488b790..e83d4c75cdc 100644 --- a/src/backend/ci/boot-assembly/build.gradle.kts +++ b/src/backend/ci/boot-assembly/build.gradle.kts @@ -62,10 +62,6 @@ dependencies { implementation(project(":core:websocket:biz-websocket-blueking")) } -plugins { - `task-spring-boot-package` -} - configurations.all { exclude(group = "javax.ws.rs", module = "jsr311-api") } diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index 811c4d9536f..0901ab0bbff 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -4,10 +4,9 @@ plugins { apply("$rootDir/detekt.gradle.kts") -allprojects { +subprojects { apply(plugin = "com.tencent.devops.boot") apply(plugin = "maven") - apply(plugin = "io.spring.dependency-management") /************ https://github.com/bkdevops-projects/devops-framework/issues/73 ********/ apply(plugin = "java") diff --git a/src/backend/ci/buildSrc/build.gradle.kts b/src/backend/ci/buildSrc/build.gradle.kts index 3388b1c7c8f..4f8c2a7c8a8 100644 --- a/src/backend/ci/buildSrc/build.gradle.kts +++ b/src/backend/ci/buildSrc/build.gradle.kts @@ -22,11 +22,9 @@ repositories { // 依赖插件 dependencies { - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72") - implementation("org.jetbrains.kotlin:kotlin-allopen:1.3.72") +// implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72") implementation("nu.studer:gradle-jooq-plugin:5.2.1") - implementation("org.springframework.boot:spring-boot-gradle-plugin:2.3.7.RELEASE") - implementation("io.spring.gradle:dependency-management-plugin:1.0.10.RELEASE") +// implementation("org.springframework.boot:spring-boot-gradle-plugin:2.3.7.RELEASE") implementation("com.github.jengelman.gradle.plugins:shadow:5.2.0") implementation("org.ajoberstar:grgit:1.1.0") } diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts index ef25cf65988..40cfbb90fc4 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts @@ -25,6 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import nu.studer.gradle.jooq.JooqGenerate +import org.gradle.api.tasks.compile.AbstractCompile plugins { id("nu.studer.jooq") @@ -117,7 +118,7 @@ jooq { } } - tasks.getByName("compileKotlin") { + tasks.getByName("compileKotlin") { destinationDir = File("build/generated-src") tasks.matching { it is JooqGenerate }.forEach { println("#task: ${it.name} , group: ${it.group}") diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts deleted file mode 100644 index 963c05b29c3..00000000000 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-spring-boot-package.gradle.kts +++ /dev/null @@ -1,70 +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. - */ -import org.ajoberstar.grgit.Commit -import org.ajoberstar.grgit.Grgit -import org.springframework.boot.gradle.tasks.run.BootRun - -// 设置为release包不带版本号 -version = "" - -plugins { - kotlin("jvm") - id("org.springframework.boot") -} - -tasks { - withType { - jvmArgs = listOf("-Dspring.output.ansi.enabled=ALWAYS", "-Dfile.encoding=UTF-8") - } - - register("copyVersionInfo") { - var gitDir = file("$projectDir/../../../.git") - val commit: Commit? = if (gitDir.exists()) { - gitDir = file("$projectDir/../../../") - Grgit.open(gitDir).head() - } else { - null - } - if (null != commit && File("$projectDir/src/main/resources").exists()) { - File("$projectDir/src/main/resources/version.txt").writeText( - """ - id: ${commit.id} - message: ${commit.fullMessage} - user: ${commit.author.name} - email: ${commit.author.email} - time: ${commit.date} - """ - ) - } - dependsOn("build") - } -} - -configurations.forEach { - it.exclude("ch.qos.logback", "logback-classic") -} - diff --git a/src/backend/ci/core/artifactory/boot-artifactory/build.gradle.kts b/src/backend/ci/core/artifactory/boot-artifactory/build.gradle.kts index 9bd9667cf9d..5a323040791 100644 --- a/src/backend/ci/core/artifactory/boot-artifactory/build.gradle.kts +++ b/src/backend/ci/core/artifactory/boot-artifactory/build.gradle.kts @@ -1,39 +1,37 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) - api(project(":core:artifactory:biz-artifactory")) - api(project(":core:artifactory:biz-artifactory-store")) // 对接研发商店 - api(project(":core:artifactory:biz-artifactory-sample")) // sample 是开源版实现 -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) + api(project(":core:artifactory:biz-artifactory")) + api(project(":core:artifactory:biz-artifactory-store")) // 对接研发商店 + api(project(":core:artifactory:biz-artifactory-sample")) // sample 是开源版实现 +} + + diff --git a/src/backend/ci/core/auth/boot-auth/build.gradle.kts b/src/backend/ci/core/auth/boot-auth/build.gradle.kts index 53fbe43e97d..4fd6a6bad73 100644 --- a/src/backend/ci/core/auth/boot-auth/build.gradle.kts +++ b/src/backend/ci/core/auth/boot-auth/build.gradle.kts @@ -1,35 +1,31 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:auth:biz-auth")) - api(project(":core:auth:biz-auth-blueking")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:auth:biz-auth")) + api(project(":core:auth:biz-auth-blueking")) +} diff --git a/src/backend/ci/core/dispatch-docker/boot-dispatch-docker/build.gradle.kts b/src/backend/ci/core/dispatch-docker/boot-dispatch-docker/build.gradle.kts index 817b59ecf0f..35f36f0d006 100644 --- a/src/backend/ci/core/dispatch-docker/boot-dispatch-docker/build.gradle.kts +++ b/src/backend/ci/core/dispatch-docker/boot-dispatch-docker/build.gradle.kts @@ -1,37 +1,35 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:dispatch-docker:biz-dispatch-docker-sample")) - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:dispatch-docker:biz-dispatch-docker-sample")) + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) +} + + diff --git a/src/backend/ci/core/dispatch/boot-dispatch/build.gradle.kts b/src/backend/ci/core/dispatch/boot-dispatch/build.gradle.kts index d6535acd388..ce06eef4969 100644 --- a/src/backend/ci/core/dispatch/boot-dispatch/build.gradle.kts +++ b/src/backend/ci/core/dispatch/boot-dispatch/build.gradle.kts @@ -1,37 +1,35 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:dispatch:biz-dispatch")) - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:dispatch:biz-dispatch")) + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) +} + + diff --git a/src/backend/ci/core/dockerhost/boot-dockerhost/build.gradle.kts b/src/backend/ci/core/dockerhost/boot-dockerhost/build.gradle.kts index dc2d2c94216..07070f9f06e 100644 --- a/src/backend/ci/core/dockerhost/boot-dockerhost/build.gradle.kts +++ b/src/backend/ci/core/dockerhost/boot-dockerhost/build.gradle.kts @@ -30,7 +30,3 @@ dependencies { api(project(":core:dockerhost:plugin-dockerhost-codecc")) api("com.squareup.okhttp3:okhttp") } - -plugins { - `task-spring-boot-package` -} diff --git a/src/backend/ci/core/environment/boot-environment/build.gradle.kts b/src/backend/ci/core/environment/boot-environment/build.gradle.kts index 804af786b46..a59fd7fd0f6 100644 --- a/src/backend/ci/core/environment/boot-environment/build.gradle.kts +++ b/src/backend/ci/core/environment/boot-environment/build.gradle.kts @@ -1,37 +1,35 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) - api(project(":core:environment:biz-environment-sample")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) + api(project(":core:environment:biz-environment-sample")) +} + + diff --git a/src/backend/ci/core/image/boot-image/build.gradle.kts b/src/backend/ci/core/image/boot-image/build.gradle.kts index 6505da07e24..46d6899d2fe 100644 --- a/src/backend/ci/core/image/boot-image/build.gradle.kts +++ b/src/backend/ci/core/image/boot-image/build.gradle.kts @@ -1,37 +1,35 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) - api(project(":core:image:biz-image")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) + api(project(":core:image:biz-image")) +} + + diff --git a/src/backend/ci/core/log/boot-log/build.gradle.kts b/src/backend/ci/core/log/boot-log/build.gradle.kts index c77236517f8..52e351631e3 100644 --- a/src/backend/ci/core/log/boot-log/build.gradle.kts +++ b/src/backend/ci/core/log/boot-log/build.gradle.kts @@ -1,37 +1,33 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) - api(project(":core:log:biz-log-sample")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) + api(project(":core:log:biz-log-sample")) +} diff --git a/src/backend/ci/core/misc/boot-misc/build.gradle.kts b/src/backend/ci/core/misc/boot-misc/build.gradle.kts index e83822ada45..af98b94a9f6 100644 --- a/src/backend/ci/core/misc/boot-misc/build.gradle.kts +++ b/src/backend/ci/core/misc/boot-misc/build.gradle.kts @@ -1,39 +1,37 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:misc:biz-misc-sample")) - // 无对接权限中心,根据common.yml配置文件项auth.idProvider=samle启用,会忽略下面蓝鲸权限中心实现 - api(project(":core:common:common-auth:common-auth-mock")) - // 对接蓝鲸的权限中心实现, 根据common.yml配置项auth.idProvider=bk_login值来决定加载 - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:misc:biz-misc-sample")) + // 无对接权限中心,根据common.yml配置文件项auth.idProvider=samle启用,会忽略下面蓝鲸权限中心实现 + api(project(":core:common:common-auth:common-auth-mock")) + // 对接蓝鲸的权限中心实现, 根据common.yml配置项auth.idProvider=bk_login值来决定加载 + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) +} + + diff --git a/src/backend/ci/core/monitoring/boot-monitoring/build.gradle.kts b/src/backend/ci/core/monitoring/boot-monitoring/build.gradle.kts index e9bddcf96f3..88913a39c30 100644 --- a/src/backend/ci/core/monitoring/boot-monitoring/build.gradle.kts +++ b/src/backend/ci/core/monitoring/boot-monitoring/build.gradle.kts @@ -1,34 +1,32 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:monitoring:biz-monitoring-sample")) // 开源版实现 -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:monitoring:biz-monitoring-sample")) // 开源版实现 +} + + diff --git a/src/backend/ci/core/notify/boot-notify/build.gradle.kts b/src/backend/ci/core/notify/boot-notify/build.gradle.kts index 819752fd069..e28ef47fbe3 100644 --- a/src/backend/ci/core/notify/boot-notify/build.gradle.kts +++ b/src/backend/ci/core/notify/boot-notify/build.gradle.kts @@ -1,35 +1,33 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:notify:biz-notify")) // 开源版实现 - api(project(":core:notify:biz-notify-blueking")) // 对接蓝鲸实现 -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:notify:biz-notify")) // 开源版实现 + api(project(":core:notify:biz-notify-blueking")) // 对接蓝鲸实现 +} + + diff --git a/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts b/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts index 34005c31349..12e66314bce 100644 --- a/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts +++ b/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts @@ -33,6 +33,4 @@ dependencies { runtimeOnly("io.jsonwebtoken:jjwt-impl") runtimeOnly("io.jsonwebtoken:jjwt-jackson") } -plugins { - `task-spring-boot-package` -} + diff --git a/src/backend/ci/core/plugin/boot-plugin/build.gradle.kts b/src/backend/ci/core/plugin/boot-plugin/build.gradle.kts index 06b2546973d..c723030f990 100644 --- a/src/backend/ci/core/plugin/boot-plugin/build.gradle.kts +++ b/src/backend/ci/core/plugin/boot-plugin/build.gradle.kts @@ -1,38 +1,34 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:plugin:biz-plugin")) - api(project(":core:plugin:codecc-plugin:biz-codecc")) - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:plugin:biz-plugin")) + api(project(":core:plugin:codecc-plugin:biz-codecc")) + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) +} diff --git a/src/backend/ci/core/process/biz-base/src/test/kotlin/com/tencent/devops/process/engine/service/rule/PipelineRuleServiceTest.kt b/src/backend/ci/core/process/biz-base/src/test/kotlin/com/tencent/devops/process/engine/service/rule/PipelineRuleServiceTest.kt index 70b50c2ba2a..fb415cf944a 100644 --- a/src/backend/ci/core/process/biz-base/src/test/kotlin/com/tencent/devops/process/engine/service/rule/PipelineRuleServiceTest.kt +++ b/src/backend/ci/core/process/biz-base/src/test/kotlin/com/tencent/devops/process/engine/service/rule/PipelineRuleServiceTest.kt @@ -1,67 +1,67 @@ -/* - * 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.process.engine.service.rule - -import com.nhaarman.mockito_kotlin.mock -import com.tencent.devops.common.api.util.JsonUtil -import com.tencent.devops.common.redis.RedisOperation -import com.tencent.devops.process.engine.dao.PipelineRuleDao -import org.jooq.DSLContext -import org.junit.Assert -import org.junit.jupiter.api.Test - -internal class PipelineRuleServiceTest { - - private val dslContext: DSLContext = mock() - private val pipelineRuleDao: PipelineRuleDao = mock() - private val redisOperation: RedisOperation = mock() - - private val pipelineRuleService = PipelineRuleService( - dslContext = dslContext, - pipelineRuleDao = pipelineRuleDao, - redisOperation = redisOperation - ) - - @Test - fun generateReplaceRuleStr() { - val ruleStr = "\${{YEAR}}_\${{DAY_OF_MONTH}}-\${{FORMAT_DATE:\"yyyy-MM-dd HH:mm:ss\"}}" - val validRuleValueMap = mutableMapOf() - validRuleValueMap["YEAR"] = "2020" - validRuleValueMap["DAY_OF_MONTH"] = "28" - validRuleValueMap["FORMAT_DATE:\"yyyy-MM-dd HH:mm:ss\""] = "2021-04-28 15:28:00" - val replaceRuleStr = pipelineRuleService.generateReplaceRuleStr(ruleStr, validRuleValueMap) - Assert.assertEquals(replaceRuleStr, "2020_28-2021-04-28 15:28:00") - } - - @Test - fun getRuleNameList() { - val ruleStr = "\${{YEAR}}_\${{DAY_OF_MONTH}}-\${{FORMAT_DATE:\"yyyy-MM-dd HH:mm:ss\"}}}" - val ruleValue = JsonUtil.toJson(pipelineRuleService.getRuleNameList(ruleStr)) - Assert.assertEquals(ruleValue, "[ \"YEAR\", \"DAY_OF_MONTH\", \"FORMAT_DATE:\\\"yyyy-MM-dd HH:mm:ss\\\"\" ]") - } -} +/* + * 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.process.engine.service.rule + +import com.nhaarman.mockito_kotlin.mock +import com.tencent.devops.common.api.util.JsonUtil +import com.tencent.devops.common.redis.RedisOperation +import com.tencent.devops.process.engine.dao.PipelineRuleDao +import org.jooq.DSLContext +import org.junit.Assert +import org.junit.jupiter.api.Test + +class PipelineRuleServiceTest { + + private val dslContext: DSLContext = mock() + private val pipelineRuleDao: PipelineRuleDao = mock() + private val redisOperation: RedisOperation = RedisOperation(mock()) + + private val pipelineRuleService = PipelineRuleService( + dslContext = dslContext, + pipelineRuleDao = pipelineRuleDao, + redisOperation = redisOperation + ) + + @Test + fun generateReplaceRuleStr() { + val ruleStr = "\${{YEAR}}_\${{DAY_OF_MONTH}}-\${{FORMAT_DATE:\"yyyy-MM-dd HH:mm:ss\"}}" + val validRuleValueMap = mutableMapOf() + validRuleValueMap["YEAR"] = "2020" + validRuleValueMap["DAY_OF_MONTH"] = "28" + validRuleValueMap["FORMAT_DATE:\"yyyy-MM-dd HH:mm:ss\""] = "2021-04-28 15:28:00" + val replaceRuleStr = pipelineRuleService.generateReplaceRuleStr(ruleStr, validRuleValueMap) + Assert.assertEquals(replaceRuleStr, "2020_28-2021-04-28 15:28:00") + } + + @Test + fun getRuleNameList() { + val ruleStr = "\${{YEAR}}_\${{DAY_OF_MONTH}}-\${{FORMAT_DATE:\"yyyy-MM-dd HH:mm:ss\"}}}" + val ruleValue = JsonUtil.toJson(pipelineRuleService.getRuleNameList(ruleStr)) + Assert.assertEquals(ruleValue, "[ \"YEAR\", \"DAY_OF_MONTH\", \"FORMAT_DATE:\\\"yyyy-MM-dd HH:mm:ss\\\"\" ]") + } +} diff --git a/src/backend/ci/core/process/boot-process/build.gradle.kts b/src/backend/ci/core/process/boot-process/build.gradle.kts index 1193811df36..f71310d10da 100644 --- a/src/backend/ci/core/process/boot-process/build.gradle.kts +++ b/src/backend/ci/core/process/boot-process/build.gradle.kts @@ -1,42 +1,40 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:process:plugin-load")) - api(project(":core:process:plugin-trigger")) - api(project(":core:common:common-archive")) - api(project(":core:process:biz-engine")) - api(project(":core:process:biz-process")) - api(project(":core:process:biz-process-sample")) - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:process:plugin-load")) + api(project(":core:process:plugin-trigger")) + api(project(":core:common:common-archive")) + api(project(":core:process:biz-engine")) + api(project(":core:process:biz-process")) + api(project(":core:process:biz-process-sample")) + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) +} + + diff --git a/src/backend/ci/core/project/boot-project/build.gradle.kts b/src/backend/ci/core/project/boot-project/build.gradle.kts index f9f84634493..582be07a2ec 100644 --- a/src/backend/ci/core/project/boot-project/build.gradle.kts +++ b/src/backend/ci/core/project/boot-project/build.gradle.kts @@ -1,37 +1,33 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:project:biz-project-sample")) - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:project:biz-project-sample")) + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) +} diff --git a/src/backend/ci/core/quality/boot-quality/build.gradle.kts b/src/backend/ci/core/quality/boot-quality/build.gradle.kts index cd484dfccc0..88baa39636e 100644 --- a/src/backend/ci/core/quality/boot-quality/build.gradle.kts +++ b/src/backend/ci/core/quality/boot-quality/build.gradle.kts @@ -1,38 +1,36 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) - api(project(":core:quality:biz-quality")) - api(project(":core:quality:biz-quality-sample")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) + api(project(":core:quality:biz-quality")) + api(project(":core:quality:biz-quality-sample")) +} + + diff --git a/src/backend/ci/core/repository/boot-repository/build.gradle.kts b/src/backend/ci/core/repository/boot-repository/build.gradle.kts index e2c700275c7..f4b5d53a70b 100644 --- a/src/backend/ci/core/repository/boot-repository/build.gradle.kts +++ b/src/backend/ci/core/repository/boot-repository/build.gradle.kts @@ -1,40 +1,35 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:repository:biz-repository-sample")) - // 无对接权限中心,根据common.yml配置文件项auth.idProvider=samle启用,会忽略下面蓝鲸权限中心实现 - api(project(":core:common:common-auth:common-auth-mock")) - // 对接蓝鲸的权限中心实现, 根据common.yml配置项auth.idProvider=bk_login值来决定加载 - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) -} - - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:repository:biz-repository-sample")) + // 无对接权限中心,根据common.yml配置文件项auth.idProvider=samle启用,会忽略下面蓝鲸权限中心实现 + api(project(":core:common:common-auth:common-auth-mock")) + // 对接蓝鲸的权限中心实现, 根据common.yml配置项auth.idProvider=bk_login值来决定加载 + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) +} diff --git a/src/backend/ci/core/sign/boot-sign/build.gradle.kts b/src/backend/ci/core/sign/boot-sign/build.gradle.kts index c621d6ccd0f..0b57548a451 100644 --- a/src/backend/ci/core/sign/boot-sign/build.gradle.kts +++ b/src/backend/ci/core/sign/boot-sign/build.gradle.kts @@ -1,36 +1,34 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:sign:biz-sign-sample")) -} - - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:sign:biz-sign-sample")) +} + + + diff --git a/src/backend/ci/core/store/boot-store/build.gradle.kts b/src/backend/ci/core/store/boot-store/build.gradle.kts index 9506f12a069..eaaf345e8cc 100644 --- a/src/backend/ci/core/store/boot-store/build.gradle.kts +++ b/src/backend/ci/core/store/boot-store/build.gradle.kts @@ -1,35 +1,33 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:store:biz-store-sample")) - api(project(":core:store:biz-store-image-sample")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:store:biz-store-sample")) + api(project(":core:store:biz-store-image-sample")) +} + + diff --git a/src/backend/ci/core/ticket/boot-ticket/build.gradle.kts b/src/backend/ci/core/ticket/boot-ticket/build.gradle.kts index 718082ed55a..f0fc47de4cd 100644 --- a/src/backend/ci/core/ticket/boot-ticket/build.gradle.kts +++ b/src/backend/ci/core/ticket/boot-ticket/build.gradle.kts @@ -1,37 +1,35 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:ticket:biz-ticket-sample")) - api(project(":core:common:common-auth:common-auth-mock")) - api(project(":core:common:common-auth:common-auth-blueking")) - api(project(":core:common:common-auth:common-auth-v3")) -} - -plugins { - `task-spring-boot-package` -} +/* + * 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. + */ + +dependencies { + api(project(":core:ticket:biz-ticket-sample")) + api(project(":core:common:common-auth:common-auth-mock")) + api(project(":core:common:common-auth:common-auth-blueking")) + api(project(":core:common:common-auth:common-auth-v3")) +} + + diff --git a/src/backend/ci/core/websocket/boot-websocket/build.gradle.kts b/src/backend/ci/core/websocket/boot-websocket/build.gradle.kts index ff7fa0b2665..f93396c5c1f 100644 --- a/src/backend/ci/core/websocket/boot-websocket/build.gradle.kts +++ b/src/backend/ci/core/websocket/boot-websocket/build.gradle.kts @@ -30,6 +30,4 @@ dependencies { api(project(":core:websocket:biz-websocket-blueking")) } -plugins { - `task-spring-boot-package` -} + diff --git a/src/backend/ci/gradle.properties b/src/backend/ci/gradle.properties index 76b0d618f4b..974914ca43e 100644 --- a/src/backend/ci/gradle.properties +++ b/src/backend/ci/gradle.properties @@ -42,3 +42,4 @@ DB_USERNAME=root DB_PASSWORD=root DB_PREFIX=devops_ci_ devopsBootVersion=0.0.3 +org.gradle.jvmargs=-Xmx2048M -Xms2048M From c9164bc813266b8b100c8c89e0130c9a594c1563 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 7 Jul 2021 15:43:14 +0800 Subject: [PATCH 008/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + src/backend/ci/build.gradle.kts | 97 +-- src/backend/ci/buildSrc/build.gradle.kts | 5 +- src/backend/ci/buildSrc/gradle.properties | 1 - .../common/security/util/EnvironmentUtil.kt | 2 +- .../common/common-service/build.gradle.kts | 2 +- .../devops/common/service/MicroService.kt | 74 +- .../common/service/utils/CommonUtils.kt | 356 +++++----- .../core/common/common-web/build.gradle.kts | 81 +-- .../BuildRepositoryMaterialResourceImpl.kt | 132 ++-- .../api/builds/BuildVarResourceImpl.kt | 146 ++-- .../timer/quartz/PipelineQuartzService.kt | 382 +++++------ .../common/impl/StorePipelineServiceImpl.kt | 644 +++++++++--------- .../websocket/biz-websocket/build.gradle.kts | 1 - .../worker/worker-common/build.gradle.kts | 2 - .../worker/task/scm/git/GitUpdateTask.kt | 2 +- src/backend/ci/gradle.properties | 9 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 18 files changed, 926 insertions(+), 1013 deletions(-) diff --git a/.gitignore b/.gitignore index a4089b732ef..ce73c38d609 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ out .history .codecc build.yml +*.ipa diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index 0901ab0bbff..3d2c6337631 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -1,108 +1,35 @@ plugins { - id("com.tencent.devops.boot") apply false + id("com.tencent.devops.boot") } apply("$rootDir/detekt.gradle.kts") -subprojects { +allprojects { apply(plugin = "com.tencent.devops.boot") apply(plugin = "maven") - /************ https://github.com/bkdevops-projects/devops-framework/issues/73 ********/ - apply(plugin = "java") - apply(plugin = "kotlin") - apply(plugin = "org.jetbrains.kotlin.plugin.spring") - tasks.withType { - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() - javaParameters = true - } - } - - tasks.withType { - options.encoding = "UTF-8" - options.compilerArgs.add("-parameters") - sourceCompatibility = JavaVersion.VERSION_1_8.toString() - targetCompatibility = JavaVersion.VERSION_1_8.toString() - } - - tasks.getByName("jar") { - onlyIf { - project.the()["main"].allSource.files.isNotEmpty() - } - } - - tasks.getByName("uploadArchives") { - onlyIf { - project.the()["main"].allSource.files.isNotEmpty() - } - } - - tasks.getByName("install") { - onlyIf { - project.the()["main"].allSource.files.isNotEmpty() && - !name.startsWith("model-") && - !name.startsWith("boot-") && - !name.startsWith("biz-") - } - } - - configurations.forEach { - it.exclude("org.springframework.boot", "spring-boot-starter-logging") - it.exclude("org.springframework.boot", "spring-boot-starter-tomcat") - it.exclude("org.apache.tomcat", "tomcat-jdbc") - it.exclude("org.slf4j", "log4j-over-slf4j") - it.exclude("org.slf4j", "slf4j-log4j12") - it.exclude("org.slf4j", "slf4j-nop") - } - - dependencies { - "testImplementation"("junit:junit") - } - /*****************************************************************************************/ - // 包路径 group = "com.tencent.bk.devops.ci" // 版本 - version = System.getProperty("ci_version") ?: "1.6.0" - version = if (System.getProperty("snapshot") == "true") { - version as String + "-SNAPSHOT" + version = (System.getProperty("ci_version") ?: "1.6.0") + if (System.getProperty("snapshot") == "true") { + "-SNAPSHOT" } else { - version as String + "-RELEASE" + "-RELEASE" } - // 仓库 - val mavenRepoUrl = System.getProperty("mavenRepoUrl") - ?: System.getenv("mavenRepoUrl") - ?: extra["MAVEN_REPO_URL"] as String - repositories { mavenLocal() - maven(url = mavenRepoUrl) - maven(url = "https://repo.spring.io/libs-milestone") + maven( + url = System.getProperty("mavenRepoUrl") + ?: System.getenv("mavenRepoUrl") + ?: extra["MAVEN_REPO_URL"]?.toString() + ?: "https://repo.spring.io/libs-milestone" + ) mavenCentral() jcenter() } - // 创建目录 - task("createCodeDirs") { - listOf( - "src/main/java", - "src/main/kotlin", - "src/main/resources", - "src/test/java", - "src/test/kotlin", - "src/test/resources" - ).forEach { - val f = File(it) - if (!f.exists()) { - f.mkdirs() - } - } - } - - - configure { + dependencyManagement { dependencies { dependency("org.mockito:mockito-all:${Versions.Mockito}") dependency("com.nhaarman:mockito-kotlin-kt1.1:${Versions.MockitoKt}") diff --git a/src/backend/ci/buildSrc/build.gradle.kts b/src/backend/ci/buildSrc/build.gradle.kts index 4f8c2a7c8a8..c48a3edd9af 100644 --- a/src/backend/ci/buildSrc/build.gradle.kts +++ b/src/backend/ci/buildSrc/build.gradle.kts @@ -14,17 +14,14 @@ repositories { } mavenLocal() - mavenRepoUrl?.let { maven(url = it) } - maven(url = "https://repo.spring.io/libs-milestone") + maven(url = mavenRepoUrl ?: "https://repo.spring.io/libs-milestone") mavenCentral() jcenter() } // 依赖插件 dependencies { -// implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72") implementation("nu.studer:gradle-jooq-plugin:5.2.1") -// implementation("org.springframework.boot:spring-boot-gradle-plugin:2.3.7.RELEASE") implementation("com.github.jengelman.gradle.plugins:shadow:5.2.0") implementation("org.ajoberstar:grgit:1.1.0") } diff --git a/src/backend/ci/buildSrc/gradle.properties b/src/backend/ci/buildSrc/gradle.properties index c02aa4e03d7..62db07730f5 100644 --- a/src/backend/ci/buildSrc/gradle.properties +++ b/src/backend/ci/buildSrc/gradle.properties @@ -28,7 +28,6 @@ MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public MAVEN_REPO_DEPLOY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/ MAVEN_REPO_USERNAME= MAVEN_REPO_PASSWORD= -MAVEN_REPO_SNAPSHOT_URL= MAVEN_REPO_SNAPSHOT_DEPLOY_URL= MAVEN_REPO_SNAPSHOT_USERNAME= MAVEN_REPO_SNAPSHOT_PASSWORD= diff --git a/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/util/EnvironmentUtil.kt b/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/util/EnvironmentUtil.kt index 51ee6edb8f5..be7c35f2a87 100644 --- a/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/util/EnvironmentUtil.kt +++ b/src/backend/ci/core/common/common-security/src/main/kotlin/com/tencent/devops/common/security/util/EnvironmentUtil.kt @@ -27,7 +27,7 @@ package com.tencent.devops.common.security.util -import org.apache.commons.lang.StringUtils +import org.apache.commons.lang3.StringUtils import org.springframework.beans.BeansException import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware diff --git a/src/backend/ci/core/common/common-service/build.gradle.kts b/src/backend/ci/core/common/common-service/build.gradle.kts index 2006d2765a1..a317ed3d994 100644 --- a/src/backend/ci/core/common/common-service/build.gradle.kts +++ b/src/backend/ci/core/common/common-service/build.gradle.kts @@ -35,5 +35,5 @@ dependencies { api("org.jolokia:jolokia-core") api("javax.servlet:javax.servlet-api") api("org.springframework:spring-web") - testImplementation("org.springframework.boot:spring-boot-starter-test") + api("org.apache.commons:commons-lang3") } diff --git a/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/MicroService.kt b/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/MicroService.kt index 077c61d78f1..e1e664370bc 100644 --- a/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/MicroService.kt +++ b/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/MicroService.kt @@ -1,38 +1,36 @@ -/* - * 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.common.service - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration - -/** - * - * Powered By Tencent - */ -@SpringBootApplication(exclude = [(ArchaiusAutoConfiguration::class)]) -annotation class MicroService +/* + * 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.common.service + +import org.springframework.boot.autoconfigure.SpringBootApplication +/** + * + * Powered By Tencent + */ +@SpringBootApplication +annotation class MicroService diff --git a/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/CommonUtils.kt b/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/CommonUtils.kt index 0fe7c75912a..41c3dea9388 100755 --- a/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/CommonUtils.kt +++ b/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/CommonUtils.kt @@ -1,178 +1,178 @@ -/* - * 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.common.service.utils - -import com.fasterxml.jackson.core.type.TypeReference -import com.tencent.devops.common.api.constant.CommonMessageCode -import com.tencent.devops.common.api.pojo.Result -import com.tencent.devops.common.api.util.JsonUtil -import com.tencent.devops.common.api.util.OkhttpUtils -import org.apache.commons.lang.StringUtils -import org.slf4j.LoggerFactory -import org.springframework.context.i18n.LocaleContextHolder -import org.springframework.web.context.request.RequestContextHolder -import org.springframework.web.context.request.ServletRequestAttributes -import java.io.File -import java.net.Inet4Address -import java.net.InetAddress -import java.net.NetworkInterface -import java.net.SocketException -import java.util.Enumeration -import kotlin.collections.HashMap -import kotlin.collections.Map -import kotlin.collections.component1 -import kotlin.collections.component2 -import kotlin.collections.listOf -import kotlin.collections.set - -object CommonUtils { - - private val simpleCnLanList = listOf("ZH_CN", "ZH-CN") - - private val twCnLanList = listOf("ZH_TW", "ZH-TW", "ZH_HK", "ZH-HK") - - private val logger = LoggerFactory.getLogger(CommonUtils::class.java) - - fun getInnerIP(): String { - val ipMap = getMachineIP() - var innerIp = ipMap["eth1"] - if (StringUtils.isBlank(innerIp)) { - logger.error("eth1 网卡Ip为空,因此,获取eth0的网卡ip") - innerIp = ipMap["eth0"] - } - if (StringUtils.isBlank(innerIp)) { - val ipSet = ipMap.entries - for ((_, value) in ipSet) { - innerIp = value - if (!StringUtils.isBlank(innerIp)) { - break - } - } - } - - return if (StringUtils.isBlank(innerIp) || null == innerIp) "" else innerIp - } - - private fun getMachineIP(): Map { - logger.info("####Start getMachineIP") - val allIp = HashMap() - - try { - val allNetInterfaces = NetworkInterface.getNetworkInterfaces() // 获取服务器的所有网卡 - if (null == allNetInterfaces) { - logger.error("####getMachineIP Can not get NetworkInterfaces") - } else { - while (allNetInterfaces.hasMoreElements()) { // 循环网卡获取网卡的IP地址 - parseIp(allNetInterfaces, allIp) - } - } - } catch (e: SocketException) { - logger.error("获取网卡失败", e) - } catch (ignore: NullPointerException) { - logger.error("获取网卡失败", ignore) - } - - return allIp - } - - private fun parseIp( - allNetInterfaces: Enumeration, - allIp: HashMap - ) { - val netInterface = allNetInterfaces.nextElement() - val netInterfaceName = netInterface.name - // 过滤掉127.0.0.1的IP - if (StringUtils.isBlank(netInterfaceName) || "lo".equals(netInterfaceName, ignoreCase = true)) { - logger.info("loopback地址或网卡名称为空") - } else { - val addresses = netInterface.inetAddresses - while (addresses.hasMoreElements()) { - val ip = addresses.nextElement() as InetAddress - if (ip is Inet4Address && !ip.isLoopbackAddress) { - val machineIp = ip.hostAddress - logger.info("####netInterfaceName=$netInterfaceName The Machine IP=$machineIp") - allIp[netInterfaceName] = machineIp - } - } - } - } - - fun serviceUploadFile( - userId: String, - serviceUrlPrefix: String, - file: File, - fileChannelType: String - ): Result { - val serviceUrl = - "$serviceUrlPrefix/service/artifactories/file/upload?userId=$userId&fileChannelType=$fileChannelType" - logger.info("the serviceUrl is:$serviceUrl") - OkhttpUtils.uploadFile(serviceUrl, file).use { response -> - val responseContent = response.body()!!.string() - logger.error("uploadFile responseContent is: $responseContent") - if (!response.isSuccessful) { - return MessageCodeUtil.generateResponseDataObject(CommonMessageCode.SYSTEM_ERROR) - } - return JsonUtil.to(responseContent, object : TypeReference>() {}) - } - } - - /** - * 获取语言信息 - */ - private fun getOriginLocale(): String { - val attributes = RequestContextHolder.getRequestAttributes() as? ServletRequestAttributes - return if (null != attributes) { - val request = attributes.request - val cookieLan = CookieUtil.getCookieValue(request, "blueking_language") - cookieLan ?: LocaleContextHolder.getLocale().toString() // 获取字符集(与http请求头中的Accept-Language有关) - } else { - "ZH_CN" // 取不到语言信息默认为中文 - } - } - - /** - * 获取蓝盾能处理的语言信息 - */ - fun getBkLocale(): String { - val locale = getOriginLocale() - return when { - simpleCnLanList.contains(locale.toUpperCase()) -> "ZH_CN" // 简体中文 - twCnLanList.contains(locale.toUpperCase()) -> "ZH_TW" // 繁体中文 - else -> "EN" // 英文描述 - } - } - - /** - * 获取字符串的头部指定长度 - */ - fun interceptStringInLength(string: String?, length: Int): String? { - return if (string != null && string.length > length) { - string.substring(0, length - 1) - } else string - } -} +/* + * 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.common.service.utils + +import com.fasterxml.jackson.core.type.TypeReference +import com.tencent.devops.common.api.constant.CommonMessageCode +import com.tencent.devops.common.api.pojo.Result +import com.tencent.devops.common.api.util.JsonUtil +import com.tencent.devops.common.api.util.OkhttpUtils +import org.apache.commons.lang3.StringUtils +import org.slf4j.LoggerFactory +import org.springframework.context.i18n.LocaleContextHolder +import org.springframework.web.context.request.RequestContextHolder +import org.springframework.web.context.request.ServletRequestAttributes +import java.io.File +import java.net.Inet4Address +import java.net.InetAddress +import java.net.NetworkInterface +import java.net.SocketException +import java.util.Enumeration +import kotlin.collections.HashMap +import kotlin.collections.Map +import kotlin.collections.component1 +import kotlin.collections.component2 +import kotlin.collections.listOf +import kotlin.collections.set + +object CommonUtils { + + private val simpleCnLanList = listOf("ZH_CN", "ZH-CN") + + private val twCnLanList = listOf("ZH_TW", "ZH-TW", "ZH_HK", "ZH-HK") + + private val logger = LoggerFactory.getLogger(CommonUtils::class.java) + + fun getInnerIP(): String { + val ipMap = getMachineIP() + var innerIp = ipMap["eth1"] + if (StringUtils.isBlank(innerIp)) { + logger.error("eth1 网卡Ip为空,因此,获取eth0的网卡ip") + innerIp = ipMap["eth0"] + } + if (StringUtils.isBlank(innerIp)) { + val ipSet = ipMap.entries + for ((_, value) in ipSet) { + innerIp = value + if (!StringUtils.isBlank(innerIp)) { + break + } + } + } + + return if (StringUtils.isBlank(innerIp) || null == innerIp) "" else innerIp + } + + private fun getMachineIP(): Map { + logger.info("####Start getMachineIP") + val allIp = HashMap() + + try { + val allNetInterfaces = NetworkInterface.getNetworkInterfaces() // 获取服务器的所有网卡 + if (null == allNetInterfaces) { + logger.error("####getMachineIP Can not get NetworkInterfaces") + } else { + while (allNetInterfaces.hasMoreElements()) { // 循环网卡获取网卡的IP地址 + parseIp(allNetInterfaces, allIp) + } + } + } catch (e: SocketException) { + logger.error("获取网卡失败", e) + } catch (ignore: NullPointerException) { + logger.error("获取网卡失败", ignore) + } + + return allIp + } + + private fun parseIp( + allNetInterfaces: Enumeration, + allIp: HashMap + ) { + val netInterface = allNetInterfaces.nextElement() + val netInterfaceName = netInterface.name + // 过滤掉127.0.0.1的IP + if (StringUtils.isBlank(netInterfaceName) || "lo".equals(netInterfaceName, ignoreCase = true)) { + logger.info("loopback地址或网卡名称为空") + } else { + val addresses = netInterface.inetAddresses + while (addresses.hasMoreElements()) { + val ip = addresses.nextElement() as InetAddress + if (ip is Inet4Address && !ip.isLoopbackAddress) { + val machineIp = ip.hostAddress + logger.info("####netInterfaceName=$netInterfaceName The Machine IP=$machineIp") + allIp[netInterfaceName] = machineIp + } + } + } + } + + fun serviceUploadFile( + userId: String, + serviceUrlPrefix: String, + file: File, + fileChannelType: String + ): Result { + val serviceUrl = + "$serviceUrlPrefix/service/artifactories/file/upload?userId=$userId&fileChannelType=$fileChannelType" + logger.info("the serviceUrl is:$serviceUrl") + OkhttpUtils.uploadFile(serviceUrl, file).use { response -> + val responseContent = response.body()!!.string() + logger.error("uploadFile responseContent is: $responseContent") + if (!response.isSuccessful) { + return MessageCodeUtil.generateResponseDataObject(CommonMessageCode.SYSTEM_ERROR) + } + return JsonUtil.to(responseContent, object : TypeReference>() {}) + } + } + + /** + * 获取语言信息 + */ + private fun getOriginLocale(): String { + val attributes = RequestContextHolder.getRequestAttributes() as? ServletRequestAttributes + return if (null != attributes) { + val request = attributes.request + val cookieLan = CookieUtil.getCookieValue(request, "blueking_language") + cookieLan ?: LocaleContextHolder.getLocale().toString() // 获取字符集(与http请求头中的Accept-Language有关) + } else { + "ZH_CN" // 取不到语言信息默认为中文 + } + } + + /** + * 获取蓝盾能处理的语言信息 + */ + fun getBkLocale(): String { + val locale = getOriginLocale() + return when { + simpleCnLanList.contains(locale.toUpperCase()) -> "ZH_CN" // 简体中文 + twCnLanList.contains(locale.toUpperCase()) -> "ZH_TW" // 繁体中文 + else -> "EN" // 英文描述 + } + } + + /** + * 获取字符串的头部指定长度 + */ + fun interceptStringInLength(string: String?, length: Int): String? { + return if (string != null && string.length > length) { + string.substring(0, length - 1) + } else string + } +} diff --git a/src/backend/ci/core/common/common-web/build.gradle.kts b/src/backend/ci/core/common/common-web/build.gradle.kts index b2ad52085af..b71442baa5c 100644 --- a/src/backend/ci/core/common/common-web/build.gradle.kts +++ b/src/backend/ci/core/common/common-web/build.gradle.kts @@ -1,40 +1,41 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:common:common-api")) - api(project(":core:common:common-service")) - api(project(":core:common:common-security")) - api(project(":core:common:common-client")) - api("org.springframework.boot:spring-boot-starter-jersey") - api("org.springframework.boot:spring-boot-starter-undertow") - api("org.springframework.boot:spring-boot-starter-web") - api("io.swagger:swagger-jersey2-jaxrs") - api("com.github.ulisesbocchio:jasypt-spring-boot-starter") - api("org.springframework.boot:spring-boot-starter-amqp") - api("org.springframework.cloud:spring-cloud-starter-config") -} +/* + * 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. + */ + +dependencies { + api(project(":core:common:common-api")) + api(project(":core:common:common-service")) + api(project(":core:common:common-security")) + api(project(":core:common:common-client")) + api("org.springframework.boot:spring-boot-starter-jersey") + api("org.springframework.boot:spring-boot-starter-undertow") + api("org.springframework.boot:spring-boot-starter-web") + api("io.swagger:swagger-jersey2-jaxrs") + api("com.github.ulisesbocchio:jasypt-spring-boot-starter") + api("org.springframework.boot:spring-boot-starter-amqp") + api("org.springframework.cloud:spring-cloud-starter-config") + api("org.aspectj:aspectjweaver") +} diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildRepositoryMaterialResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildRepositoryMaterialResourceImpl.kt index 8ce488c4841..35ace28272b 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildRepositoryMaterialResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildRepositoryMaterialResourceImpl.kt @@ -1,66 +1,66 @@ -/* - * 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.process.api.builds - -import com.tencent.devops.common.api.exception.ParamBlankException -import com.tencent.devops.common.api.pojo.Result -import com.tencent.devops.common.web.RestResource -import com.tencent.devops.process.pojo.PipelineBuildMaterial -import com.tencent.devops.process.service.PipelineBuildMaterialService -import org.apache.commons.lang.StringUtils -import org.springframework.beans.factory.annotation.Autowired - -@Suppress("ALL") -@RestResource -class BuildRepositoryMaterialResourceImpl @Autowired constructor( - private val pipelineBuildMaterialService: PipelineBuildMaterialService -) : BuildRepositoryMaterialResource { - override fun saveBuildMaterial( - buildId: String, - projectId: String, - pipelineId: String, - pipelineBuildMaterials: List - ): Result { - checkParam(buildId = buildId, projectId = projectId, pipelineId = pipelineId) - return Result(pipelineBuildMaterialService.saveBuildMaterial( - buildId = buildId, - projectId = projectId, - pipelineId = pipelineId, - pipelineBuildMaterials = pipelineBuildMaterials - )) - } - - fun checkParam(buildId: String, projectId: String, pipelineId: String) { - if (StringUtils.isBlank(buildId)) { - throw ParamBlankException("build Id is null or blank") - } - if (StringUtils.isBlank(pipelineId)) { - throw ParamBlankException("pipeline Id is null or blank") - } - } -} +/* + * 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.process.api.builds + +import com.tencent.devops.common.api.exception.ParamBlankException +import com.tencent.devops.common.api.pojo.Result +import com.tencent.devops.common.web.RestResource +import com.tencent.devops.process.pojo.PipelineBuildMaterial +import com.tencent.devops.process.service.PipelineBuildMaterialService +import org.apache.commons.lang3.StringUtils +import org.springframework.beans.factory.annotation.Autowired + +@Suppress("ALL") +@RestResource +class BuildRepositoryMaterialResourceImpl @Autowired constructor( + private val pipelineBuildMaterialService: PipelineBuildMaterialService +) : BuildRepositoryMaterialResource { + override fun saveBuildMaterial( + buildId: String, + projectId: String, + pipelineId: String, + pipelineBuildMaterials: List + ): Result { + checkParam(buildId = buildId, projectId = projectId, pipelineId = pipelineId) + return Result(pipelineBuildMaterialService.saveBuildMaterial( + buildId = buildId, + projectId = projectId, + pipelineId = pipelineId, + pipelineBuildMaterials = pipelineBuildMaterials + )) + } + + fun checkParam(buildId: String, projectId: String, pipelineId: String) { + if (StringUtils.isBlank(buildId)) { + throw ParamBlankException("build Id is null or blank") + } + if (StringUtils.isBlank(pipelineId)) { + throw ParamBlankException("pipeline Id is null or blank") + } + } +} diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt index 09170add873..8e0069744b7 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt @@ -1,73 +1,73 @@ -/* - * 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.process.api.builds - -import com.tencent.devops.common.api.exception.ParamBlankException -import com.tencent.devops.common.api.exception.PermissionForbiddenException -import com.tencent.devops.common.api.pojo.Result -import com.tencent.devops.common.auth.api.AuthPermission -import com.tencent.devops.common.web.RestResource -import com.tencent.devops.process.engine.service.PipelineRepositoryService -import com.tencent.devops.process.permission.PipelinePermissionService -import com.tencent.devops.process.service.BuildVariableService - -import org.apache.commons.lang.StringUtils -import org.springframework.beans.factory.annotation.Autowired - -@RestResource -class BuildVarResourceImpl @Autowired constructor( - private val buildVariableService: BuildVariableService, - private val pipelinePermissionService: PipelinePermissionService, - private val pipelineRepositoryService: PipelineRepositoryService -) : BuildVarResource { - override fun getBuildVar(buildId: String, projectId: String, pipelineId: String): Result> { - checkParam(buildId = buildId, projectId = projectId, pipelineId = pipelineId) - checkPermission(projectId = projectId, pipelineId = pipelineId) - return Result(buildVariableService.getAllVariable(buildId)) - } - - fun checkPermission(projectId: String, pipelineId: String) { - val userId = pipelineRepositoryService.getPipelineInfo(projectId, pipelineId)?.lastModifyUser ?: "" - if (!pipelinePermissionService.checkPipelinePermission( - userId = userId, - projectId = projectId, - pipelineId = pipelineId, - permission = AuthPermission.EXECUTE)) { - throw PermissionForbiddenException("用户${userId}无权获取此流水线构建信息") - } - } - - fun checkParam(buildId: String, projectId: String, pipelineId: String) { - if (StringUtils.isBlank(buildId)) { - throw ParamBlankException("build Id is null or blank") - } - if (StringUtils.isBlank(pipelineId)) { - throw ParamBlankException("pipeline Id is null or blank") - } - } -} +/* + * 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.process.api.builds + +import com.tencent.devops.common.api.exception.ParamBlankException +import com.tencent.devops.common.api.exception.PermissionForbiddenException +import com.tencent.devops.common.api.pojo.Result +import com.tencent.devops.common.auth.api.AuthPermission +import com.tencent.devops.common.web.RestResource +import com.tencent.devops.process.engine.service.PipelineRepositoryService +import com.tencent.devops.process.permission.PipelinePermissionService +import com.tencent.devops.process.service.BuildVariableService + +import org.apache.commons.lang3.StringUtils +import org.springframework.beans.factory.annotation.Autowired + +@RestResource +class BuildVarResourceImpl @Autowired constructor( + private val buildVariableService: BuildVariableService, + private val pipelinePermissionService: PipelinePermissionService, + private val pipelineRepositoryService: PipelineRepositoryService +) : BuildVarResource { + override fun getBuildVar(buildId: String, projectId: String, pipelineId: String): Result> { + checkParam(buildId = buildId, projectId = projectId, pipelineId = pipelineId) + checkPermission(projectId = projectId, pipelineId = pipelineId) + return Result(buildVariableService.getAllVariable(buildId)) + } + + fun checkPermission(projectId: String, pipelineId: String) { + val userId = pipelineRepositoryService.getPipelineInfo(projectId, pipelineId)?.lastModifyUser ?: "" + if (!pipelinePermissionService.checkPipelinePermission( + userId = userId, + projectId = projectId, + pipelineId = pipelineId, + permission = AuthPermission.EXECUTE)) { + throw PermissionForbiddenException("用户${userId}无权获取此流水线构建信息") + } + } + + fun checkParam(buildId: String, projectId: String, pipelineId: String) { + if (StringUtils.isBlank(buildId)) { + throw ParamBlankException("build Id is null or blank") + } + if (StringUtils.isBlank(pipelineId)) { + throw ParamBlankException("pipeline Id is null or blank") + } + } +} diff --git a/src/backend/ci/core/process/plugin-trigger/src/main/kotlin/com/tencent/devops/process/plugin/trigger/timer/quartz/PipelineQuartzService.kt b/src/backend/ci/core/process/plugin-trigger/src/main/kotlin/com/tencent/devops/process/plugin/trigger/timer/quartz/PipelineQuartzService.kt index 6065d108949..b80fdfc6046 100644 --- a/src/backend/ci/core/process/plugin-trigger/src/main/kotlin/com/tencent/devops/process/plugin/trigger/timer/quartz/PipelineQuartzService.kt +++ b/src/backend/ci/core/process/plugin-trigger/src/main/kotlin/com/tencent/devops/process/plugin/trigger/timer/quartz/PipelineQuartzService.kt @@ -1,191 +1,191 @@ -/* - * 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.process.plugin.trigger.timer.quartz - -import com.tencent.devops.common.event.dispatcher.pipeline.PipelineEventDispatcher -import com.tencent.devops.common.redis.RedisLock -import com.tencent.devops.common.redis.RedisOperation -import com.tencent.devops.common.service.gray.Gray -import com.tencent.devops.common.service.utils.SpringContextUtil -import com.tencent.devops.process.plugin.trigger.pojo.event.PipelineTimerBuildEvent -import com.tencent.devops.process.plugin.trigger.service.PipelineTimerService -import com.tencent.devops.process.plugin.trigger.timer.SchedulerManager -import org.apache.commons.codec.digest.DigestUtils -import org.apache.commons.lang.time.DateFormatUtils -import org.quartz.Job -import org.quartz.JobExecutionContext -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.scheduling.annotation.Scheduled -import org.springframework.stereotype.Service -import java.util.concurrent.atomic.AtomicBoolean -import javax.annotation.PreDestroy - -/** - * 调度服务框架 - * @version 1.0 - */ -@Service -class PipelineQuartzService @Autowired constructor( - private val pipelineTimerService: PipelineTimerService, - private val schedulerManager: SchedulerManager -) { - private val logger = LoggerFactory.getLogger(javaClass)!! - - companion object { - private val jobBeanClass = PipelineQuartzJob::class.java - private val init = AtomicBoolean(false) - } - - @Suppress("ALL") - @Scheduled(initialDelay = 20000, fixedDelay = 3000000) - fun reloadTimer() { - logger.info("TIMER_RELOAD| start add timer pipeline to quartz queue!") - var start = 0 - val limit = 200 - loop@ while (true) { - val resp = pipelineTimerService.list(start, limit) - val list = resp.data - if (list == null || list.isEmpty()) { - logger.info("list timer pipeline finish|start=$start|limit=$limit|resp=$resp") - break@loop - } - list.forEach { timer -> - logger.info("TIMER_RELOAD| load crontab($timer)") - timer.crontabExpressions.forEach { crontab -> - addJob(pipelineId = timer.pipelineId, crontab = crontab) - } - } - start += limit - } - - logger.warn("TIMER_RELOAD| reload ok!") - } - - fun addJob(pipelineId: String, crontab: String) { - try { - val md5 = DigestUtils.md5Hex(crontab) - val comboKey = "${pipelineId}_$md5" - schedulerManager.addJob( - comboKey, crontab, - jobBeanClass - ) - } catch (e: Exception) { - logger.error("TIMER_RELOAD| add job error|pipelineId=$pipelineId|crontab=$crontab", e) - } - } - - @PreDestroy - fun stop() { - if (init.get()) { - schedulerManager.shutdown() - init.set(false) - logger.warn("STOP| timer quartz have been stop!") - } else { - logger.warn("STOP| do not init!") - } - } -} - -class PipelineQuartzJob : Job { - override fun execute(context: JobExecutionContext?) { - SpringContextUtil.getBean(PipelineJobBean::class.java).execute(context) - } -} - -class PipelineJobBean( - private val pipelineEventDispatcher: PipelineEventDispatcher, - private val schedulerManager: SchedulerManager, - private val pipelineTimerService: PipelineTimerService, - private val redisOperation: RedisOperation, - private val gray: Gray -) { - - private val logger = LoggerFactory.getLogger(javaClass)!! - - @Suppress("ALL") - fun execute(context: JobExecutionContext?) { - val jobKey = context?.jobDetail?.key ?: return - val comboKey = jobKey.name - val comboKeys = comboKey.split("_") - val pipelineId = comboKeys[0] - val crontabMd5 = comboKeys[1] - val pipelineTimer = pipelineTimerService.get(pipelineId) - if (null == pipelineTimer) { - logger.info("[$comboKey]|PIPELINE_TIMER_EXPIRED|Timer is expire, delete it from queue!") - schedulerManager.deleteJob(comboKey) - return - } - - if (gray.isGray()) { - // 灰度环境只加载灰度项目的流水线 - if (!gray.isGrayProject(pipelineTimer.projectId, redisOperation)) { - logger.info("[$comboKey]|PIPELINE_TIMER_GRAY|${pipelineTimer.projectId} is prod, discard!") - return - } - } else { - // 生产环境只加载生产项目的流水线 - if (gray.isGrayProject(pipelineTimer.projectId, redisOperation)) { - logger.info("[$comboKey]|PIPELINE_TIMER_PROD|${pipelineTimer.projectId} is gray, discard!") - return - } - } - - var find = false - pipelineTimer.crontabExpressions.forEach { - if (DigestUtils.md5Hex(it) == crontabMd5) { - find = true - } - } - if (!find) { - logger.info("[$comboKey]|PIPELINE_TIMER_EXPIRED|can not find crontab, delete it from queue!") - schedulerManager.deleteJob(comboKey) - return - } - val scheduledFireTime = DateFormatUtils.format(context.scheduledFireTime, "yyyyMMddHHmmss") - // 相同触发的要锁定,防止误差导致重复执行 - val redisLock = RedisLock(redisOperation, "process:pipeline:timer:trigger:$pipelineId:$scheduledFireTime", 58) - if (redisLock.tryLock()) { - try { - logger.info("[$comboKey]|PIPELINE_TIMER|scheduledFireTime=$scheduledFireTime") - pipelineEventDispatcher.dispatch( - PipelineTimerBuildEvent( - source = "timer_trigger", projectId = pipelineTimer.projectId, pipelineId = pipelineId, - userId = pipelineTimer.startUser, channelCode = pipelineTimer.channelCode - ) - ) - } catch (ignored: Exception) { - logger.error( - "[$comboKey]|PIPELINE_TIMER|scheduledFireTime=$scheduledFireTime|Dispatch event fail, e=$ignored" - ) - } - } else { - logger.info("[$comboKey]|PIPELINE_TIMER_CONCURRENT|scheduledFireTime=$scheduledFireTime| lock fail, skip!") - } - } -} +/* + * 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.process.plugin.trigger.timer.quartz + +import com.tencent.devops.common.event.dispatcher.pipeline.PipelineEventDispatcher +import com.tencent.devops.common.redis.RedisLock +import com.tencent.devops.common.redis.RedisOperation +import com.tencent.devops.common.service.gray.Gray +import com.tencent.devops.common.service.utils.SpringContextUtil +import com.tencent.devops.process.plugin.trigger.pojo.event.PipelineTimerBuildEvent +import com.tencent.devops.process.plugin.trigger.service.PipelineTimerService +import com.tencent.devops.process.plugin.trigger.timer.SchedulerManager +import org.apache.commons.codec.digest.DigestUtils +import org.apache.commons.lang3.time.DateFormatUtils +import org.quartz.Job +import org.quartz.JobExecutionContext +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.scheduling.annotation.Scheduled +import org.springframework.stereotype.Service +import java.util.concurrent.atomic.AtomicBoolean +import javax.annotation.PreDestroy + +/** + * 调度服务框架 + * @version 1.0 + */ +@Service +class PipelineQuartzService @Autowired constructor( + private val pipelineTimerService: PipelineTimerService, + private val schedulerManager: SchedulerManager +) { + private val logger = LoggerFactory.getLogger(javaClass)!! + + companion object { + private val jobBeanClass = PipelineQuartzJob::class.java + private val init = AtomicBoolean(false) + } + + @Suppress("ALL") + @Scheduled(initialDelay = 20000, fixedDelay = 3000000) + fun reloadTimer() { + logger.info("TIMER_RELOAD| start add timer pipeline to quartz queue!") + var start = 0 + val limit = 200 + loop@ while (true) { + val resp = pipelineTimerService.list(start, limit) + val list = resp.data + if (list == null || list.isEmpty()) { + logger.info("list timer pipeline finish|start=$start|limit=$limit|resp=$resp") + break@loop + } + list.forEach { timer -> + logger.info("TIMER_RELOAD| load crontab($timer)") + timer.crontabExpressions.forEach { crontab -> + addJob(pipelineId = timer.pipelineId, crontab = crontab) + } + } + start += limit + } + + logger.warn("TIMER_RELOAD| reload ok!") + } + + fun addJob(pipelineId: String, crontab: String) { + try { + val md5 = DigestUtils.md5Hex(crontab) + val comboKey = "${pipelineId}_$md5" + schedulerManager.addJob( + comboKey, crontab, + jobBeanClass + ) + } catch (e: Exception) { + logger.error("TIMER_RELOAD| add job error|pipelineId=$pipelineId|crontab=$crontab", e) + } + } + + @PreDestroy + fun stop() { + if (init.get()) { + schedulerManager.shutdown() + init.set(false) + logger.warn("STOP| timer quartz have been stop!") + } else { + logger.warn("STOP| do not init!") + } + } +} + +class PipelineQuartzJob : Job { + override fun execute(context: JobExecutionContext?) { + SpringContextUtil.getBean(PipelineJobBean::class.java).execute(context) + } +} + +class PipelineJobBean( + private val pipelineEventDispatcher: PipelineEventDispatcher, + private val schedulerManager: SchedulerManager, + private val pipelineTimerService: PipelineTimerService, + private val redisOperation: RedisOperation, + private val gray: Gray +) { + + private val logger = LoggerFactory.getLogger(javaClass)!! + + @Suppress("ALL") + fun execute(context: JobExecutionContext?) { + val jobKey = context?.jobDetail?.key ?: return + val comboKey = jobKey.name + val comboKeys = comboKey.split("_") + val pipelineId = comboKeys[0] + val crontabMd5 = comboKeys[1] + val pipelineTimer = pipelineTimerService.get(pipelineId) + if (null == pipelineTimer) { + logger.info("[$comboKey]|PIPELINE_TIMER_EXPIRED|Timer is expire, delete it from queue!") + schedulerManager.deleteJob(comboKey) + return + } + + if (gray.isGray()) { + // 灰度环境只加载灰度项目的流水线 + if (!gray.isGrayProject(pipelineTimer.projectId, redisOperation)) { + logger.info("[$comboKey]|PIPELINE_TIMER_GRAY|${pipelineTimer.projectId} is prod, discard!") + return + } + } else { + // 生产环境只加载生产项目的流水线 + if (gray.isGrayProject(pipelineTimer.projectId, redisOperation)) { + logger.info("[$comboKey]|PIPELINE_TIMER_PROD|${pipelineTimer.projectId} is gray, discard!") + return + } + } + + var find = false + pipelineTimer.crontabExpressions.forEach { + if (DigestUtils.md5Hex(it) == crontabMd5) { + find = true + } + } + if (!find) { + logger.info("[$comboKey]|PIPELINE_TIMER_EXPIRED|can not find crontab, delete it from queue!") + schedulerManager.deleteJob(comboKey) + return + } + val scheduledFireTime = DateFormatUtils.format(context.scheduledFireTime, "yyyyMMddHHmmss") + // 相同触发的要锁定,防止误差导致重复执行 + val redisLock = RedisLock(redisOperation, "process:pipeline:timer:trigger:$pipelineId:$scheduledFireTime", 58) + if (redisLock.tryLock()) { + try { + logger.info("[$comboKey]|PIPELINE_TIMER|scheduledFireTime=$scheduledFireTime") + pipelineEventDispatcher.dispatch( + PipelineTimerBuildEvent( + source = "timer_trigger", projectId = pipelineTimer.projectId, pipelineId = pipelineId, + userId = pipelineTimer.startUser, channelCode = pipelineTimer.channelCode + ) + ) + } catch (ignored: Exception) { + logger.error( + "[$comboKey]|PIPELINE_TIMER|scheduledFireTime=$scheduledFireTime|Dispatch event fail, e=$ignored" + ) + } + } else { + logger.info("[$comboKey]|PIPELINE_TIMER_CONCURRENT|scheduledFireTime=$scheduledFireTime| lock fail, skip!") + } + } +} diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StorePipelineServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StorePipelineServiceImpl.kt index d53d8fdeaa1..31cecc59e86 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StorePipelineServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StorePipelineServiceImpl.kt @@ -1,322 +1,322 @@ -/* - * 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.store.service.common.impl - -import com.tencent.devops.common.api.constant.CommonMessageCode -import com.tencent.devops.common.api.exception.ErrorCodeException -import com.tencent.devops.common.api.pojo.Result -import com.tencent.devops.common.api.util.PageUtil -import com.tencent.devops.common.api.util.UUIDUtil -import com.tencent.devops.common.client.Client -import com.tencent.devops.common.redis.RedisOperation -import com.tencent.devops.common.service.gray.Gray -import com.tencent.devops.common.service.utils.MessageCodeUtil -import com.tencent.devops.common.service.utils.SpringContextUtil -import com.tencent.devops.model.store.tables.TStoreProjectRel -import com.tencent.devops.process.api.service.ServicePipelineSettingResource -import com.tencent.devops.process.pojo.setting.PipelineModelVersion -import com.tencent.devops.process.pojo.setting.UpdatePipelineModelRequest -import com.tencent.devops.store.dao.common.AbstractStoreCommonDao -import com.tencent.devops.store.dao.common.BusinessConfigDao -import com.tencent.devops.store.dao.common.OperationLogDao -import com.tencent.devops.store.dao.common.StoreProjectRelDao -import com.tencent.devops.store.pojo.common.OperationLogCreateRequest -import com.tencent.devops.store.pojo.common.UpdateStorePipelineModelRequest -import com.tencent.devops.store.pojo.common.enums.ScopeTypeEnum -import com.tencent.devops.store.pojo.common.enums.StoreOperationTypeEnum -import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum -import com.tencent.devops.store.service.common.StorePipelineService -import org.apache.commons.lang.StringEscapeUtils -import org.jooq.DSLContext -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.stereotype.Service -import java.util.concurrent.Executors - -@Suppress("ALL") -@Service -class StorePipelineServiceImpl : StorePipelineService { - - @Autowired - private lateinit var storeProjectRelDao: StoreProjectRelDao - - @Autowired - private lateinit var businessConfigDao: BusinessConfigDao - - @Autowired - private lateinit var operationLogDao: OperationLogDao - - @Autowired - private lateinit var redisOperation: RedisOperation - - @Autowired - private lateinit var gray: Gray - - @Autowired - private lateinit var dslContext: DSLContext - - @Autowired - private lateinit var client: Client - - private final val pageSize = 50 - - private final val handlePageKeyPrefix = "updatePipelineModel:handlePage" - - private final val featureName = "initBuildPipeline" - - private val executorService = Executors.newSingleThreadScheduledExecutor() - - private val logger = LoggerFactory.getLogger(StorePipelineServiceImpl::class.java) - - override fun updatePipelineModel( - userId: String, - updateStorePipelineModelRequest: UpdateStorePipelineModelRequest - ): Result { - val taskId = UUIDUtil.generate() - val scopeType = updateStorePipelineModelRequest.scopeType - val storeType = updateStorePipelineModelRequest.storeType - val storeCodeList = updateStorePipelineModelRequest.storeCodeList - val updatePipelineModel = updateStorePipelineModelRequest.pipelineModel - val pipelineModel: String - val grayPipelineModel: String - if (updatePipelineModel.isNullOrBlank()) { - val pipelineModelConfig = - businessConfigDao.get(dslContext, storeType, featureName, "PIPELINE_MODEL") - ?: return MessageCodeUtil.generateResponseDataObject(CommonMessageCode.SYSTEM_ERROR) - val grayPipelineModelConfig = - businessConfigDao.get(dslContext, storeType, featureName, "GRAY_PIPELINE_MODEL") - ?: return MessageCodeUtil.generateResponseDataObject(CommonMessageCode.SYSTEM_ERROR) - pipelineModel = pipelineModelConfig.configValue - grayPipelineModel = grayPipelineModelConfig.configValue - } else { - pipelineModel = updatePipelineModel!! - grayPipelineModel = updatePipelineModel - } - when (scopeType) { - ScopeTypeEnum.ALL.name -> { - handleStorePipelineModel( - storeType = storeType, - taskId = taskId, - userId = userId, - pipelineModel = grayPipelineModel, - grayFlag = true - ) - handleStorePipelineModel( - storeType = storeType, - taskId = taskId, - userId = userId, - pipelineModel = pipelineModel, - grayFlag = false - ) - } - ScopeTypeEnum.GRAY.name -> { - handleStorePipelineModel( - storeType = storeType, - taskId = taskId, - userId = userId, - pipelineModel = grayPipelineModel, - grayFlag = true - ) - } - ScopeTypeEnum.NO_GRAY.name -> { - handleStorePipelineModel( - storeType = storeType, - taskId = taskId, - userId = userId, - pipelineModel = pipelineModel, - grayFlag = false - ) - } - ScopeTypeEnum.SPEC.name -> { - if (storeCodeList == null) { - return MessageCodeUtil.generateResponseDataObject( - CommonMessageCode.PARAMETER_IS_NULL, - arrayOf("storeCodeList") - ) - } - updatePipelineModel( - storeType = storeType, - storeCodeList = storeCodeList, - userId = userId, - taskId = taskId, - defaultPipelineModel = pipelineModel, - checkGrayFlag = true, - grayPipelineModel = grayPipelineModel - ) - } - } - return Result(true) - } - - private fun handleStorePipelineModel( - storeType: String, - taskId: String, - userId: String, - pipelineModel: String, - grayFlag: Boolean? = null - ) { - val grayProjectSet = gray.grayProjectSet(redisOperation) - executorService.submit { - loop@ while (true) { - val projectRelCount = storeProjectRelDao.getStoreInitProjectCount( - dslContext = dslContext, - storeType = StoreTypeEnum.valueOf(storeType).type.toByte(), - descFlag = false, - grayFlag = grayFlag, - grayProjectCodeList = if (grayFlag != null) grayProjectSet else null - ) - // 获取实际处理的页数 - val handlePage = redisOperation.get("$handlePageKeyPrefix:$taskId")?.toInt() ?: 0 - // 计算当前实际的页数 - val actPage = PageUtil.calTotalPage(pageSize, projectRelCount) - if (projectRelCount > 0 && actPage > handlePage) { - val page = handlePage + 1 - val projectRelRecords = storeProjectRelDao.getStoreInitProjects( - dslContext = dslContext, - storeType = StoreTypeEnum.valueOf(storeType).type.toByte(), - descFlag = false, - grayFlag = grayFlag, - grayProjectCodeList = if (grayFlag != null) grayProjectSet else null, - page = page, - pageSize = pageSize - ) - val grayStoreCodeList = - projectRelRecords?.getValues(TStoreProjectRel.T_STORE_PROJECT_REL.STORE_CODE) - if (grayStoreCodeList != null && grayStoreCodeList.isNotEmpty()) { - updatePipelineModel( - storeType = storeType, - storeCodeList = grayStoreCodeList, - userId = userId, - taskId = taskId, - defaultPipelineModel = pipelineModel - ) - } - // 把当前任务处理的页数放入redis缓存 - redisOperation.set("$handlePageKeyPrefix:$taskId", page.toString()) - } else { - redisOperation.delete("$handlePageKeyPrefix:$taskId") - break@loop - } - } - } - } - - private fun updatePipelineModel( - storeType: String, - storeCodeList: List, - userId: String, - taskId: String, - defaultPipelineModel: String, - checkGrayFlag: Boolean = false, - grayPipelineModel: String? = null - ) { - if (checkGrayFlag && (grayPipelineModel == null)) { - throw ErrorCodeException( - errorCode = CommonMessageCode.ERROR_NEED_PARAM_, - params = arrayOf("grayPipelineModel") - ) - } - val storeCommonDao = - SpringContextUtil.getBean(AbstractStoreCommonDao::class.java, "${storeType}_COMMON_DAO") - // 获取研发商店组件信息 - val storeInfoRecords = storeCommonDao.getLatestStoreInfoListByCodes(dslContext, storeCodeList) - val pipelineModelVersionList = mutableListOf() - storeInfoRecords?.forEach { storeInfo -> - val projectCode = storeInfo["projectCode"] as String - val storeCode = storeInfo["storeCode"] as String - val pipelineName = "am-$projectCode-$storeCode-${System.currentTimeMillis()}" - val paramMap = mapOf( - "pipelineName" to pipelineName, - "storeCode" to storeCode, - "version" to storeInfo["version"], - "language" to storeInfo["language"], - "script" to StringEscapeUtils.escapeJava(storeInfo["script"] as String), - "repositoryHashId" to storeInfo["repositoryHashId"], - "repositoryPath" to (storeInfo["repositoryPath"] ?: "") - ) - // 将流水线模型中的变量替换成具体的值 - var convertModel = if (checkGrayFlag) { - val grayProjectSet = gray.grayProjectSet(redisOperation) - if (grayProjectSet.contains(projectCode)) grayPipelineModel!! else defaultPipelineModel - } else { - defaultPipelineModel - } - paramMap.forEach { (key, value) -> - if (value != null) { - convertModel = convertModel.replace("#{$key}", value.toString()) - } - } - pipelineModelVersionList.add( - PipelineModelVersion( - projectId = projectCode, - pipelineId = storeInfo["pipelineId"] as String, - creator = storeInfo["creator"] as String, - model = convertModel - ) - ) - } - try { - val updatePipelineModelResult = client.get(ServicePipelineSettingResource::class) - .updatePipelineModel( - userId = userId, - updatePipelineModelRequest = UpdatePipelineModelRequest( - pipelineModelVersionList = pipelineModelVersionList - ) - ) - logger.info("updatePipelineModelResult:$updatePipelineModelResult") - if (updatePipelineModelResult.isNotOk()) { - batchAddOperateLogs(storeCodeList, storeType, userId, taskId) - } - } catch (e: Exception) { - logger.error("updatePipelineModel error is :", e) - // 将刷新失败的组件信息入库 - batchAddOperateLogs(storeCodeList, storeType, userId, taskId) - } - } - - private fun batchAddOperateLogs( - storeCodeList: List, - storeType: String, - userId: String, - taskId: String - ) { - val operationLogList = mutableListOf() - storeCodeList.forEach { - operationLogList.add( - OperationLogCreateRequest( - storeCode = it, - storeType = StoreTypeEnum.valueOf(storeType).type.toByte(), - optType = StoreOperationTypeEnum.UPDATE_PIPELINE_MODEL.name, - optUser = userId, - optDesc = taskId - ) - ) - } - operationLogDao.batchAddLogs(dslContext, userId, operationLogList) - } -} +/* + * 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.store.service.common.impl + +import com.tencent.devops.common.api.constant.CommonMessageCode +import com.tencent.devops.common.api.exception.ErrorCodeException +import com.tencent.devops.common.api.pojo.Result +import com.tencent.devops.common.api.util.PageUtil +import com.tencent.devops.common.api.util.UUIDUtil +import com.tencent.devops.common.client.Client +import com.tencent.devops.common.redis.RedisOperation +import com.tencent.devops.common.service.gray.Gray +import com.tencent.devops.common.service.utils.MessageCodeUtil +import com.tencent.devops.common.service.utils.SpringContextUtil +import com.tencent.devops.model.store.tables.TStoreProjectRel +import com.tencent.devops.process.api.service.ServicePipelineSettingResource +import com.tencent.devops.process.pojo.setting.PipelineModelVersion +import com.tencent.devops.process.pojo.setting.UpdatePipelineModelRequest +import com.tencent.devops.store.dao.common.AbstractStoreCommonDao +import com.tencent.devops.store.dao.common.BusinessConfigDao +import com.tencent.devops.store.dao.common.OperationLogDao +import com.tencent.devops.store.dao.common.StoreProjectRelDao +import com.tencent.devops.store.pojo.common.OperationLogCreateRequest +import com.tencent.devops.store.pojo.common.UpdateStorePipelineModelRequest +import com.tencent.devops.store.pojo.common.enums.ScopeTypeEnum +import com.tencent.devops.store.pojo.common.enums.StoreOperationTypeEnum +import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum +import com.tencent.devops.store.service.common.StorePipelineService +import org.apache.commons.lang3.StringEscapeUtils +import org.jooq.DSLContext +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Service +import java.util.concurrent.Executors + +@Suppress("ALL") +@Service +class StorePipelineServiceImpl : StorePipelineService { + + @Autowired + private lateinit var storeProjectRelDao: StoreProjectRelDao + + @Autowired + private lateinit var businessConfigDao: BusinessConfigDao + + @Autowired + private lateinit var operationLogDao: OperationLogDao + + @Autowired + private lateinit var redisOperation: RedisOperation + + @Autowired + private lateinit var gray: Gray + + @Autowired + private lateinit var dslContext: DSLContext + + @Autowired + private lateinit var client: Client + + private final val pageSize = 50 + + private final val handlePageKeyPrefix = "updatePipelineModel:handlePage" + + private final val featureName = "initBuildPipeline" + + private val executorService = Executors.newSingleThreadScheduledExecutor() + + private val logger = LoggerFactory.getLogger(StorePipelineServiceImpl::class.java) + + override fun updatePipelineModel( + userId: String, + updateStorePipelineModelRequest: UpdateStorePipelineModelRequest + ): Result { + val taskId = UUIDUtil.generate() + val scopeType = updateStorePipelineModelRequest.scopeType + val storeType = updateStorePipelineModelRequest.storeType + val storeCodeList = updateStorePipelineModelRequest.storeCodeList + val updatePipelineModel = updateStorePipelineModelRequest.pipelineModel + val pipelineModel: String + val grayPipelineModel: String + if (updatePipelineModel.isNullOrBlank()) { + val pipelineModelConfig = + businessConfigDao.get(dslContext, storeType, featureName, "PIPELINE_MODEL") + ?: return MessageCodeUtil.generateResponseDataObject(CommonMessageCode.SYSTEM_ERROR) + val grayPipelineModelConfig = + businessConfigDao.get(dslContext, storeType, featureName, "GRAY_PIPELINE_MODEL") + ?: return MessageCodeUtil.generateResponseDataObject(CommonMessageCode.SYSTEM_ERROR) + pipelineModel = pipelineModelConfig.configValue + grayPipelineModel = grayPipelineModelConfig.configValue + } else { + pipelineModel = updatePipelineModel!! + grayPipelineModel = updatePipelineModel + } + when (scopeType) { + ScopeTypeEnum.ALL.name -> { + handleStorePipelineModel( + storeType = storeType, + taskId = taskId, + userId = userId, + pipelineModel = grayPipelineModel, + grayFlag = true + ) + handleStorePipelineModel( + storeType = storeType, + taskId = taskId, + userId = userId, + pipelineModel = pipelineModel, + grayFlag = false + ) + } + ScopeTypeEnum.GRAY.name -> { + handleStorePipelineModel( + storeType = storeType, + taskId = taskId, + userId = userId, + pipelineModel = grayPipelineModel, + grayFlag = true + ) + } + ScopeTypeEnum.NO_GRAY.name -> { + handleStorePipelineModel( + storeType = storeType, + taskId = taskId, + userId = userId, + pipelineModel = pipelineModel, + grayFlag = false + ) + } + ScopeTypeEnum.SPEC.name -> { + if (storeCodeList == null) { + return MessageCodeUtil.generateResponseDataObject( + CommonMessageCode.PARAMETER_IS_NULL, + arrayOf("storeCodeList") + ) + } + updatePipelineModel( + storeType = storeType, + storeCodeList = storeCodeList, + userId = userId, + taskId = taskId, + defaultPipelineModel = pipelineModel, + checkGrayFlag = true, + grayPipelineModel = grayPipelineModel + ) + } + } + return Result(true) + } + + private fun handleStorePipelineModel( + storeType: String, + taskId: String, + userId: String, + pipelineModel: String, + grayFlag: Boolean? = null + ) { + val grayProjectSet = gray.grayProjectSet(redisOperation) + executorService.submit { + loop@ while (true) { + val projectRelCount = storeProjectRelDao.getStoreInitProjectCount( + dslContext = dslContext, + storeType = StoreTypeEnum.valueOf(storeType).type.toByte(), + descFlag = false, + grayFlag = grayFlag, + grayProjectCodeList = if (grayFlag != null) grayProjectSet else null + ) + // 获取实际处理的页数 + val handlePage = redisOperation.get("$handlePageKeyPrefix:$taskId")?.toInt() ?: 0 + // 计算当前实际的页数 + val actPage = PageUtil.calTotalPage(pageSize, projectRelCount) + if (projectRelCount > 0 && actPage > handlePage) { + val page = handlePage + 1 + val projectRelRecords = storeProjectRelDao.getStoreInitProjects( + dslContext = dslContext, + storeType = StoreTypeEnum.valueOf(storeType).type.toByte(), + descFlag = false, + grayFlag = grayFlag, + grayProjectCodeList = if (grayFlag != null) grayProjectSet else null, + page = page, + pageSize = pageSize + ) + val grayStoreCodeList = + projectRelRecords?.getValues(TStoreProjectRel.T_STORE_PROJECT_REL.STORE_CODE) + if (grayStoreCodeList != null && grayStoreCodeList.isNotEmpty()) { + updatePipelineModel( + storeType = storeType, + storeCodeList = grayStoreCodeList, + userId = userId, + taskId = taskId, + defaultPipelineModel = pipelineModel + ) + } + // 把当前任务处理的页数放入redis缓存 + redisOperation.set("$handlePageKeyPrefix:$taskId", page.toString()) + } else { + redisOperation.delete("$handlePageKeyPrefix:$taskId") + break@loop + } + } + } + } + + private fun updatePipelineModel( + storeType: String, + storeCodeList: List, + userId: String, + taskId: String, + defaultPipelineModel: String, + checkGrayFlag: Boolean = false, + grayPipelineModel: String? = null + ) { + if (checkGrayFlag && (grayPipelineModel == null)) { + throw ErrorCodeException( + errorCode = CommonMessageCode.ERROR_NEED_PARAM_, + params = arrayOf("grayPipelineModel") + ) + } + val storeCommonDao = + SpringContextUtil.getBean(AbstractStoreCommonDao::class.java, "${storeType}_COMMON_DAO") + // 获取研发商店组件信息 + val storeInfoRecords = storeCommonDao.getLatestStoreInfoListByCodes(dslContext, storeCodeList) + val pipelineModelVersionList = mutableListOf() + storeInfoRecords?.forEach { storeInfo -> + val projectCode = storeInfo["projectCode"] as String + val storeCode = storeInfo["storeCode"] as String + val pipelineName = "am-$projectCode-$storeCode-${System.currentTimeMillis()}" + val paramMap = mapOf( + "pipelineName" to pipelineName, + "storeCode" to storeCode, + "version" to storeInfo["version"], + "language" to storeInfo["language"], + "script" to StringEscapeUtils.escapeJava(storeInfo["script"] as String), + "repositoryHashId" to storeInfo["repositoryHashId"], + "repositoryPath" to (storeInfo["repositoryPath"] ?: "") + ) + // 将流水线模型中的变量替换成具体的值 + var convertModel = if (checkGrayFlag) { + val grayProjectSet = gray.grayProjectSet(redisOperation) + if (grayProjectSet.contains(projectCode)) grayPipelineModel!! else defaultPipelineModel + } else { + defaultPipelineModel + } + paramMap.forEach { (key, value) -> + if (value != null) { + convertModel = convertModel.replace("#{$key}", value.toString()) + } + } + pipelineModelVersionList.add( + PipelineModelVersion( + projectId = projectCode, + pipelineId = storeInfo["pipelineId"] as String, + creator = storeInfo["creator"] as String, + model = convertModel + ) + ) + } + try { + val updatePipelineModelResult = client.get(ServicePipelineSettingResource::class) + .updatePipelineModel( + userId = userId, + updatePipelineModelRequest = UpdatePipelineModelRequest( + pipelineModelVersionList = pipelineModelVersionList + ) + ) + logger.info("updatePipelineModelResult:$updatePipelineModelResult") + if (updatePipelineModelResult.isNotOk()) { + batchAddOperateLogs(storeCodeList, storeType, userId, taskId) + } + } catch (e: Exception) { + logger.error("updatePipelineModel error is :", e) + // 将刷新失败的组件信息入库 + batchAddOperateLogs(storeCodeList, storeType, userId, taskId) + } + } + + private fun batchAddOperateLogs( + storeCodeList: List, + storeType: String, + userId: String, + taskId: String + ) { + val operationLogList = mutableListOf() + storeCodeList.forEach { + operationLogList.add( + OperationLogCreateRequest( + storeCode = it, + storeType = StoreTypeEnum.valueOf(storeType).type.toByte(), + optType = StoreOperationTypeEnum.UPDATE_PIPELINE_MODEL.name, + optUser = userId, + optDesc = taskId + ) + ) + } + operationLogDao.batchAddLogs(dslContext, userId, operationLogList) + } +} diff --git a/src/backend/ci/core/websocket/biz-websocket/build.gradle.kts b/src/backend/ci/core/websocket/biz-websocket/build.gradle.kts index 4fd71a422f5..6bfe05647c8 100644 --- a/src/backend/ci/core/websocket/biz-websocket/build.gradle.kts +++ b/src/backend/ci/core/websocket/biz-websocket/build.gradle.kts @@ -35,5 +35,4 @@ dependencies { api("javax.websocket:javax.websocket-api") api("io.undertow:undertow-servlet") api("io.undertow:undertow-websockets-jsr") - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") } diff --git a/src/backend/ci/core/worker/worker-common/build.gradle.kts b/src/backend/ci/core/worker/worker-common/build.gradle.kts index 3bcf1421d2c..118cf513a4b 100644 --- a/src/backend/ci/core/worker/worker-common/build.gradle.kts +++ b/src/backend/ci/core/worker/worker-common/build.gradle.kts @@ -35,8 +35,6 @@ dependencies { api(project(":core:dockerhost:api-dockerhost")) api(project(":core:common:common-archive")) api(project(":core:common:common-pipeline")) - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") api("org.apache.commons:commons-exec") api("org.apache.commons:commons-compress") api("com.github.oshi:oshi-core") diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/plugin/worker/task/scm/git/GitUpdateTask.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/plugin/worker/task/scm/git/GitUpdateTask.kt index f0e3f26f537..31dacd731d6 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/plugin/worker/task/scm/git/GitUpdateTask.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/plugin/worker/task/scm/git/GitUpdateTask.kt @@ -57,7 +57,7 @@ import com.tencent.devops.scm.utils.code.github.GithubUtils import com.tencent.devops.worker.common.api.ApiFactory import com.tencent.devops.worker.common.api.scm.CommitSDKApi import com.tencent.devops.worker.common.logger.LoggerService -import org.apache.commons.lang.exception.ExceptionUtils +import org.apache.commons.lang3.exception.ExceptionUtils import org.eclipse.jgit.api.CreateBranchCommand import org.eclipse.jgit.api.Git import org.eclipse.jgit.api.ListBranchCommand diff --git a/src/backend/ci/gradle.properties b/src/backend/ci/gradle.properties index 974914ca43e..8e76821ddd5 100644 --- a/src/backend/ci/gradle.properties +++ b/src/backend/ci/gradle.properties @@ -23,17 +23,10 @@ # 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. # -kotlin.incremental=true -systemProp.file.encoding=utf-8 -#systemProp.http.proxyHost= -#systemProp.http.proxyPort= -#systemProp.https.proxyHost= -#systemProp.https.proxyPort= MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public MAVEN_REPO_DEPLOY_URL= MAVEN_REPO_USERNAME= MAVEN_REPO_PASSWORD= -MAVEN_REPO_SNAPSHOT_URL= MAVEN_REPO_SNAPSHOT_DEPLOY_URL= MAVEN_REPO_SNAPSHOT_USERNAME= MAVEN_REPO_SNAPSHOT_PASSWORD= @@ -41,5 +34,5 @@ DB_HOST=127.0.0.1:3306 DB_USERNAME=root DB_PASSWORD=root DB_PREFIX=devops_ci_ -devopsBootVersion=0.0.3 +devopsBootVersion=0.0.4-SNAPSHOT org.gradle.jvmargs=-Xmx2048M -Xms2048M diff --git a/src/backend/ci/gradle/wrapper/gradle-wrapper.properties b/src/backend/ci/gradle/wrapper/gradle-wrapper.properties index be52383ef49..442d9132ea3 100644 --- a/src/backend/ci/gradle/wrapper/gradle-wrapper.properties +++ b/src/backend/ci/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From d5774336049c919c9e678e96ba7586f6f87f9d01 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 7 Jul 2021 15:46:22 +0800 Subject: [PATCH 009/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/build.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index 09a233051dc..948aad5400d 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -3,8 +3,6 @@ plugins { detektCheck } -apply("$rootDir/detekt.gradle.kts") - allprojects { apply(plugin = "com.tencent.devops.boot") apply(plugin = "maven") From 71240a0e36ec5c09e3eec214840717a88a03b1e0 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 7 Jul 2021 16:09:41 +0800 Subject: [PATCH 010/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/constants/Versions.kt | 35 ------------------- .../{ => plugins}/detektCheck.gradle.kts | 0 2 files changed, 35 deletions(-) rename src/backend/ci/buildSrc/src/main/kotlin/{ => plugins}/detektCheck.gradle.kts (100%) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt index 0df94cba851..0b1fc39cf9b 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt +++ b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt @@ -1,61 +1,26 @@ object Versions { - const val Java = "1.8" - const val Kotlin = "1.3.72" - const val SpringBoot = "2.3.4.RELEASE" - const val DependencyManagement = "1.0.10.RELEASE" - const val GradleJooq = "3.0.3" - const val GradleShadow = "5.2.0" - const val Grgit = "1.1.0" - const val Guava = "21.0" - const val SearchGuardSsl = "5.6.14-23" - const val Elasticsearch = "7.0.0" const val HashIds = "1.0.3" const val Jaxrs = "2.0" - const val OkHttp = "3.14.4" - const val Httpclient = "4.5.2" const val CommonExec = "1.3" const val Vmware = "5.1" const val BouncyCastle = "1.46" const val Dom4j = "1.6.1" - const val Compress = "1.16.1" - const val Reflections = "0.9.11" const val JsonSchema = "2.2.6" const val Jasypt = "2.0.0" - const val CommonLang3 = "3.5" - const val CommonCodec = "1.15" - const val Jooq = "3.14.7" const val Lucene = "8.6.0" - const val SpringConsul = "2.2.4.RELEASE" const val Swagger = "1.6.2" - const val Jackson = "2.11.2" - const val Feign = "9.5.1" - const val FeignForm = "3.8.0" - const val Slf4j = "1.7.25" const val Mockito = "1.10.19" const val JsonLib = "2.4" const val CronUtils = "7.0.1" - const val AwsS3 = "1.11.461" - const val AsyncHttpClient = "2.1.0" const val Sigar = "1.7.0.0" - const val Logback = "1.1.11" - const val Poi = "3.17" - const val Jolokia = "1.6.0" - const val InfluxDB = "2.10" - const val Caffeine = "2.8.8" const val Thumbnailator = "0.4.8" const val EmojiJava = "5.1.1" const val CommonCsv = "1.8" const val CommonCollections4 = "4.4" const val MockitoKt = "1.6.0" - const val Svnkit = "1.9.3" - const val JGit = "5.0.2.201807311906-r" - const val JJwt = "0.10.8" const val DockerJava = "3.2.5" - const val Jersey = "2.25.1" - const val WebSocketApi = "1.1" const val DdPlist = "1.23" const val ApkParser = "2.5.3" - const val SqlLiteJdbc = "3.23.1" const val OshiCore = "3.4.0" const val TencentBkRepo = "1.0.0" } diff --git a/src/backend/ci/buildSrc/src/main/kotlin/detektCheck.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/detektCheck.gradle.kts similarity index 100% rename from src/backend/ci/buildSrc/src/main/kotlin/detektCheck.gradle.kts rename to src/backend/ci/buildSrc/src/main/kotlin/plugins/detektCheck.gradle.kts From 10210b2115905feb5e4b3a615ebddce262e7502c Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 7 Jul 2021 18:05:23 +0800 Subject: [PATCH 011/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/build.gradle.kts | 18 +++-- src/backend/ci/buildSrc/build.gradle.kts | 10 +-- src/backend/ci/buildSrc/gradle.properties | 37 --------- .../auth/biz-auth-blueking/build.gradle.kts | 80 +++++++++---------- src/backend/ci/core/build.gradle.kts | 9 --- src/backend/ci/core/common/build.gradle.kts | 1 - .../core/common/common-api/build.gradle.kts | 5 +- .../common/common-archive/build.gradle.kts | 74 ++++++++--------- .../common/common-client/build.gradle.kts | 4 +- .../core/common/common-event/build.gradle.kts | 62 +++++++------- .../common/common-pipeline/build.gradle.kts | 66 +++++++-------- .../core/common/common-util/build.gradle.kts | 2 - .../biz-dispatch-docker/build.gradle.kts | 1 - .../model-dispatch-docker/build.gradle.kts | 61 +++++++------- .../dispatch/biz-dispatch/build.gradle.kts | 1 - .../dispatch/model-dispatch/build.gradle.kts | 61 +++++++------- .../boot-environment/build.gradle.kts | 2 - .../core/image/model-image/build.gradle.kts | 61 +++++++------- .../core/log/biz-log-sample/build.gradle.kts | 63 +++++++-------- .../ci/core/misc/boot-misc/build.gradle.kts | 2 - .../boot-monitoring/build.gradle.kts | 2 +- .../core/notify/boot-notify/build.gradle.kts | 4 +- .../core/notify/model-notify/build.gradle.kts | 61 +++++++------- .../openapi/boot-openapi/build.gradle.kts | 5 -- .../openapi/model-openapi/build.gradle.kts | 61 +++++++------- .../core/plugin/model-plugin/build.gradle.kts | 61 +++++++------- .../core/process/biz-process/build.gradle.kts | 2 +- .../project/model-project/build.gradle.kts | 61 +++++++------- .../quality/model-quality/build.gradle.kts | 61 +++++++------- .../api-repository/build.gradle.kts | 73 +++++++++-------- .../boot-repository/build.gradle.kts | 2 - .../ci/core/sign/boot-sign/build.gradle.kts | 3 - .../ci/core/sign/model-sign/build.gradle.kts | 61 +++++++------- .../core/ticket/boot-ticket/build.gradle.kts | 2 - .../core/ticket/model-ticket/build.gradle.kts | 61 +++++++------- .../websocket/boot-websocket/build.gradle.kts | 2 - .../core/worker/worker-agent/build.gradle.kts | 78 +++++++++--------- src/backend/ci/gradle.properties | 6 +- src/backend/ci/settings.gradle.kts | 4 +- 39 files changed, 573 insertions(+), 657 deletions(-) delete mode 100644 src/backend/ci/buildSrc/gradle.properties diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index 948aad5400d..fc76efb81ef 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -5,16 +5,12 @@ plugins { allprojects { apply(plugin = "com.tencent.devops.boot") - apply(plugin = "maven") // 包路径 group = "com.tencent.bk.devops.ci" // 版本 - version = (System.getProperty("ci_version") ?: "1.6.0") + if (System.getProperty("snapshot") == "true") { - "-SNAPSHOT" - } else { - "-RELEASE" - } + version = (System.getProperty("ci_version") ?: "1.6.0") + + if (System.getProperty("snapshot") == "true") "-SNAPSHOT" else "-RELEASE" // 仓库 repositories { mavenLocal() @@ -28,6 +24,7 @@ allprojects { jcenter() } + // 版本管理 dependencyManagement { dependencies { dependency("org.mockito:mockito-all:${Versions.Mockito}") @@ -68,4 +65,13 @@ allprojects { } } } + + // 兼容Junit4 + dependencies { + testImplementation("org.junit.vintage:junit-vintage-engine") + } + // 兼容 Log4j + configurations.forEach { + it.exclude("org.springframework.boot", "spring-boot-starter-logging") + } } diff --git a/src/backend/ci/buildSrc/build.gradle.kts b/src/backend/ci/buildSrc/build.gradle.kts index c48a3edd9af..09c31aca859 100644 --- a/src/backend/ci/buildSrc/build.gradle.kts +++ b/src/backend/ci/buildSrc/build.gradle.kts @@ -5,16 +5,8 @@ plugins { // 插件使用仓库 repositories { - var mavenRepoUrl: String? = System.getProperty("mavenRepoUrl") - if (mavenRepoUrl == null) { - mavenRepoUrl = System.getenv("mavenRepoUrl") - } - if (mavenRepoUrl == null) { - mavenRepoUrl = project.extra["MAVEN_REPO_URL"]?.toString() - } - mavenLocal() - maven(url = mavenRepoUrl ?: "https://repo.spring.io/libs-milestone") + maven(url = "https://plugins.gradle.org/m2/") mavenCentral() jcenter() } diff --git a/src/backend/ci/buildSrc/gradle.properties b/src/backend/ci/buildSrc/gradle.properties deleted file mode 100644 index 62db07730f5..00000000000 --- a/src/backend/ci/buildSrc/gradle.properties +++ /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. -# -MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public -MAVEN_REPO_DEPLOY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -MAVEN_REPO_USERNAME= -MAVEN_REPO_PASSWORD= -MAVEN_REPO_SNAPSHOT_DEPLOY_URL= -MAVEN_REPO_SNAPSHOT_USERNAME= -MAVEN_REPO_SNAPSHOT_PASSWORD= -DB_HOST=127.0.0.1:3306 -DB_USERNAME=root -DB_PASSWORD=root -DB_PREFIX=devops_ci_ diff --git a/src/backend/ci/core/auth/biz-auth-blueking/build.gradle.kts b/src/backend/ci/core/auth/biz-auth-blueking/build.gradle.kts index 6fa0b9f628a..b32ebb084c6 100644 --- a/src/backend/ci/core/auth/biz-auth-blueking/build.gradle.kts +++ b/src/backend/ci/core/auth/biz-auth-blueking/build.gradle.kts @@ -1,40 +1,40 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:common:common-service")) - api(project(":core:common:common-client")) - api(project(":core:common:common-auth:common-auth-api")) - api(project(":core:common:common-auth:common-auth-v3")) - api(project(":core:project:api-project-sample")) - api(project(":core:process:api-process")) - api(project(":core:repository:api-repository")) - api(project(":core:environment:api-environment")) - api(project(":core:ticket:api-ticket")) - api(project(":core:auth:api-auth-blueking")) - api(project(":core:auth:biz-auth")) -} +/* + * 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. + */ + +dependencies { + api(project(":core:common:common-service")) + api(project(":core:common:common-client")) + api(project(":core:common:common-auth:common-auth-api")) + api(project(":core:common:common-auth:common-auth-v3")) + api(project(":core:project:api-project-sample")) + api(project(":core:process:api-process")) + api(project(":core:repository:api-repository")) + api(project(":core:environment:api-environment")) + api(project(":core:ticket:api-ticket")) + api(project(":core:auth:api-auth-blueking")) + api(project(":core:auth:biz-auth")) +} diff --git a/src/backend/ci/core/build.gradle.kts b/src/backend/ci/core/build.gradle.kts index aaecff3579f..e4fa3cbbd8f 100644 --- a/src/backend/ci/core/build.gradle.kts +++ b/src/backend/ci/core/build.gradle.kts @@ -24,12 +24,3 @@ * 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. */ - -subprojects { - dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("org.jetbrains.kotlin:kotlin-reflect") - testImplementation("junit:junit") - testImplementation("org.springframework.boot:spring-boot-starter-test") - } -} diff --git a/src/backend/ci/core/common/build.gradle.kts b/src/backend/ci/core/common/build.gradle.kts index 70a29c5e3e2..b75d8aef3ec 100644 --- a/src/backend/ci/core/common/build.gradle.kts +++ b/src/backend/ci/core/common/build.gradle.kts @@ -24,7 +24,6 @@ * 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. */ - subprojects { group = "com.tencent.bk.devops.ci.common" apply(plugin = "task-deploy-to-maven") diff --git a/src/backend/ci/core/common/common-api/build.gradle.kts b/src/backend/ci/core/common/common-api/build.gradle.kts index fd8204fc7b1..516b7688965 100644 --- a/src/backend/ci/core/common/common-api/build.gradle.kts +++ b/src/backend/ci/core/common/common-api/build.gradle.kts @@ -37,10 +37,7 @@ dependencies { api("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") api("com.fasterxml.jackson.jaxrs:jackson-jaxrs-base") api("org.bouncycastle:bcprov-jdk16") - api("com.github.fge:json-schema-validator") { - exclude(group = "javax.mail", module = "mailapi") - exclude(group = "com.google.guava", module = "guava") - } + api("com.github.fge:json-schema-validator") api("com.google.guava:guava") api("com.squareup.okhttp3:okhttp") api("commons-codec:commons-codec") diff --git a/src/backend/ci/core/common/common-archive/build.gradle.kts b/src/backend/ci/core/common/common-archive/build.gradle.kts index ed2a2f5d889..02315d539aa 100644 --- a/src/backend/ci/core/common/common-archive/build.gradle.kts +++ b/src/backend/ci/core/common/common-archive/build.gradle.kts @@ -1,37 +1,37 @@ -/* - * 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. - */ - -dependencies { - api("com.fasterxml.jackson.module:jackson-module-kotlin") - api("com.fasterxml.jackson.core:jackson-databind") - api("com.fasterxml.jackson.core:jackson-core") - api("com.fasterxml.jackson.core:jackson-annotations") - api("com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider") - api("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") - api("com.fasterxml.jackson.jaxrs:jackson-jaxrs-base") - api(project(":core:common:common-pipeline")) -} +/* + * 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. + */ + +dependencies { + api("com.fasterxml.jackson.module:jackson-module-kotlin") + api("com.fasterxml.jackson.core:jackson-databind") + api("com.fasterxml.jackson.core:jackson-core") + api("com.fasterxml.jackson.core:jackson-annotations") + api("com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider") + api("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") + api("com.fasterxml.jackson.jaxrs:jackson-jaxrs-base") + api(project(":core:common:common-pipeline")) +} diff --git a/src/backend/ci/core/common/common-client/build.gradle.kts b/src/backend/ci/core/common/common-client/build.gradle.kts index 206fa4c99e3..de40d58bc4f 100644 --- a/src/backend/ci/core/common/common-client/build.gradle.kts +++ b/src/backend/ci/core/common/common-client/build.gradle.kts @@ -27,9 +27,7 @@ dependencies { api(project(":core:common:common-service")) api(project(":core:common:common-api")) - api("io.github.openfeign:feign-jaxrs") { - exclude(group = "javax.ws.rs", module = "jsr311-api") - } + api("io.github.openfeign:feign-jaxrs") api("io.github.openfeign:feign-okhttp") api("io.github.openfeign:feign-jackson") api("io.github.openfeign.form:feign-form") diff --git a/src/backend/ci/core/common/common-event/build.gradle.kts b/src/backend/ci/core/common/common-event/build.gradle.kts index 3a621588e3a..dfb61ef9762 100644 --- a/src/backend/ci/core/common/common-event/build.gradle.kts +++ b/src/backend/ci/core/common/common-event/build.gradle.kts @@ -1,31 +1,31 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:common:common-service")) - compileOnly("org.springframework.boot:spring-boot-starter-amqp") -} +/* + * 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. + */ + +dependencies { + api(project(":core:common:common-service")) + compileOnly("org.springframework.boot:spring-boot-starter-amqp") +} diff --git a/src/backend/ci/core/common/common-pipeline/build.gradle.kts b/src/backend/ci/core/common/common-pipeline/build.gradle.kts index d01161be5ba..54f6ab5ed4b 100644 --- a/src/backend/ci/core/common/common-pipeline/build.gradle.kts +++ b/src/backend/ci/core/common/common-pipeline/build.gradle.kts @@ -1,33 +1,33 @@ -/* - * 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. - */ -dependencies { - api(project(":core:common:common-api")) - api(project(":core:common:common-event")) - api("org.slf4j:slf4j-api") - api("com.squareup.okhttp3:okhttp") - api("com.cronutils:cron-utils") -} +/* + * 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. + */ +dependencies { + api(project(":core:common:common-api")) + api(project(":core:common:common-event")) + api("org.slf4j:slf4j-api") + api("com.squareup.okhttp3:okhttp") + api("com.cronutils:cron-utils") +} diff --git a/src/backend/ci/core/common/common-util/build.gradle.kts b/src/backend/ci/core/common/common-util/build.gradle.kts index d625e1868af..6750d3a81d0 100644 --- a/src/backend/ci/core/common/common-util/build.gradle.kts +++ b/src/backend/ci/core/common/common-util/build.gradle.kts @@ -31,6 +31,4 @@ dependencies { implementation("commons-codec:commons-codec") implementation("com.google.guava:guava") implementation("org.jolokia:jolokia-core") - compileOnly("org.projectlombok:lombok") - annotationProcessor("org.projectlombok:lombok") } diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/build.gradle.kts b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/build.gradle.kts index bc8405f1f6d..197927969c2 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/build.gradle.kts +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/build.gradle.kts @@ -27,7 +27,6 @@ dependencies { api(project(":core:dispatch-docker:api-dispatch-docker")) - // api(project(":core:dispatch:biz-dispatch")) api(project(":core:common:common-dispatch-sdk")) api(project(":core:common:common-service")) api(project(":core:common:common-web")) diff --git a/src/backend/ci/core/dispatch-docker/model-dispatch-docker/build.gradle.kts b/src/backend/ci/core/dispatch-docker/model-dispatch-docker/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/dispatch-docker/model-dispatch-docker/build.gradle.kts +++ b/src/backend/ci/core/dispatch-docker/model-dispatch-docker/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/dispatch/biz-dispatch/build.gradle.kts b/src/backend/ci/core/dispatch/biz-dispatch/build.gradle.kts index ce459759eb2..6cceead387a 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/build.gradle.kts +++ b/src/backend/ci/core/dispatch/biz-dispatch/build.gradle.kts @@ -34,7 +34,6 @@ dependencies { api(project(":core:notify:api-notify")) api(project(":core:monitoring:api-monitoring")) api(project(":core:log:api-log")) -// api(project(":core:store:api-store-image")) api(project(":core:common:common-service")) api(project(":core:common:common-web")) api(project(":core:common:common-client")) diff --git a/src/backend/ci/core/dispatch/model-dispatch/build.gradle.kts b/src/backend/ci/core/dispatch/model-dispatch/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/dispatch/model-dispatch/build.gradle.kts +++ b/src/backend/ci/core/dispatch/model-dispatch/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/environment/boot-environment/build.gradle.kts b/src/backend/ci/core/environment/boot-environment/build.gradle.kts index a59fd7fd0f6..5ba88e11946 100644 --- a/src/backend/ci/core/environment/boot-environment/build.gradle.kts +++ b/src/backend/ci/core/environment/boot-environment/build.gradle.kts @@ -31,5 +31,3 @@ dependencies { api(project(":core:common:common-auth:common-auth-v3")) api(project(":core:environment:biz-environment-sample")) } - - diff --git a/src/backend/ci/core/image/model-image/build.gradle.kts b/src/backend/ci/core/image/model-image/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/image/model-image/build.gradle.kts +++ b/src/backend/ci/core/image/model-image/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/log/biz-log-sample/build.gradle.kts b/src/backend/ci/core/log/biz-log-sample/build.gradle.kts index 80bcfbf54d6..7f2ca67b9ea 100644 --- a/src/backend/ci/core/log/biz-log-sample/build.gradle.kts +++ b/src/backend/ci/core/log/biz-log-sample/build.gradle.kts @@ -1,32 +1,31 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:log:biz-log")) - api(project(":core:project:api-project")) - -} +/* + * 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. + */ + +dependencies { + api(project(":core:log:biz-log")) + api(project(":core:project:api-project")) +} diff --git a/src/backend/ci/core/misc/boot-misc/build.gradle.kts b/src/backend/ci/core/misc/boot-misc/build.gradle.kts index af98b94a9f6..c0bba6d57f3 100644 --- a/src/backend/ci/core/misc/boot-misc/build.gradle.kts +++ b/src/backend/ci/core/misc/boot-misc/build.gradle.kts @@ -27,9 +27,7 @@ dependencies { api(project(":core:misc:biz-misc-sample")) - // 无对接权限中心,根据common.yml配置文件项auth.idProvider=samle启用,会忽略下面蓝鲸权限中心实现 api(project(":core:common:common-auth:common-auth-mock")) - // 对接蓝鲸的权限中心实现, 根据common.yml配置项auth.idProvider=bk_login值来决定加载 api(project(":core:common:common-auth:common-auth-blueking")) api(project(":core:common:common-auth:common-auth-v3")) } diff --git a/src/backend/ci/core/monitoring/boot-monitoring/build.gradle.kts b/src/backend/ci/core/monitoring/boot-monitoring/build.gradle.kts index 88913a39c30..95e07b28ded 100644 --- a/src/backend/ci/core/monitoring/boot-monitoring/build.gradle.kts +++ b/src/backend/ci/core/monitoring/boot-monitoring/build.gradle.kts @@ -26,7 +26,7 @@ */ dependencies { - api(project(":core:monitoring:biz-monitoring-sample")) // 开源版实现 + api(project(":core:monitoring:biz-monitoring-sample")) } diff --git a/src/backend/ci/core/notify/boot-notify/build.gradle.kts b/src/backend/ci/core/notify/boot-notify/build.gradle.kts index e28ef47fbe3..a6249410ca6 100644 --- a/src/backend/ci/core/notify/boot-notify/build.gradle.kts +++ b/src/backend/ci/core/notify/boot-notify/build.gradle.kts @@ -26,8 +26,8 @@ */ dependencies { - api(project(":core:notify:biz-notify")) // 开源版实现 - api(project(":core:notify:biz-notify-blueking")) // 对接蓝鲸实现 + api(project(":core:notify:biz-notify")) + api(project(":core:notify:biz-notify-blueking")) } diff --git a/src/backend/ci/core/notify/model-notify/build.gradle.kts b/src/backend/ci/core/notify/model-notify/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/notify/model-notify/build.gradle.kts +++ b/src/backend/ci/core/notify/model-notify/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts b/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts index 12e66314bce..99b666fc356 100644 --- a/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts +++ b/src/backend/ci/core/openapi/boot-openapi/build.gradle.kts @@ -27,10 +27,5 @@ dependencies { api(project(":core:openapi:biz-openapi")) - api(group = "net.sf.json-lib", name = "json-lib", classifier = "jdk15") - api("org.springframework.boot:spring-boot-starter-aop") - api("io.jsonwebtoken:jjwt-api") - runtimeOnly("io.jsonwebtoken:jjwt-impl") - runtimeOnly("io.jsonwebtoken:jjwt-jackson") } diff --git a/src/backend/ci/core/openapi/model-openapi/build.gradle.kts b/src/backend/ci/core/openapi/model-openapi/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/openapi/model-openapi/build.gradle.kts +++ b/src/backend/ci/core/openapi/model-openapi/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/plugin/model-plugin/build.gradle.kts b/src/backend/ci/core/plugin/model-plugin/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/plugin/model-plugin/build.gradle.kts +++ b/src/backend/ci/core/plugin/model-plugin/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/process/biz-process/build.gradle.kts b/src/backend/ci/core/process/biz-process/build.gradle.kts index cbdbac75a3a..edfe54c1bbe 100644 --- a/src/backend/ci/core/process/biz-process/build.gradle.kts +++ b/src/backend/ci/core/process/biz-process/build.gradle.kts @@ -48,6 +48,7 @@ dependencies { api(project(":core:notify:api-notify")) api(project(":core:process:biz-base")) api(project(":core:log:api-log")) + api(project(":core:common:common-webhook:biz-common-webhook")) api("com.zaxxer:HikariCP") api("mysql:mysql-connector-java") @@ -56,5 +57,4 @@ dependencies { api("io.undertow:undertow-servlet") api("io.undertow:undertow-websockets-jsr") testImplementation(project(":core:common:common-test")) - api(project(":core:common:common-webhook:biz-common-webhook")) } diff --git a/src/backend/ci/core/project/model-project/build.gradle.kts b/src/backend/ci/core/project/model-project/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/project/model-project/build.gradle.kts +++ b/src/backend/ci/core/project/model-project/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/quality/model-quality/build.gradle.kts b/src/backend/ci/core/quality/model-quality/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/quality/model-quality/build.gradle.kts +++ b/src/backend/ci/core/quality/model-quality/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/repository/api-repository/build.gradle.kts b/src/backend/ci/core/repository/api-repository/build.gradle.kts index 72f64c3aa6d..6bb8496155a 100644 --- a/src/backend/ci/core/repository/api-repository/build.gradle.kts +++ b/src/backend/ci/core/repository/api-repository/build.gradle.kts @@ -1,37 +1,36 @@ -/* - * 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. - */ - -dependencies { - api(project(":core:common:common-api")) - api(project(":core:common:common-scm")) - api(project(":core:common:common-auth:common-auth-api")) -} - - -plugins { - `task-deploy-to-maven` -} +/* + * 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. + */ + +dependencies { + api(project(":core:common:common-api")) + api(project(":core:common:common-scm")) + api(project(":core:common:common-auth:common-auth-api")) +} + +plugins { + `task-deploy-to-maven` +} diff --git a/src/backend/ci/core/repository/boot-repository/build.gradle.kts b/src/backend/ci/core/repository/boot-repository/build.gradle.kts index f4b5d53a70b..862ecf5254b 100644 --- a/src/backend/ci/core/repository/boot-repository/build.gradle.kts +++ b/src/backend/ci/core/repository/boot-repository/build.gradle.kts @@ -27,9 +27,7 @@ dependencies { api(project(":core:repository:biz-repository-sample")) - // 无对接权限中心,根据common.yml配置文件项auth.idProvider=samle启用,会忽略下面蓝鲸权限中心实现 api(project(":core:common:common-auth:common-auth-mock")) - // 对接蓝鲸的权限中心实现, 根据common.yml配置项auth.idProvider=bk_login值来决定加载 api(project(":core:common:common-auth:common-auth-blueking")) api(project(":core:common:common-auth:common-auth-v3")) } diff --git a/src/backend/ci/core/sign/boot-sign/build.gradle.kts b/src/backend/ci/core/sign/boot-sign/build.gradle.kts index 0b57548a451..a72dabbe0d0 100644 --- a/src/backend/ci/core/sign/boot-sign/build.gradle.kts +++ b/src/backend/ci/core/sign/boot-sign/build.gradle.kts @@ -29,6 +29,3 @@ dependencies { api(project(":core:common:common-auth:common-auth-mock")) api(project(":core:sign:biz-sign-sample")) } - - - diff --git a/src/backend/ci/core/sign/model-sign/build.gradle.kts b/src/backend/ci/core/sign/model-sign/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/sign/model-sign/build.gradle.kts +++ b/src/backend/ci/core/sign/model-sign/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/ticket/boot-ticket/build.gradle.kts b/src/backend/ci/core/ticket/boot-ticket/build.gradle.kts index f0fc47de4cd..693dc97be7b 100644 --- a/src/backend/ci/core/ticket/boot-ticket/build.gradle.kts +++ b/src/backend/ci/core/ticket/boot-ticket/build.gradle.kts @@ -31,5 +31,3 @@ dependencies { api(project(":core:common:common-auth:common-auth-blueking")) api(project(":core:common:common-auth:common-auth-v3")) } - - diff --git a/src/backend/ci/core/ticket/model-ticket/build.gradle.kts b/src/backend/ci/core/ticket/model-ticket/build.gradle.kts index 727a2c6f0a1..a5ab961b88b 100644 --- a/src/backend/ci/core/ticket/model-ticket/build.gradle.kts +++ b/src/backend/ci/core/ticket/model-ticket/build.gradle.kts @@ -1,31 +1,30 @@ -/* - * 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. - */ - -plugins { - `task-gen-jooq` - -} +/* + * 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. + */ + +plugins { + `task-gen-jooq` +} diff --git a/src/backend/ci/core/websocket/boot-websocket/build.gradle.kts b/src/backend/ci/core/websocket/boot-websocket/build.gradle.kts index f93396c5c1f..072f752caa9 100644 --- a/src/backend/ci/core/websocket/boot-websocket/build.gradle.kts +++ b/src/backend/ci/core/websocket/boot-websocket/build.gradle.kts @@ -29,5 +29,3 @@ dependencies { api(project(":core:websocket:biz-websocket")) api(project(":core:websocket:biz-websocket-blueking")) } - - diff --git a/src/backend/ci/core/worker/worker-agent/build.gradle.kts b/src/backend/ci/core/worker/worker-agent/build.gradle.kts index 130ec4c85a0..e87438fb5cd 100644 --- a/src/backend/ci/core/worker/worker-agent/build.gradle.kts +++ b/src/backend/ci/core/worker/worker-agent/build.gradle.kts @@ -1,39 +1,39 @@ -/* - * 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. - */ - -plugins { - `task-shadow-jar` -} - -application.mainClassName = "com.tencent.devops.agent.ApplicationKt" - -dependencies { - api(project(":core:worker:worker-common")) - api(project(":core:worker:worker-api-sdk")) - - api(project(":core:plugin:codecc-plugin:worker-plugin-codecc")) -} +/* + * 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. + */ + +plugins { + `task-shadow-jar` +} + +application.mainClass.set("com.tencent.devops.agent.ApplicationKt") + +dependencies { + api(project(":core:worker:worker-common")) + api(project(":core:worker:worker-api-sdk")) + + api(project(":core:plugin:codecc-plugin:worker-plugin-codecc")) +} diff --git a/src/backend/ci/gradle.properties b/src/backend/ci/gradle.properties index 8e76821ddd5..42b47f07c6a 100644 --- a/src/backend/ci/gradle.properties +++ b/src/backend/ci/gradle.properties @@ -23,6 +23,9 @@ # 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. # +# devops-framework 版本 +DEVOPS_BOOT_VERSION=0.0.4-SNAPSHOT +# 版本仓库配置 MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public MAVEN_REPO_DEPLOY_URL= MAVEN_REPO_USERNAME= @@ -30,9 +33,10 @@ MAVEN_REPO_PASSWORD= MAVEN_REPO_SNAPSHOT_DEPLOY_URL= MAVEN_REPO_SNAPSHOT_USERNAME= MAVEN_REPO_SNAPSHOT_PASSWORD= +#数据库配置 DB_HOST=127.0.0.1:3306 DB_USERNAME=root DB_PASSWORD=root DB_PREFIX=devops_ci_ -devopsBootVersion=0.0.4-SNAPSHOT +# Gradle参数配置 org.gradle.jvmargs=-Xmx2048M -Xms2048M diff --git a/src/backend/ci/settings.gradle.kts b/src/backend/ci/settings.gradle.kts index df1cc8f8d4a..e5a9f41747d 100644 --- a/src/backend/ci/settings.gradle.kts +++ b/src/backend/ci/settings.gradle.kts @@ -28,9 +28,9 @@ rootProject.name = "bk-ci-backend" pluginManagement { - val devopsBootVersion: String by settings + val DEVOPS_BOOT_VERSION: String by settings plugins { - id("com.tencent.devops.boot") version devopsBootVersion + id("com.tencent.devops.boot") version DEVOPS_BOOT_VERSION } repositories { mavenLocal() From a8d955f1f20c893f23084d329e0f11c91ddf5140 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 7 Jul 2021 18:08:11 +0800 Subject: [PATCH 012/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/settings.gradle.kts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/settings.gradle.kts b/src/backend/ci/settings.gradle.kts index e5a9f41747d..992408e428b 100644 --- a/src/backend/ci/settings.gradle.kts +++ b/src/backend/ci/settings.gradle.kts @@ -33,7 +33,9 @@ pluginManagement { id("com.tencent.devops.boot") version DEVOPS_BOOT_VERSION } repositories { - mavenLocal() + // TODO 使用SNAPSHOT仓库 , 正式版不用使用 + //mavenLocal() + maven(url = "https://oss.sonatype.org/content/repositories/snapshots/") mavenCentral() gradlePluginPortal() } From 8e7a2151afd5abc29e7ffe1422d16bf3eeb06f83 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 13 Jul 2021 11:21:16 +0800 Subject: [PATCH 013/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/build.gradle.kts | 1 + src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt | 2 +- src/backend/ci/core/common/common-service/build.gradle.kts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index fc76efb81ef..2d28e74c887 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -52,6 +52,7 @@ allprojects { dependencySet("io.swagger:${Versions.Swagger}") { entry("swagger-annotations") entry("swagger-jersey2-jaxrs") + entry("swagger-models") } dependencySet("com.github.docker-java:${Versions.DockerJava}") { diff --git a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt index 0b1fc39cf9b..35fe41ac0da 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt +++ b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt @@ -6,7 +6,7 @@ object Versions { const val BouncyCastle = "1.46" const val Dom4j = "1.6.1" const val JsonSchema = "2.2.6" - const val Jasypt = "2.0.0" + const val Jasypt = "3.0.3" const val Lucene = "8.6.0" const val Swagger = "1.6.2" const val Mockito = "1.10.19" diff --git a/src/backend/ci/core/common/common-service/build.gradle.kts b/src/backend/ci/core/common/common-service/build.gradle.kts index a317ed3d994..9e49df8b73c 100644 --- a/src/backend/ci/core/common/common-service/build.gradle.kts +++ b/src/backend/ci/core/common/common-service/build.gradle.kts @@ -36,4 +36,5 @@ dependencies { api("javax.servlet:javax.servlet-api") api("org.springframework:spring-web") api("org.apache.commons:commons-lang3") + api("org.springframework.cloud:spring-cloud-starter-bootstrap") } From 5642cd7f2096e3af1f37ec6b096508b85a4e7729 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 13 Jul 2021 11:25:12 +0800 Subject: [PATCH 014/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/core/log/build.gradle.kts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/ci/core/log/build.gradle.kts b/src/backend/ci/core/log/build.gradle.kts index 2790d798f20..01346dad464 100644 --- a/src/backend/ci/core/log/build.gradle.kts +++ b/src/backend/ci/core/log/build.gradle.kts @@ -27,4 +27,11 @@ subprojects { group = "com.tencent.bk.devops.ci.log" + + // 解决依赖冲突:process要求lucene-8.6.0,es-rest-client7.0.0要求lucene-8.0.0 + dependencyManagement { + dependencies { + dependency("org.apache.lucene:lucene-core:8.0.0") + } + } } From dd8a2c7a55827bd597f1f0c367d662fe068975c7 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 13 Jul 2021 15:46:50 +0800 Subject: [PATCH 015/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/common/client/ms/MicroServiceTarget.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ms/MicroServiceTarget.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ms/MicroServiceTarget.kt index 6c1f948c606..2492b6fffb6 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ms/MicroServiceTarget.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ms/MicroServiceTarget.kt @@ -35,6 +35,7 @@ import feign.Request import feign.RequestTemplate import org.springframework.cloud.client.ServiceInstance import org.springframework.cloud.consul.discovery.ConsulDiscoveryClient +import org.springframework.cloud.consul.discovery.ConsulServiceInstance import java.util.concurrent.ConcurrentHashMap @Suppress("ALL") @@ -66,12 +67,8 @@ class MicroServiceTarget constructor( consulContentTag } else tag - instances.forEach next@{ serviceInstance -> - if (serviceInstance.metadata.isEmpty()) { - return@next - } - - if (serviceInstance.metadata.values.contains(useConsulTag)) { + instances.forEach { serviceInstance -> + if (serviceInstance is ConsulServiceInstance && serviceInstance.tags.contains(useConsulTag)) { // 已经用过的不选择 if (!usedInstance.contains(serviceInstance.url())) { matchTagInstances.add(serviceInstance) From 639e2aac2241e1899d0944b7f87ae6bfd9c1c95d Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 14 Jul 2021 17:08:41 +0800 Subject: [PATCH 016/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/core/common/common-notify/build.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/backend/ci/core/common/common-notify/build.gradle.kts b/src/backend/ci/core/common/common-notify/build.gradle.kts index ebd7a2a8061..061307305fc 100644 --- a/src/backend/ci/core/common/common-notify/build.gradle.kts +++ b/src/backend/ci/core/common/common-notify/build.gradle.kts @@ -28,6 +28,4 @@ dependencies { api(project(":core:common:common-pipeline")) api(project(":core:common:common-web")) - api("org.mockito:mockito-all") - api("com.nhaarman:mockito-kotlin-kt1.1") } From 69d93d041ada1e2fa77cc513c5ab394ae30ed318 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Thu, 22 Jul 2021 17:43:46 +0800 Subject: [PATCH 017/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/build.gradle.kts | 30 +++++++++---------- .../src/main/kotlin/constants/Versions.kt | 10 ++++++- .../kotlin/plugins/task-gen-jooq.gradle.kts | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index fee09203330..091b49243dc 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -11,21 +11,10 @@ allprojects { // 版本 version = (System.getProperty("ci_version") ?: "1.6.0") + if (System.getProperty("snapshot") == "true") "-SNAPSHOT" else "-RELEASE" - // 仓库 - repositories { - mavenLocal() - maven( - url = System.getProperty("mavenRepoUrl") - ?: System.getenv("mavenRepoUrl") - ?: extra["MAVEN_REPO_URL"]?.toString() - ?: "https://repo.spring.io/libs-milestone" - ) - mavenCentral() - jcenter() - } // 版本管理 dependencyManagement { + setApplyMavenExclusions(false) dependencies { dependency("org.mockito:mockito-all:${Versions.Mockito}") dependency("com.nhaarman:mockito-kotlin-kt1.1:${Versions.MockitoKt}") @@ -42,28 +31,37 @@ allprojects { dependency("org.apache.commons:commons-collections4:${Versions.CommonCollections4}") dependency("net.coobird:thumbnailator:${Versions.Thumbnailator}") dependency("com.vmware:vijava:${Versions.Vmware}") - dependency("com.tencent.devops.ci-plugins:sigar:${Versions.Sigar}") + dependency("com.tencent.devops.ci-plugins:sigar:${Versions.SigarPlugin}") dependency("net.sf.json-lib:json-lib:${Versions.JsonLib}") dependency("com.googlecode.plist:dd-plist:${Versions.DdPlist}") dependency("com.github.oshi:oshi-core:${Versions.OshiCore}") dependency("net.dongliu:apk-parser:${Versions.ApkParser}") dependency("dom4j:dom4j:${Versions.Dom4j}") - + dependency("org.apache.ant:ant:${Versions.Ant}") + dependency("cglib:cglib:${Versions.Cglib}") + dependency("org.fusesource:sigar:${Versions.Sigar}") + dependency("com.floragunn:search-guard-ssl:${Versions.SearchGuardSsl}") + dependency("org.asynchttpclient:async-http-client:${Versions.AsyncHttpClient}") + dependency("me.cassiano:ktlint-html-reporter:${Versions.KtlintHtmlReport}") + dependency("com.github.shyiko:ktlint:${Versions.Ktlint}") + dependency("log4j:log4j:1.2.17") dependencySet("io.swagger:${Versions.Swagger}") { entry("swagger-annotations") entry("swagger-jersey2-jaxrs") entry("swagger-models") } - dependencySet("com.github.docker-java:${Versions.DockerJava}") { entry("docker-java") entry("docker-java-transport-okhttp") } - dependencySet("com.tencent.bkrepo:${Versions.TencentBkRepo}") { entry("api-generic") entry("api-repository") } + dependencySet("org.apache.poi:${Versions.Poi}") { + entry("poi") + entry("poi-ooxml") + } } } diff --git a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt index 35fe41ac0da..a2859b29b6c 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt +++ b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt @@ -12,7 +12,7 @@ object Versions { const val Mockito = "1.10.19" const val JsonLib = "2.4" const val CronUtils = "7.0.1" - const val Sigar = "1.7.0.0" + const val SigarPlugin = "1.7.0.0" const val Thumbnailator = "0.4.8" const val EmojiJava = "5.1.1" const val CommonCsv = "1.8" @@ -23,4 +23,12 @@ object Versions { const val ApkParser = "2.5.3" const val OshiCore = "3.4.0" const val TencentBkRepo = "1.0.0" + const val Ant = "1.10.5" + const val Cglib = "2.2.2" + const val Sigar = "1.6.4" + const val SearchGuardSsl = "5.6.14-23" + const val Poi = "3.17" + const val AsyncHttpClient = "2.1.0" + const val KtlintHtmlReport = "0.1.2" + const val Ktlint = "0.29.0" } diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts index 40cfbb90fc4..55cdb40ae15 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts @@ -86,7 +86,7 @@ jooq { mysqlPasswd = project.extra["DB_PASSWORD"]?.toString() } - driver = "com.mysql.jdbc.Driver" + driver = "com.mysql.cj.jdbc.Driver" url = "jdbc:mysql://$mysqlURL/$databaseName?useSSL=false" user = mysqlUser password = mysqlPasswd From e56d2f53a27d9380f09cddb4c864e0ddeba101ee Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 27 Jul 2021 17:07:31 +0800 Subject: [PATCH 018/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/common/redis/RedisLock.kt | 2 +- .../tencent/devops/common/redis/RedisLockByValue.kt | 2 +- .../tencent/devops/common/redis/RedisOperation.kt | 13 ++++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisLock.kt b/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisLock.kt index 500e1fe287f..6fabc06e47b 100644 --- a/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisLock.kt +++ b/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisLock.kt @@ -186,7 +186,7 @@ open class RedisLock( } locked = result == 0L result == 1L - }) + }) ?: false } else { logger.info("It's already unlock") } diff --git a/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisLockByValue.kt b/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisLockByValue.kt index 84f33ed08c6..3c3c08ce5db 100644 --- a/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisLockByValue.kt +++ b/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisLockByValue.kt @@ -200,7 +200,7 @@ class RedisLockByValue( } } queryResult == 1L - }) + }) ?: false } return result } diff --git a/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisOperation.kt b/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisOperation.kt index afa011950e7..9e8ffe98193 100644 --- a/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisOperation.kt +++ b/src/backend/ci/core/common/common-redis/src/main/kotlin/com/tencent/devops/common/redis/RedisOperation.kt @@ -31,7 +31,6 @@ import org.springframework.data.redis.core.Cursor import org.springframework.data.redis.core.RedisCallback import org.springframework.data.redis.core.RedisTemplate import org.springframework.data.redis.core.ScanOptions -import java.lang.NullPointerException import java.util.Date import java.util.concurrent.TimeUnit @@ -170,8 +169,16 @@ class RedisOperation(private val redisTemplate: RedisTemplate, p redisTemplate.expire(key, expiredInSecond, TimeUnit.SECONDS) } - fun execute(action: RedisCallback): T { - return redisTemplate.execute(action) ?: throw NullPointerException() + fun execute(action: RedisCallback): T? { + return redisTemplate.execute(action) + } + + fun leftPush(key: String, value: String): Long? { + return redisTemplate.opsForList().leftPush(key, value) + } + + fun rightPop(key: String): String? { + return redisTemplate.opsForList().rightPop(key) } fun getRedisName(): String? { From dc9f0750affa7acb5719ed8905ed5a0a39b21fc0 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Thu, 29 Jul 2021 15:55:48 +0800 Subject: [PATCH 019/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts index cac780e83d2..d48f74ab55c 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-gen-jooq.gradle.kts @@ -147,7 +147,6 @@ jooq { tasks.getByName("compileKotlin") { destinationDir = File("build/generated-src") tasks.matching { it is JooqGenerate }.forEach { - println("#task: ${it.name} , group: ${it.group}") dependsOn(it.name) } } From 91e25ecb7e39838e670c30e2084e47c8d99d1be5 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Thu, 29 Jul 2021 18:17:20 +0800 Subject: [PATCH 020/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/gradle.properties | 2 +- src/backend/ci/settings.gradle.kts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/backend/ci/gradle.properties b/src/backend/ci/gradle.properties index 42b47f07c6a..fd478992d01 100644 --- a/src/backend/ci/gradle.properties +++ b/src/backend/ci/gradle.properties @@ -24,7 +24,7 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # devops-framework 版本 -DEVOPS_BOOT_VERSION=0.0.4-SNAPSHOT +DEVOPS_BOOT_VERSION=0.0.4 # 版本仓库配置 MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public MAVEN_REPO_DEPLOY_URL= diff --git a/src/backend/ci/settings.gradle.kts b/src/backend/ci/settings.gradle.kts index 992408e428b..e5a9f41747d 100644 --- a/src/backend/ci/settings.gradle.kts +++ b/src/backend/ci/settings.gradle.kts @@ -33,9 +33,7 @@ pluginManagement { id("com.tencent.devops.boot") version DEVOPS_BOOT_VERSION } repositories { - // TODO 使用SNAPSHOT仓库 , 正式版不用使用 - //mavenLocal() - maven(url = "https://oss.sonatype.org/content/repositories/snapshots/") + mavenLocal() mavenCentral() gradlePluginPortal() } From 019fd25c5561e36f6fb77bf60eaa414fcb3a42b7 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Fri, 30 Jul 2021 20:38:20 +0800 Subject: [PATCH 021/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/build.gradle.kts | 7 ++++++- .../ci/buildSrc/src/main/kotlin/constants/Versions.kt | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index 091b49243dc..18e6045bdfe 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -44,7 +44,12 @@ allprojects { dependency("org.asynchttpclient:async-http-client:${Versions.AsyncHttpClient}") dependency("me.cassiano:ktlint-html-reporter:${Versions.KtlintHtmlReport}") dependency("com.github.shyiko:ktlint:${Versions.Ktlint}") - dependency("log4j:log4j:1.2.17") + dependencySet("io.github.openfeign:${Versions.Feign}") { + entry("feign-core") + entry("feign-jackson") + entry("feign-jaxrs") + entry("feign-okhttp") + } dependencySet("io.swagger:${Versions.Swagger}") { entry("swagger-annotations") entry("swagger-jersey2-jaxrs") diff --git a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt index a2859b29b6c..6d0ee8b4870 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt +++ b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt @@ -31,4 +31,5 @@ object Versions { const val AsyncHttpClient = "2.1.0" const val KtlintHtmlReport = "0.1.2" const val Ktlint = "0.29.0" + const val Feign = "11.6" //TODO 修复这个BUG:https://github.com/OpenFeign/feign/pull/1347 , 后续SpringCloud升级后可以去掉 } From 63d66f2f109140900d53dc9eabfce0f5de5ada60 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Mon, 2 Aug 2021 12:15:30 +0800 Subject: [PATCH 022/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/artifactory/service/impl/FileTaskServiceImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/FileTaskServiceImpl.kt b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/FileTaskServiceImpl.kt index 722c7e4469b..a5780db714d 100644 --- a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/FileTaskServiceImpl.kt +++ b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/FileTaskServiceImpl.kt @@ -206,7 +206,7 @@ class FileTaskServiceImpl : FileTaskService { } } - @Scheduled(cron = "0 0 9 0/1 * ?") + @Scheduled(cron = "0 0 9 * * ?") fun clearRecordTask() { logger.info("clearRecordTask start") if (!clearRecordEnable) { From b58b552d65df3a3933f8e68301230e8b6be900de Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 4 Aug 2021 12:14:29 +0800 Subject: [PATCH 023/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/core/dockerhost/build.gradle.kts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/ci/core/dockerhost/build.gradle.kts b/src/backend/ci/core/dockerhost/build.gradle.kts index e9af1cdd8c0..84e4a3de320 100644 --- a/src/backend/ci/core/dockerhost/build.gradle.kts +++ b/src/backend/ci/core/dockerhost/build.gradle.kts @@ -26,4 +26,9 @@ */ subprojects { group = "com.tencent.bk.devops.ci.dockerhost" + + configurations.forEach { + it.exclude("org.springframework.cloud", "spring-cloud-starter-config") + it.exclude("org.springframework.cloud", "spring-cloud-starter-consul-config") + } } From e8c7ceca35d7f37be66736a8b437dfca6f09b831 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 4 Aug 2021 18:39:18 +0800 Subject: [PATCH 024/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/install/backend.en.md | 4 ++-- docs/install/backend.md | 4 ++-- docs/overview/installation.en.md | 4 ++-- docs/overview/installation.md | 4 ++-- docs/overview/source_compile.en.md | 2 +- docs/overview/source_compile.md | 2 +- docs/wiki/collaborative_development_guidelines.md | 2 +- src/backend/ci/build.gradle.kts | 3 +++ .../ci/buildSrc/src/main/kotlin/constants/Versions.kt | 3 ++- src/backend/ci/core/log/build.gradle.kts | 7 ------- 10 files changed, 16 insertions(+), 19 deletions(-) diff --git a/docs/install/backend.en.md b/docs/install/backend.en.md index 86c9c457efa..f419b6aeda1 100644 --- a/docs/install/backend.en.md +++ b/docs/install/backend.en.md @@ -5,10 +5,10 @@ There are 10 microservices (artifactory, dispatch, environment, log, plugin, pro ## 1. System Requirements - JDK 1.8 -- Gradle 4.8 +- Gradle 6.7 - Redis 2.8.17 - MySQL 5.7 -- ES 5.6 +- ES 7.4 - Consul 1.0 [Consul Installation](consul.en.md) - RabbitMQ 3.7.15 [RabbitMQ Deployment](rabbitmq.en.md) diff --git a/docs/install/backend.md b/docs/install/backend.md index 43cb7cbc18a..4c6920f17b3 100644 --- a/docs/install/backend.md +++ b/docs/install/backend.md @@ -5,10 +5,10 @@ ## 1.系统要求 jdk: 1.8 -gradle: 4.8 +gradle: 6.7 redis: 2.8.17 mysql 5.7 -es: 5.6 +es: 7.4 consul: 1.0 [Consul安装](consul.md) rabbitmq: 3.7.15 [rabbitmq部署](rabbitmq.md) diff --git a/docs/overview/installation.en.md b/docs/overview/installation.en.md index 01072e46a73..a725e3d0375 100644 --- a/docs/overview/installation.en.md +++ b/docs/overview/installation.en.md @@ -40,10 +40,10 @@ The following directories are explained in detail. - CentOS 7.x - JDK 1.8 -- Gradle 4.8 +- Gradle 6.7 - Redis 2.8.17 - MySQL 5.7 -- ES 5.6 +- ES 7.4 - RabbitMQ 3.7.15 [RabbitMQ Installation Document](../install/rabbitmq.en.md) - Consul 1.0+ [Consul Installation](../install/consul.en.md) diff --git a/docs/overview/installation.md b/docs/overview/installation.md index 929affd649f..faeacca3335 100644 --- a/docs/overview/installation.md +++ b/docs/overview/installation.md @@ -40,10 +40,10 @@ - CentOS 7.X - jdk: 1.8 -- gradle: 4.8 +- gradle: 6.7 - redis: 2.8.17 - mysql 5.7 -- es: 5.6 +- es: 7.4 - rabbitmq: 3.7.15 [rabbitMQ 安装文档](../install/rabbitmq.md) - Consul 1.0+ [Consul安装](../install/consul.md) diff --git a/docs/overview/source_compile.en.md b/docs/overview/source_compile.en.md index 1e903571577..c49bb91134f 100644 --- a/docs/overview/source_compile.en.md +++ b/docs/overview/source_compile.en.md @@ -61,7 +61,7 @@ The gateway is built with Lua scripts and Nginx configurations, so no compilatio - MySQL 5.7 - JDK 1.8 -- Gradle 4.8 – 4.10 +- Gradle 6.7 #### Database Initialization diff --git a/docs/overview/source_compile.md b/docs/overview/source_compile.md index d453476aabf..f9a5fe09833 100644 --- a/docs/overview/source_compile.md +++ b/docs/overview/source_compile.md @@ -62,7 +62,7 @@ yarn public - MySQL 5.7 - JDK 1.8 -- Gradle 4.8 - 4.10 +- Gradle 6.7 #### 数据库初始化 diff --git a/docs/wiki/collaborative_development_guidelines.md b/docs/wiki/collaborative_development_guidelines.md index e406d66a114..ffe9a1830e4 100644 --- a/docs/wiki/collaborative_development_guidelines.md +++ b/docs/wiki/collaborative_development_guidelines.md @@ -10,7 +10,7 @@ #### 1.2、安装gradle -​ bk-ci使用gradle作为构建工具,gradle的版本建议使用4.8-4.10,gradle可以直接从gradle官网下载下来安装即可(gradle官网地址详见:[gradle官网](https://gradle.org/))。 +​ bk-ci使用gradle作为构建工具,gradle的版本建议使用6.7,gradle可以直接从gradle官网下载下来安装即可(gradle官网地址详见:[gradle官网](https://gradle.org/))。 #### 1.3、安装IDE开发工具 diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index 18e6045bdfe..149b2da0fed 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -44,6 +44,9 @@ allprojects { dependency("org.asynchttpclient:async-http-client:${Versions.AsyncHttpClient}") dependency("me.cassiano:ktlint-html-reporter:${Versions.KtlintHtmlReport}") dependency("com.github.shyiko:ktlint:${Versions.Ktlint}") + dependency("org.elasticsearch:elasticsearch:${Versions.Elasticsearch}") + dependency("org.elasticsearch.client:elasticsearch-rest-client:${Versions.Elasticsearch}") + dependency("org.elasticsearch.client:elasticsearch-rest-high-level-client:${Versions.Elasticsearch}") dependencySet("io.github.openfeign:${Versions.Feign}") { entry("feign-core") entry("feign-jackson") diff --git a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt index 6d0ee8b4870..9d2554ced63 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt +++ b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt @@ -7,7 +7,6 @@ object Versions { const val Dom4j = "1.6.1" const val JsonSchema = "2.2.6" const val Jasypt = "3.0.3" - const val Lucene = "8.6.0" const val Swagger = "1.6.2" const val Mockito = "1.10.19" const val JsonLib = "2.4" @@ -31,5 +30,7 @@ object Versions { const val AsyncHttpClient = "2.1.0" const val KtlintHtmlReport = "0.1.2" const val Ktlint = "0.29.0" + const val Elasticsearch = "7.4.0" + const val Lucene = "8.2.0" const val Feign = "11.6" //TODO 修复这个BUG:https://github.com/OpenFeign/feign/pull/1347 , 后续SpringCloud升级后可以去掉 } diff --git a/src/backend/ci/core/log/build.gradle.kts b/src/backend/ci/core/log/build.gradle.kts index 01346dad464..2790d798f20 100644 --- a/src/backend/ci/core/log/build.gradle.kts +++ b/src/backend/ci/core/log/build.gradle.kts @@ -27,11 +27,4 @@ subprojects { group = "com.tencent.bk.devops.ci.log" - - // 解决依赖冲突:process要求lucene-8.6.0,es-rest-client7.0.0要求lucene-8.0.0 - dependencyManagement { - dependencies { - dependency("org.apache.lucene:lucene-core:8.0.0") - } - } } From bff01b2ca506eb3ae8cfd8d5810d0e1819e974ce Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 17 Aug 2021 11:55:18 +0800 Subject: [PATCH 025/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/buildSrc/build.gradle.kts | 1 - src/backend/ci/core/worker/worker-agent/build.gradle.kts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/ci/buildSrc/build.gradle.kts b/src/backend/ci/buildSrc/build.gradle.kts index 09c31aca859..98a90a35674 100644 --- a/src/backend/ci/buildSrc/build.gradle.kts +++ b/src/backend/ci/buildSrc/build.gradle.kts @@ -15,5 +15,4 @@ repositories { dependencies { implementation("nu.studer:gradle-jooq-plugin:5.2.1") implementation("com.github.jengelman.gradle.plugins:shadow:5.2.0") - implementation("org.ajoberstar:grgit:1.1.0") } diff --git a/src/backend/ci/core/worker/worker-agent/build.gradle.kts b/src/backend/ci/core/worker/worker-agent/build.gradle.kts index e87438fb5cd..d0a5fcfa11b 100644 --- a/src/backend/ci/core/worker/worker-agent/build.gradle.kts +++ b/src/backend/ci/core/worker/worker-agent/build.gradle.kts @@ -29,7 +29,7 @@ plugins { `task-shadow-jar` } -application.mainClass.set("com.tencent.devops.agent.ApplicationKt") +application.mainClassName = "com.tencent.devops.agent.ApplicationKt" dependencies { api(project(":core:worker:worker-common")) From 99fb6941fc0b55f926bfcb1913518e64a6cb1573 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 17 Aug 2021 14:35:02 +0800 Subject: [PATCH 026/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/buildSrc/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/buildSrc/build.gradle.kts b/src/backend/ci/buildSrc/build.gradle.kts index 98a90a35674..8bf8ca9abff 100644 --- a/src/backend/ci/buildSrc/build.gradle.kts +++ b/src/backend/ci/buildSrc/build.gradle.kts @@ -14,5 +14,5 @@ repositories { // 依赖插件 dependencies { implementation("nu.studer:gradle-jooq-plugin:5.2.1") - implementation("com.github.jengelman.gradle.plugins:shadow:5.2.0") + implementation("com.github.jengelman.gradle.plugins:shadow:6.1.0") } From b3dafa915130e53d7b26911fe9913f6cea94a473 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 17 Aug 2021 15:29:45 +0800 Subject: [PATCH 027/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- support-files/templates/gateway#core#devops.server.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/support-files/templates/gateway#core#devops.server.conf b/support-files/templates/gateway#core#devops.server.conf index da61a3c48b4..f60807c9853 100644 --- a/support-files/templates/gateway#core#devops.server.conf +++ b/support-files/templates/gateway#core#devops.server.conf @@ -35,9 +35,6 @@ server { #后台的网关路径 include backend.conf; - # 后台特殊路径 - include vhosts/devops.backend.special.conf; - # 代理 include vhosts/devops.proxy.conf; From a2158a1786ab939d960fccbedbfa7eb7e7aa3522 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Thu, 19 Aug 2021 11:36:17 +0800 Subject: [PATCH 028/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt | 2 +- src/backend/ci/gradle.properties | 2 +- src/backend/ci/settings.gradle.kts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt index 9d2554ced63..69e106f3a5e 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt +++ b/src/backend/ci/buildSrc/src/main/kotlin/constants/Versions.kt @@ -32,5 +32,5 @@ object Versions { const val Ktlint = "0.29.0" const val Elasticsearch = "7.4.0" const val Lucene = "8.2.0" - const val Feign = "11.6" //TODO 修复这个BUG:https://github.com/OpenFeign/feign/pull/1347 , 后续SpringCloud升级后可以去掉 + const val Feign = "11.6" // TODO 修复这个BUG:https://github.com/OpenFeign/feign/pull/1347 , 后续SpringCloud升级后可以去掉 } diff --git a/src/backend/ci/gradle.properties b/src/backend/ci/gradle.properties index fd478992d01..2c86696a673 100644 --- a/src/backend/ci/gradle.properties +++ b/src/backend/ci/gradle.properties @@ -24,7 +24,7 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # devops-framework 版本 -DEVOPS_BOOT_VERSION=0.0.4 +devopsBootVersion=0.0.4 # 版本仓库配置 MAVEN_REPO_URL=http://mirrors.cloud.tencent.com/nexus/repository/maven-public MAVEN_REPO_DEPLOY_URL= diff --git a/src/backend/ci/settings.gradle.kts b/src/backend/ci/settings.gradle.kts index e5a9f41747d..df1cc8f8d4a 100644 --- a/src/backend/ci/settings.gradle.kts +++ b/src/backend/ci/settings.gradle.kts @@ -28,9 +28,9 @@ rootProject.name = "bk-ci-backend" pluginManagement { - val DEVOPS_BOOT_VERSION: String by settings + val devopsBootVersion: String by settings plugins { - id("com.tencent.devops.boot") version DEVOPS_BOOT_VERSION + id("com.tencent.devops.boot") version devopsBootVersion } repositories { mavenLocal() From 055a5e23e8b3bf1bb0d9cb60c78b079ffabaefb5 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 24 Aug 2021 10:39:28 +0800 Subject: [PATCH 029/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/gradle.properties | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/gradle.properties b/src/backend/ci/gradle.properties index 2c86696a673..9a596aeb2d5 100644 --- a/src/backend/ci/gradle.properties +++ b/src/backend/ci/gradle.properties @@ -39,4 +39,7 @@ DB_USERNAME=root DB_PASSWORD=root DB_PREFIX=devops_ci_ # Gradle参数配置 -org.gradle.jvmargs=-Xmx2048M -Xms2048M +org.gradle.daemon=true +org.gradle.configureondemand=false +org.gradle.parallel=true +org.gradle.caching=true From 66e5854cc8b274ad044a1652cd3ebd1a392fd1dc Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 24 Aug 2021 16:59:26 +0800 Subject: [PATCH 030/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/websocket/configuration/WebSocketConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/configuration/WebSocketConfig.kt b/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/configuration/WebSocketConfig.kt index 0fd77c6089a..8b747c3080e 100644 --- a/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/configuration/WebSocketConfig.kt +++ b/src/backend/ci/core/websocket/biz-websocket/src/main/kotlin/com/tencent/devops/websocket/configuration/WebSocketConfig.kt @@ -69,7 +69,7 @@ class WebSocketConfig @Autowired constructor( } override fun registerStompEndpoints(registry: StompEndpointRegistry) { - registry.addEndpoint("/ws/user").addInterceptors(bkHandshake).setAllowedOrigins("*").withSockJS() + registry.addEndpoint("/ws/user").addInterceptors(bkHandshake).setAllowedOriginPatterns("*").withSockJS() } @Override From 3c98c9cb415c8c6d15c73618908b85fc4f4f8355 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 24 Aug 2021 20:21:58 +0800 Subject: [PATCH 031/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release_for_k8s.yml | 190 ++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 .github/workflows/release_for_k8s.yml diff --git a/.github/workflows/release_for_k8s.yml b/.github/workflows/release_for_k8s.yml new file mode 100644 index 00000000000..2345cdd2d53 --- /dev/null +++ b/.github/workflows/release_for_k8s.yml @@ -0,0 +1,190 @@ +name: Tag Realse +on: + push: + tags: + - 'k*' + +jobs: + frontend: + name: Build frontend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v1 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - run: yarn install && yarn start && yarn public + working-directory: src/frontend + - uses: actions/upload-artifact@v1 + with: + name: frontend + path: src/frontend/frontend/ + + agent: + name: Build agent on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + fail-fast: true + max-parallel: 3 + steps: + - uses: actions/setup-go@v2 + with: + go-version: 1.12 + - uses: actions/checkout@v2 + - run: make clean build_linux + working-directory: src/agent/ + if: matrix.os == 'ubuntu-latest' + - run: make clean build_macos + working-directory: src/agent/ + if: matrix.os == 'macos-latest' + - run: build_windows.bat + shell: cmd + working-directory: src/agent/ + if: matrix.os == 'windows-latest' + - uses: actions/upload-artifact@v1 + with: + name: agent + path: src/agent/bin/ + + backend: + name: Build backend and release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: init mysql + run: | + sudo /etc/init.d/mysql start + export MYSQL_PWD=root + for i in *.sql;do echo $i;mysql -h localhost -uroot < $i;done + working-directory: support-files/sql + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Cache Gradle + uses: actions/cache@v1 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Gradle Build Backend Service + working-directory: src/backend/ci + run: ./gradlew clean test build :core:worker:worker-agent:shadowJar -Ddevops.assemblyMode=K8S -DmavenRepoUrl="https://maven.aliyun.com/nexus/content/groups/public/" + + - name: Create artifact - Step1:init + run: | + true # 暂无init需求, 保留此步骤. + + - name: Create artifact - Step2:get Agent + uses: actions/download-artifact@v1 + with: + name: agent + path: src/agent/bin/ + + - name: Create artifact - Step3:get Frontend + uses: actions/download-artifact@v1 + with: + name: frontend + path: src/frontend/frontend + + - name: Create artifact - Step4:make package + id: create-artifact + run: | + version="$(basename $GITHUB_REF)" + echo "::set-output name=version::$version" + ci_ms_wip="sign,monitoring" ci_pkg_dir=/dev/shm/ci ./scripts/packager-ci.sh "$version" bkci-slim.tar.gz + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: bk-ci ${{ github.ref }} + draft: true + prerelease: true + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./bkci-slim.tar.gz + asset_name: bkci-slim.tar.gz + asset_content_type: application/gzip + + - name: download codecc + uses: actions/download-artifact@v1 + with: + name: codecc + path: ./ + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./bkcodecc-slim.tar.gz + asset_name: bkcodecc-slim.tar.gz + asset_content_type: application/gzip + + codecc: + name: Build CodeCC + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: CodeCC Cache Gradle + uses: actions/cache@v1 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-codecc-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-codecc-gradle- + - name: Gradle Build + id: codecc-backend + uses: eskatos/gradle-command-action@v1 + with: + gradle-version: 4.6 + build-root-directory: src/backend/codecc + arguments: clean copyToRelease -DmavenRepoUrl="https://maven.aliyun.com/nexus/content/groups/public/" + + - name: frontend + id: codecc-frontend + run: | + cd src/frontend/devops-codecc + rm -rf dist + npm i + npm run build + if [ -f dist/index.html ]; then + mv dist/index.html dist/frontend#index.html + fi + + - name: Create artifact - make package + id: create-artifact + run: | + version="$(basename $GITHUB_REF)" + echo "::set-output name=version::$version" + codecc_pkg_dir=/dev/shm/codecc ./scripts/deploy-codecc/packager-codecc.sh "$version" bkcodecc-slim.tar.gz "$PWD" + + - uses: actions/upload-artifact@v1 + with: + name: codecc + path: bkcodecc-slim.tar.gz From 87500032598781114497b869339466f5e5a5459e Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 24 Aug 2021 21:27:26 +0800 Subject: [PATCH 032/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/ci/gradle.properties b/src/backend/ci/gradle.properties index 9a596aeb2d5..fb35c6f5f4a 100644 --- a/src/backend/ci/gradle.properties +++ b/src/backend/ci/gradle.properties @@ -43,3 +43,4 @@ org.gradle.daemon=true org.gradle.configureondemand=false org.gradle.parallel=true org.gradle.caching=true +org.gradle.jvmargs=-Xms512M -Xmx5120M From 06ea536ea84f9e72e643f9bb32f3a701ad54f029 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 25 Aug 2021 10:41:34 +0800 Subject: [PATCH 033/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/build.gradle.kts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/build.gradle.kts b/src/backend/ci/build.gradle.kts index 149b2da0fed..04a639af5cb 100644 --- a/src/backend/ci/build.gradle.kts +++ b/src/backend/ci/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tencent.devops.utils.findPropertyOrNull + plugins { id("com.tencent.devops.boot") detektCheck @@ -6,13 +8,20 @@ plugins { allprojects { apply(plugin = "com.tencent.devops.boot") - // 包路径 + project.findPropertyOrNull("mavenRepoUrl")?.let { + project.repositories { + removeAt(0) + addFirst(maven(it)) + } + } + +// 包路径 group = "com.tencent.bk.devops.ci" - // 版本 +// 版本 version = (System.getProperty("ci_version") ?: "1.6.0") + if (System.getProperty("snapshot") == "true") "-SNAPSHOT" else "-RELEASE" - // 版本管理 +// 版本管理 dependencyManagement { setApplyMavenExclusions(false) dependencies { @@ -73,11 +82,11 @@ allprojects { } } - // 兼容Junit4 +// 兼容Junit4 dependencies { testImplementation("org.junit.vintage:junit-vintage-engine") } - // 兼容 Log4j +// 兼容 Log4j configurations.forEach { it.exclude("org.springframework.boot", "spring-boot-starter-logging") it.exclude("org.springframework.boot", "spring-boot-starter-tomcat") From 36e2ef8a31dca9e52db62046acf920f3dde924ad Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 25 Aug 2021 15:16:58 +0800 Subject: [PATCH 034/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/core/common/common-service/build.gradle.kts | 2 +- src/backend/ci/core/common/common-web/build.gradle.kts | 7 ++++++- .../ci/core/repository/biz-repository/build.gradle.kts | 1 + src/backend/ci/core/worker/worker-api-sdk/build.gradle.kts | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/common/common-service/build.gradle.kts b/src/backend/ci/core/common/common-service/build.gradle.kts index 9e49df8b73c..dd16dc5c5e1 100644 --- a/src/backend/ci/core/common/common-service/build.gradle.kts +++ b/src/backend/ci/core/common/common-service/build.gradle.kts @@ -30,7 +30,7 @@ dependencies { api(project(":core:common:common-redis")) api("org.springframework.boot:spring-boot-starter-actuator") api("org.springframework.boot:spring-boot-starter-log4j2") - api("org.springframework.cloud:spring-cloud-starter-consul-discovery") + api("org.springframework.cloud:spring-cloud-consul-discovery") api("io.github.openfeign:feign-okhttp") api("org.jolokia:jolokia-core") api("javax.servlet:javax.servlet-api") diff --git a/src/backend/ci/core/common/common-web/build.gradle.kts b/src/backend/ci/core/common/common-web/build.gradle.kts index b71442baa5c..47b4b7be0d4 100644 --- a/src/backend/ci/core/common/common-web/build.gradle.kts +++ b/src/backend/ci/core/common/common-web/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tencent.devops.utils.findPropertyOrNull + /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * @@ -36,6 +38,9 @@ dependencies { api("io.swagger:swagger-jersey2-jaxrs") api("com.github.ulisesbocchio:jasypt-spring-boot-starter") api("org.springframework.boot:spring-boot-starter-amqp") - api("org.springframework.cloud:spring-cloud-starter-config") api("org.aspectj:aspectjweaver") + val assemblyMode = project.findPropertyOrNull("devops.assemblyMode") + if (assemblyMode == null || assemblyMode.toUpperCase() == "CONSUL") { + api("org.springframework.cloud:spring-cloud-starter-config") + } } diff --git a/src/backend/ci/core/repository/biz-repository/build.gradle.kts b/src/backend/ci/core/repository/biz-repository/build.gradle.kts index 8f93499e8fb..3dd62aad461 100644 --- a/src/backend/ci/core/repository/biz-repository/build.gradle.kts +++ b/src/backend/ci/core/repository/biz-repository/build.gradle.kts @@ -36,5 +36,6 @@ dependencies { api(project(":core:repository:api-repository")) api(project(":core:repository:model-repository")) api(project(":core:common:common-db")) + api("com.google.code.gson:gson") api("org.eclipse.jgit:org.eclipse.jgit") } diff --git a/src/backend/ci/core/worker/worker-api-sdk/build.gradle.kts b/src/backend/ci/core/worker/worker-api-sdk/build.gradle.kts index b60305ebbe8..8f6f111c481 100644 --- a/src/backend/ci/core/worker/worker-api-sdk/build.gradle.kts +++ b/src/backend/ci/core/worker/worker-api-sdk/build.gradle.kts @@ -26,6 +26,7 @@ */ dependencies { + api("com.google.code.gson:gson") api(project(":core:worker:worker-common")) api(project(":core:artifactory:api-artifactory-store")) } From b3ba2f6702a4600ed641ba109b1b26b65bf93e47 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 25 Aug 2021 16:51:16 +0800 Subject: [PATCH 035/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/auth/service/BkPermissionUrlService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkPermissionUrlService.kt b/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkPermissionUrlService.kt index a479109a5f9..fea60fb839e 100644 --- a/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkPermissionUrlService.kt +++ b/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkPermissionUrlService.kt @@ -43,7 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Service -@Service +@Service("permissionUrlService") class BkPermissionUrlService @Autowired constructor( val iamEsbService: IamEsbService, @Autowired(required = false) // v3 才会有 From c4221b44f8a4ba5b6f7e977d8e197a5bb42ff5d8 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Thu, 2 Sep 2021 18:13:36 +0800 Subject: [PATCH 036/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/auth/service/BkIamPermissionRoleExtService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkIamPermissionRoleExtService.kt b/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkIamPermissionRoleExtService.kt index 718bcbbe4f9..1c394fe50c9 100644 --- a/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkIamPermissionRoleExtService.kt +++ b/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkIamPermissionRoleExtService.kt @@ -38,8 +38,8 @@ import com.tencent.devops.auth.service.iam.PermissionGradeService import com.tencent.devops.auth.service.iam.impl.IamPermissionRoleExtService import com.tencent.devops.common.client.Client import org.jooq.DSLContext -import org.jvnet.hk2.annotations.Service import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Service @Service class BkIamPermissionRoleExtService @Autowired constructor( From 454c5b63bd5e0d75c6576d93ae6e2adcbb2bf996 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Thu, 2 Sep 2021 18:28:29 +0800 Subject: [PATCH 037/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/auth/service/BKPermissionGraderServiceImpl.kt | 2 +- .../tencent/devops/auth/service/BkPermissionRoleMemberImpl.kt | 2 +- .../ci/core/common/common-auth/common-auth-api/build.gradle.kts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BKPermissionGraderServiceImpl.kt b/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BKPermissionGraderServiceImpl.kt index b8735d913a6..c76e4dc6f38 100644 --- a/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BKPermissionGraderServiceImpl.kt +++ b/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BKPermissionGraderServiceImpl.kt @@ -30,7 +30,7 @@ package com.tencent.devops.auth.service import com.tencent.bk.sdk.iam.service.ManagerService import com.tencent.devops.auth.service.iam.impl.AbsPermissionGradeServiceImpl -import org.jvnet.hk2.annotations.Service +import org.springframework.stereotype.Service import org.springframework.beans.factory.annotation.Autowired @Service diff --git a/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkPermissionRoleMemberImpl.kt b/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkPermissionRoleMemberImpl.kt index 4ce9a158723..020b182dbe3 100644 --- a/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkPermissionRoleMemberImpl.kt +++ b/src/backend/ci/core/auth/biz-auth-blueking/src/main/kotlin/com/tencent/devops/auth/service/BkPermissionRoleMemberImpl.kt @@ -31,7 +31,7 @@ package com.tencent.devops.auth.service import com.tencent.bk.sdk.iam.service.ManagerService import com.tencent.devops.auth.service.iam.PermissionGradeService import com.tencent.devops.auth.service.iam.impl.AbsPermissionRoleMemberImpl -import org.jvnet.hk2.annotations.Service +import org.springframework.stereotype.Service import org.springframework.beans.factory.annotation.Autowired @Service diff --git a/src/backend/ci/core/common/common-auth/common-auth-api/build.gradle.kts b/src/backend/ci/core/common/common-auth/common-auth-api/build.gradle.kts index 096d7dfef8d..42c3edad109 100644 --- a/src/backend/ci/core/common/common-auth/common-auth-api/build.gradle.kts +++ b/src/backend/ci/core/common/common-auth/common-auth-api/build.gradle.kts @@ -35,6 +35,7 @@ dependencies { api("com.fasterxml.jackson.jaxrs:jackson-jaxrs-base") api("com.fasterxml.jackson.module:jackson-module-kotlin") api("org.apache.commons:commons-collections4") + api("org.apache.httpcomponents:httpclient") // implementation(group = "org.apache.commons", name = "commons-collections4", version = "4.4") api(fileTree(mapOf("dir" to "lib", "includes" to listOf("*.jar")))) From e3067d72c5bf8fbee2a2bd02413635b51f3e3c5e Mon Sep 17 00:00:00 2001 From: sawyersong2 Date: Fri, 3 Sep 2021 17:25:47 +0800 Subject: [PATCH 038/120] =?UTF-8?q?feat:=20openapi=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=9A=90=E8=97=8FchannelCode=E5=8F=82=E6=95=B0=20#5084?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/apigw/v3/ApigwBuildResourceV3.kt | 9 +-- .../api/apigw/v3/ApigwPipelineResourceV3.kt | 63 ++++++++++--------- .../apigw/v3/ApigwBuildResourceV3Impl.kt | 8 ++- .../apigw/v3/ApigwPipelineResourceV3Impl.kt | 47 +++++++------- .../devops/openapi/utils/ChannelUtils.kt | 40 ++++++++++++ 5 files changed, 106 insertions(+), 61 deletions(-) create mode 100644 src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ChannelUtils.kt diff --git a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt index dfa3a4003e3..809a3ab18ce 100644 --- a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt +++ b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt @@ -30,6 +30,7 @@ import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_APP_CODE import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_APP_CODE_DEFAULT_VALUE import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE +import com.tencent.devops.common.api.auth.AUTH_HEADER_GATEWAY_TAG import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID_DEFAULT_VALUE import com.tencent.devops.common.api.pojo.BuildHistoryPage @@ -248,6 +249,9 @@ interface ApigwBuildResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, + @ApiParam(value = "网关路由tag", required = true) + @HeaderParam(AUTH_HEADER_GATEWAY_TAG) + gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -256,10 +260,7 @@ interface ApigwBuildResourceV3 { pipelineId: String, @ApiParam("构建ID", required = true) @PathParam("buildId") - buildId: String, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + buildId: String ): Result @ApiOperation("手动审核启动阶段") diff --git a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt index 663a08ad003..6750509e3de 100644 --- a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt +++ b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt @@ -30,6 +30,7 @@ import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_APP_CODE import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_APP_CODE_DEFAULT_VALUE import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE +import com.tencent.devops.common.api.auth.AUTH_HEADER_GATEWAY_TAG import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID_DEFAULT_VALUE import com.tencent.devops.common.api.pojo.Page @@ -81,14 +82,14 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, + @ApiParam(value = "网关路由tag", required = true) + @HeaderParam(AUTH_HEADER_GATEWAY_TAG) + gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @ApiParam(value = "流水线模型", required = true) - pipeline: Model, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + pipeline: Model ): Result @Deprecated("Replace with editPipeline") @@ -105,6 +106,9 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, + @ApiParam(value = "网关路由tag", required = true) + @HeaderParam(AUTH_HEADER_GATEWAY_TAG) + gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -112,10 +116,7 @@ interface ApigwPipelineResourceV3 { @PathParam("pipelineId") pipelineId: String, @ApiParam(value = "流水线模型", required = true) - pipeline: Model, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + pipeline: Model ): Result @ApiOperation("导入新流水线, 包含流水线编排和设置") @@ -131,15 +132,15 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, + @ApiParam(value = "网关路由tag", required = true) + @HeaderParam(AUTH_HEADER_GATEWAY_TAG) + gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @ApiParam(value = "流水线模型与设置", required = true) @Valid - modelAndSetting: PipelineModelAndSetting, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + modelAndSetting: PipelineModelAndSetting ): Result @ApiOperation("更新流水线编排和设置") @@ -155,6 +156,9 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, + @ApiParam(value = "网关路由tag", required = true) + @HeaderParam(AUTH_HEADER_GATEWAY_TAG) + gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -163,10 +167,7 @@ interface ApigwPipelineResourceV3 { pipelineId: String, @ApiParam(value = "流水线模型与设置", required = true) @Valid - modelAndSetting: PipelineModelAndSetting, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + modelAndSetting: PipelineModelAndSetting ): Result @ApiOperation("获取流水线编排") @@ -182,15 +183,15 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, + @ApiParam(value = "网关路由tag", required = true) + @HeaderParam(AUTH_HEADER_GATEWAY_TAG) + gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @ApiParam("流水线ID", required = true) @PathParam("pipelineId") - pipelineId: String, - @ApiParam("channel", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + pipelineId: String ): Result @ApiOperation("批量获取流水线编排与配置") @@ -206,12 +207,12 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, + @ApiParam(value = "网关路由tag", required = true) + @HeaderParam(AUTH_HEADER_GATEWAY_TAG) + gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, - @ApiParam("channel", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS, @ApiParam("流水线ID列表", required = true) pipelineIds: List ): Result> @@ -246,15 +247,15 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, + @ApiParam(value = "网关路由tag", required = true) + @HeaderParam(AUTH_HEADER_GATEWAY_TAG) + gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @ApiParam("流水线ID", required = true) @PathParam("pipelineId") - pipelineId: String, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + pipelineId: String ): Result @ApiOperation("获取项目的流水线列表") @@ -270,6 +271,9 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, + @ApiParam(value = "网关路由tag", required = true) + @HeaderParam(AUTH_HEADER_GATEWAY_TAG) + gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -278,10 +282,7 @@ interface ApigwPipelineResourceV3 { page: Int? = null, @ApiParam("每页多少条", required = false, defaultValue = "20") @QueryParam("pageSize") - pageSize: Int? = null, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + pageSize: Int? = null ): Result> @ApiOperation("获取流水线状态") diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt index 99dbef8c5d8..11bba6eb95a 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt @@ -33,6 +33,8 @@ import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.common.pipeline.pojo.StageReviewRequest import com.tencent.devops.common.web.RestResource import com.tencent.devops.openapi.api.apigw.v3.ApigwBuildResourceV3 +import com.tencent.devops.openapi.utils.ApiGatewayUtil +import com.tencent.devops.openapi.utils.ChannelUtils import com.tencent.devops.process.api.service.ServiceBuildResource import com.tencent.devops.process.pojo.BuildHistory import com.tencent.devops.process.pojo.BuildHistoryWithVars @@ -68,10 +70,10 @@ class ApigwBuildResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, + gatewayTag: String, projectId: String, pipelineId: String, - buildId: String, - channelCode: ChannelCode? + buildId: String ): Result { logger.info("$buildId|DETAIL|user($userId)") return client.get(ServiceBuildResource::class).getBuildDetail( @@ -79,7 +81,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( projectId = projectId, pipelineId = pipelineId, buildId = buildId, - channelCode = channelCode ?: ChannelCode.BS + channelCode = ChannelUtils.getChannelCode(gatewayTag) ) } diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt index 5253fe2b2cf..ad9aeb296aa 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt @@ -33,6 +33,7 @@ import com.tencent.devops.common.pipeline.Model import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.common.web.RestResource import com.tencent.devops.openapi.api.apigw.v3.ApigwPipelineResourceV3 +import com.tencent.devops.openapi.utils.ChannelUtils import com.tencent.devops.process.api.service.ServicePipelineResource import com.tencent.devops.process.pojo.Pipeline import com.tencent.devops.process.pojo.PipelineCopy @@ -69,16 +70,16 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, + gatewayTag: String, projectId: String, - pipeline: Model, - channelCode: ChannelCode? + pipeline: Model ): Result { logger.info("Create pipeline at project:$projectId") return client.get(ServicePipelineResource::class).create( userId = userId, projectId = projectId, pipeline = pipeline, - channelCode = channelCode ?: ChannelCode.BS + channelCode = ChannelUtils.getChannelCode(gatewayTag) ) } @@ -86,10 +87,10 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, + gatewayTag: String, projectId: String, pipelineId: String, - pipeline: Model, - channelCode: ChannelCode? + pipeline: Model ): Result { logger.info("Edit a pipeline at project:$projectId, pipelineId:$pipelineId") return client.get(ServicePipelineResource::class).edit( @@ -97,7 +98,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( projectId = projectId, pipelineId = pipelineId, pipeline = pipeline, - channelCode = channelCode ?: ChannelCode.BS + channelCode = ChannelUtils.getChannelCode(gatewayTag) ) } @@ -105,10 +106,10 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, + gatewayTag: String, projectId: String, pipelineId: String, - modelAndSetting: PipelineModelAndSetting, - channelCode: ChannelCode? + modelAndSetting: PipelineModelAndSetting ): Result { logger.info("updatePipeline|project:$projectId|userId:$userId|pipelineId:$pipelineId") return client.get(ServicePipelineResource::class).updatePipeline( @@ -116,7 +117,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( projectId = projectId, pipelineId = pipelineId, modelAndSetting = modelAndSetting, - channelCode = channelCode ?: ChannelCode.BS + channelCode = ChannelUtils.getChannelCode(gatewayTag) ) } @@ -124,16 +125,16 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, + gatewayTag: String, projectId: String, - modelAndSetting: PipelineModelAndSetting, - channelCode: ChannelCode? + modelAndSetting: PipelineModelAndSetting ): Result { logger.info("uploadPipeline|project:$projectId|userId:$userId") return client.get(ServicePipelineResource::class).uploadPipeline( userId = userId, projectId = projectId, modelAndSetting = modelAndSetting, - channelCode = channelCode ?: ChannelCode.BS + channelCode = ChannelUtils.getChannelCode(gatewayTag) ) } @@ -141,16 +142,16 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, + gatewayTag: String, projectId: String, - pipelineId: String, - channelCode: ChannelCode? + pipelineId: String ): Result { logger.info("Get a pipeline at project:$projectId, pipelineId:$pipelineId") return client.get(ServicePipelineResource::class).getWithPermission( userId = userId, projectId = projectId, pipelineId = pipelineId, - channelCode = channelCode ?: ChannelCode.BS, + channelCode = ChannelUtils.getChannelCode(gatewayTag), checkPermission = true ) } @@ -159,8 +160,8 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, + gatewayTag: String, projectId: String, - channelCode: ChannelCode?, pipelineIds: List ): Result> { logger.info("Get batch pipelines at project:$projectId, pipelineIds:$pipelineIds") @@ -168,7 +169,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( userId = userId, projectId = projectId, pipelineIds = pipelineIds, - channelCode = channelCode ?: ChannelCode.BS + channelCode = ChannelUtils.getChannelCode(gatewayTag) ) } @@ -176,16 +177,16 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, + gatewayTag: String, projectId: String, - pipelineId: String, - channelCode: ChannelCode? + pipelineId: String ): Result { logger.info("Delete a pipeline at project:$projectId, pipelineId:$pipelineId") return client.get(ServicePipelineResource::class).delete( userId = userId, projectId = projectId, pipelineId = pipelineId, - channelCode = channelCode ?: ChannelCode.BS + channelCode = ChannelUtils.getChannelCode(gatewayTag) ) } @@ -208,10 +209,10 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, + gatewayTag: String, projectId: String, page: Int?, - pageSize: Int?, - channelCode: ChannelCode? + pageSize: Int? ): Result> { logger.info("get pipelines by user, userId:$userId") return client.get(ServicePipelineResource::class).list( @@ -219,7 +220,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( projectId = projectId, page = page, pageSize = pageSize, - channelCode = channelCode ?: ChannelCode.BS, + channelCode = ChannelUtils.getChannelCode(gatewayTag), checkPermission = true ) } diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ChannelUtils.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ChannelUtils.kt new file mode 100644 index 00000000000..e6a819d316b --- /dev/null +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ChannelUtils.kt @@ -0,0 +1,40 @@ +/* + * 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.openapi.utils + +import com.tencent.devops.common.pipeline.enums.ChannelCode + +object ChannelUtils { + fun getChannelCode(gatewayTag: String): ChannelCode { + return if (gatewayTag.contains("stream") or gatewayTag.contains("gitci")) { + ChannelCode.GIT + } else { + ChannelCode.BS + } + } +} From 83a182f79ba9ebc24ec4d5536a5342a3f4b9098a Mon Sep 17 00:00:00 2001 From: sawyersong2 Date: Sat, 4 Sep 2021 15:10:11 +0800 Subject: [PATCH 039/120] =?UTF-8?q?feat:=20openapi=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=9A=90=E8=97=8FchannelCode=E5=8F=82=E6=95=B0=20#5084?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apigw/v3/ApigwBuildResourceV3Impl.kt | 6 ++--- .../apigw/v3/ApigwPipelineResourceV3Impl.kt | 22 +++++++++---------- .../devops/openapi/utils/ApiGatewayUtil.kt | 12 ++++++++++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt index 11bba6eb95a..6bcd91aeb8d 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt @@ -34,7 +34,6 @@ import com.tencent.devops.common.pipeline.pojo.StageReviewRequest import com.tencent.devops.common.web.RestResource import com.tencent.devops.openapi.api.apigw.v3.ApigwBuildResourceV3 import com.tencent.devops.openapi.utils.ApiGatewayUtil -import com.tencent.devops.openapi.utils.ChannelUtils import com.tencent.devops.process.api.service.ServiceBuildResource import com.tencent.devops.process.pojo.BuildHistory import com.tencent.devops.process.pojo.BuildHistoryWithVars @@ -47,7 +46,8 @@ import org.springframework.beans.factory.annotation.Autowired @RestResource class ApigwBuildResourceV3Impl @Autowired constructor( - private val client: Client + private val client: Client, + private val apiGatewayUtil: ApiGatewayUtil ) : ApigwBuildResourceV3 { override fun manualStartupInfo( appCode: String?, @@ -81,7 +81,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( projectId = projectId, pipelineId = pipelineId, buildId = buildId, - channelCode = ChannelUtils.getChannelCode(gatewayTag) + channelCode = apiGatewayUtil.getChannelCode() ) } diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt index ad9aeb296aa..04e0b53d643 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt @@ -30,10 +30,9 @@ import com.tencent.devops.common.api.pojo.Page import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.client.Client import com.tencent.devops.common.pipeline.Model -import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.common.web.RestResource import com.tencent.devops.openapi.api.apigw.v3.ApigwPipelineResourceV3 -import com.tencent.devops.openapi.utils.ChannelUtils +import com.tencent.devops.openapi.utils.ApiGatewayUtil import com.tencent.devops.process.api.service.ServicePipelineResource import com.tencent.devops.process.pojo.Pipeline import com.tencent.devops.process.pojo.PipelineCopy @@ -48,7 +47,8 @@ import org.springframework.beans.factory.annotation.Autowired @RestResource class ApigwPipelineResourceV3Impl @Autowired constructor( - private val client: Client + private val client: Client, + private val apiGatewayUtil: ApiGatewayUtil ) : ApigwPipelineResourceV3 { override fun status( @@ -79,7 +79,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( userId = userId, projectId = projectId, pipeline = pipeline, - channelCode = ChannelUtils.getChannelCode(gatewayTag) + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -98,7 +98,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( projectId = projectId, pipelineId = pipelineId, pipeline = pipeline, - channelCode = ChannelUtils.getChannelCode(gatewayTag) + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -117,7 +117,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( projectId = projectId, pipelineId = pipelineId, modelAndSetting = modelAndSetting, - channelCode = ChannelUtils.getChannelCode(gatewayTag) + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -134,7 +134,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( userId = userId, projectId = projectId, modelAndSetting = modelAndSetting, - channelCode = ChannelUtils.getChannelCode(gatewayTag) + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -151,7 +151,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( userId = userId, projectId = projectId, pipelineId = pipelineId, - channelCode = ChannelUtils.getChannelCode(gatewayTag), + channelCode = apiGatewayUtil.getChannelCode(), checkPermission = true ) } @@ -169,7 +169,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( userId = userId, projectId = projectId, pipelineIds = pipelineIds, - channelCode = ChannelUtils.getChannelCode(gatewayTag) + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -186,7 +186,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( userId = userId, projectId = projectId, pipelineId = pipelineId, - channelCode = ChannelUtils.getChannelCode(gatewayTag) + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -220,7 +220,7 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( projectId = projectId, page = page, pageSize = pageSize, - channelCode = ChannelUtils.getChannelCode(gatewayTag), + channelCode = apiGatewayUtil.getChannelCode(), checkPermission = true ) } diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt index 9f08a70bc2f..cff2f6175d5 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt @@ -26,6 +26,7 @@ */ package com.tencent.devops.openapi.utils +import com.tencent.devops.common.pipeline.enums.ChannelCode import org.springframework.beans.factory.annotation.Value import org.springframework.cloud.context.config.annotation.RefreshScope import org.springframework.stereotype.Component @@ -37,5 +38,16 @@ class ApiGatewayUtil { @Value("\${api.gateway.auth:#{false}}") private val apiGatewayAuth: Boolean = false + @Value("\${spring.cloud.consul.discovery.tag:prod}") + private val consulTag: String = "prod" + fun isAuth() = apiGatewayAuth + + fun getChannelCode(): ChannelCode { + return if (consulTag.contains("stream") or consulTag.contains("gitci")) { + ChannelCode.GIT + } else { + ChannelCode.BS + } + } } From 2ec7ea1cc20ab94c813979551dd047f342e55b33 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Sun, 5 Sep 2021 21:59:25 +0800 Subject: [PATCH 040/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/service/PipelineStageService.kt | 1 - .../stage/impl/CheckPauseReviewStageCmd.kt | 13 +++-- .../stage/impl/StartContainerStageCmd.kt | 1 - .../impl/UpdateStateForStageCmdFinally.kt | 48 ++++++++++++++++++- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt index a6e60517fcf..fd5bfcb00d2 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt @@ -178,7 +178,6 @@ class PipelineStageService @Autowired constructor( fun pauseStage(buildStage: PipelineBuildStage) { with(buildStage) { - // TODO 暂时只处理准入逻辑,后续和checkOut保持逻辑一致 checkIn?.status = BuildStatus.REVIEWING.name val allStageStatus = stageBuildDetailService.stagePause( buildId = buildId, diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index ac7405cc0ab..793b7e81919 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -75,10 +75,9 @@ class CheckPauseReviewStageCmd( } else if (commandContext.buildStatus.isReadyToRun()) { // 质量红线 - if (checkQualityFailed(event, stage, commandContext.variables)) { + if (checkInQualityFailed(event, stage, commandContext.variables)) { // #4732 优先判断是否能通过质量红线检查 - LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_FAILED|${event.stageId}") - // TODO 暂时只处理准入,后续需要兼容准出 + LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_FAILED|${event.stageId}") commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_FAIL.name commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL commandContext.latestSummary = "s(${stage.stageId}) failed with QUALITY_CHECK_IN" @@ -137,7 +136,7 @@ class CheckPauseReviewStageCmd( } } - private fun checkQualityFailed( + private fun checkInQualityFailed( event: PipelineBuildStageEvent, stage: PipelineBuildStage, variables: Map @@ -154,15 +153,15 @@ class CheckPauseReviewStageCmd( ruleBuildIds = stage.checkIn?.ruleIds!!.toSet(), runtimeVariable = variables ) - LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_REQUEST|${event.stageId}|" + + LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_REQUEST|${event.stageId}|" + "request=$request|ruleIds=${stage.checkIn?.ruleIds}") val result = client.get(ServiceQualityRuleResource::class).check(request).data!! - LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_RESPONSE|${event.stageId}|" + + LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_RESPONSE|${event.stageId}|" + "response=$result|ruleIds=${stage.checkIn?.ruleIds}") stage.checkIn!!.checkTimes = result.checkTimes !result.success } catch (ignore: Throwable) { - LOG.error("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_ERROR|${event.stageId}", ignore) + LOG.error("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_OUT_ERROR|${event.stageId}", ignore) true } } diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/StartContainerStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/StartContainerStageCmd.kt index 0ba7d51df77..765a84cf414 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/StartContainerStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/StartContainerStageCmd.kt @@ -64,7 +64,6 @@ class StartContainerStageCmd( // 执行成功则结束本次事件处理,否则要尝试下一stage judgeStageContainer(commandContext) commandContext.latestSummary = "from_s(${commandContext.stage.stageId})" -// } commandContext.cmdFlowState = CmdFlowState.FINALLY } diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index f9d71dd74e9..55f24966c38 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -27,6 +27,7 @@ package com.tencent.devops.process.engine.control.command.stage.impl +import com.tencent.devops.common.client.Client import com.tencent.devops.common.event.dispatcher.pipeline.PipelineEventDispatcher import com.tencent.devops.common.event.enums.ActionType import com.tencent.devops.common.event.pojo.pipeline.PipelineBuildStatusBroadCastEvent @@ -43,6 +44,9 @@ import com.tencent.devops.process.engine.pojo.event.PipelineBuildStageEvent import com.tencent.devops.process.engine.service.PipelineRuntimeService import com.tencent.devops.process.engine.service.PipelineStageService import com.tencent.devops.process.engine.service.detail.StageBuildDetailService +import com.tencent.devops.quality.api.v2.pojo.ControlPointPosition +import com.tencent.devops.quality.api.v3.ServiceQualityRuleResource +import com.tencent.devops.quality.api.v3.pojo.request.BuildCheckParamsV3 import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import java.time.LocalDateTime @@ -56,7 +60,8 @@ class UpdateStateForStageCmdFinally( private val pipelineRuntimeService: PipelineRuntimeService, private val stageBuildDetailService: StageBuildDetailService, private val pipelineEventDispatcher: PipelineEventDispatcher, - private val buildLogPrinter: BuildLogPrinter + private val buildLogPrinter: BuildLogPrinter, + private val client: Client ) : StageCmd { override fun canExecute(commandContext: StageContext): Boolean { @@ -130,7 +135,16 @@ class UpdateStateForStageCmdFinally( nextStage = pipelineStageService.getNextStage(buildId = event.buildId, currentStageSeq = stage.seq) } - if (nextStage != null) { + // #5019 在结束阶段做stage准出判断 + if (checkOutQualityFailed(event, stage, commandContext.variables)) { + + commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_FAIL.name + commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL + commandContext.latestSummary = "s(${stage.stageId}) failed with QUALITY_CHECK_OUT" + + return finishBuild(commandContext = commandContext) + + } else if (nextStage != null) { LOG.info("ENGINE|${event.buildId}|${event.source}|NEXT_STAGE|${event.stageId}|gotoFinal=$gotoFinal|" + "next_s(${nextStage.stageId})|e=${stage.executeCount}|summary=${commandContext.latestSummary}") event.sendNextStage(source = "From_s(${stage.stageId})", stageId = nextStage.stageId) @@ -260,6 +274,36 @@ class UpdateStateForStageCmdFinally( ) } + private fun checkOutQualityFailed( + event: PipelineBuildStageEvent, + stage: PipelineBuildStage, + variables: Map + ): Boolean { + if (stage.checkOut?.ruleIds.isNullOrEmpty()) return false + return try { + val request = BuildCheckParamsV3( + projectId = event.projectId, + pipelineId = event.pipelineId, + buildId = event.buildId, + position = ControlPointPosition.AFTER_POSITION, + templateId = null, + interceptName = null, + ruleBuildIds = stage.checkOut?.ruleIds!!.toSet(), + runtimeVariable = variables + ) + LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_OUT_REQUEST|${event.stageId}|" + + "request=$request|ruleIds=${stage.checkOut?.ruleIds}") + val result = client.get(ServiceQualityRuleResource::class).check(request).data!! + LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_OUT_RESPONSE|${event.stageId}|" + + "response=$result|ruleIds=${stage.checkOut?.ruleIds}") + stage.checkOut!!.checkTimes = result.checkTimes + !result.success + } catch (ignore: Throwable) { + LOG.error("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_OUT_ERROR|${event.stageId}", ignore) + true + } + } + companion object { private val LOG = LoggerFactory.getLogger(UpdateStateForStageCmdFinally::class.java) } From 5e84bbafe560009d903fd9ec9cbebb369b9c5e20 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Sun, 5 Sep 2021 23:04:31 +0800 Subject: [PATCH 041/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/service/PipelineStageService.kt | 51 ++++++++++++++++++- .../stage/impl/CheckPauseReviewStageCmd.kt | 39 +------------- .../impl/UpdateStateForStageCmdFinally.kt | 39 +------------- 3 files changed, 54 insertions(+), 75 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt index fd5bfcb00d2..8aca88ffa6a 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt @@ -28,6 +28,7 @@ package com.tencent.devops.process.engine.service import com.tencent.devops.common.api.util.DateTimeUtil +import com.tencent.devops.common.client.Client import com.tencent.devops.common.event.dispatcher.pipeline.PipelineEventDispatcher import com.tencent.devops.common.event.enums.ActionType import com.tencent.devops.common.pipeline.Model @@ -50,6 +51,9 @@ import com.tencent.devops.process.pojo.PipelineNotifyTemplateEnum import com.tencent.devops.process.service.BuildVariableService import com.tencent.devops.process.utils.PIPELINE_BUILD_NUM import com.tencent.devops.process.utils.PIPELINE_NAME +import com.tencent.devops.quality.api.v2.pojo.ControlPointPosition +import com.tencent.devops.quality.api.v3.ServiceQualityRuleResource +import com.tencent.devops.quality.api.v3.pojo.request.BuildCheckParamsV3 import org.jooq.DSLContext import org.jooq.impl.DSL import org.slf4j.LoggerFactory @@ -70,7 +74,8 @@ class PipelineStageService @Autowired constructor( private val pipelineBuildSummaryDao: PipelineBuildSummaryDao, private val pipelineBuildStageDao: PipelineBuildStageDao, private val buildVariableService: BuildVariableService, - private val stageBuildDetailService: StageBuildDetailService + private val stageBuildDetailService: StageBuildDetailService, + private val client: Client ) { companion object { private val logger = LoggerFactory.getLogger(PipelineStageService::class.java) @@ -375,6 +380,50 @@ class PipelineStageService @Autowired constructor( ) } + /** + * @param event 流水线引擎Stage事件 + * @param stage 该Stage的当前配置属性 + * @param variables 上下文中的环境变量 + * @param inOrOut 准入为true,准出为false + * @return 是否通过红线检查 + */ + fun checkQualityPassed( + event: PipelineBuildStageEvent, + stage: PipelineBuildStage, + variables: Map, + inOrOut: Boolean + ): Boolean { + val (check, position) = if (inOrOut) { + Pair(stage.checkIn, ControlPointPosition.BEFORE_POSITION) + } else { + Pair(stage.checkOut, ControlPointPosition.AFTER_POSITION) + } + if (check?.ruleIds.isNullOrEmpty()) return false + return try { + val request = BuildCheckParamsV3( + projectId = event.projectId, + pipelineId = event.pipelineId, + buildId = event.buildId, + position = position, + templateId = null, + interceptName = null, + ruleBuildIds = stage.checkIn?.ruleIds!!.toSet(), + runtimeVariable = variables + ) + logger.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_REQUEST|${event.stageId}|" + + "inOrOut=$inOrOut|request=$request|ruleIds=${stage.checkIn?.ruleIds}") + val result = client.get(ServiceQualityRuleResource::class).check(request).data!! + logger.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_RESPONSE|${event.stageId}|" + + "inOrOut=$inOrOut|response=$result|ruleIds=${stage.checkIn?.ruleIds}") + stage.checkIn!!.checkTimes = result.checkTimes + result.success + } catch (ignore: Throwable) { + logger.error("ENGINE|${event.buildId}|${event.source}|inOrOut=$inOrOut|" + + "STAGE_QUALITY_CHECK_OUT_ERROR|${event.stageId}", ignore) + true + } + } + fun retryRefreshStage(model: Model) { model.stages.forEach { stage -> stage.checkIn?.retryRefresh() diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index 793b7e81919..3920b41f595 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -28,7 +28,6 @@ package com.tencent.devops.process.engine.control.command.stage.impl import com.tencent.devops.common.api.util.EnvUtils -import com.tencent.devops.common.client.Client import com.tencent.devops.common.pipeline.enums.BuildStatus import com.tencent.devops.process.engine.common.BS_MANUAL_START_STAGE import com.tencent.devops.process.engine.control.command.CmdFlowState @@ -40,9 +39,6 @@ import com.tencent.devops.process.engine.service.PipelineStageService import com.tencent.devops.process.service.BuildVariableService import com.tencent.devops.process.utils.PIPELINE_BUILD_NUM import com.tencent.devops.process.utils.PIPELINE_NAME -import com.tencent.devops.quality.api.v2.pojo.ControlPointPosition -import com.tencent.devops.quality.api.v3.ServiceQualityRuleResource -import com.tencent.devops.quality.api.v3.pojo.request.BuildCheckParamsV3 import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -52,8 +48,7 @@ import org.springframework.stereotype.Service @Service class CheckPauseReviewStageCmd( private val buildVariableService: BuildVariableService, - private val pipelineStageService: PipelineStageService, - private val client: Client + private val pipelineStageService: PipelineStageService ) : StageCmd { override fun canExecute(commandContext: StageContext): Boolean { @@ -75,7 +70,7 @@ class CheckPauseReviewStageCmd( } else if (commandContext.buildStatus.isReadyToRun()) { // 质量红线 - if (checkInQualityFailed(event, stage, commandContext.variables)) { + if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { // #4732 优先判断是否能通过质量红线检查 LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_FAILED|${event.stageId}") commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_FAIL.name @@ -136,36 +131,6 @@ class CheckPauseReviewStageCmd( } } - private fun checkInQualityFailed( - event: PipelineBuildStageEvent, - stage: PipelineBuildStage, - variables: Map - ): Boolean { - if (stage.checkIn?.ruleIds.isNullOrEmpty()) return false - return try { - val request = BuildCheckParamsV3( - projectId = event.projectId, - pipelineId = event.pipelineId, - buildId = event.buildId, - position = ControlPointPosition.BEFORE_POSITION, - templateId = null, - interceptName = null, - ruleBuildIds = stage.checkIn?.ruleIds!!.toSet(), - runtimeVariable = variables - ) - LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_REQUEST|${event.stageId}|" + - "request=$request|ruleIds=${stage.checkIn?.ruleIds}") - val result = client.get(ServiceQualityRuleResource::class).check(request).data!! - LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_RESPONSE|${event.stageId}|" + - "response=$result|ruleIds=${stage.checkIn?.ruleIds}") - stage.checkIn!!.checkTimes = result.checkTimes - !result.success - } catch (ignore: Throwable) { - LOG.error("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_OUT_ERROR|${event.stageId}", ignore) - true - } - } - private fun needPause(event: PipelineBuildStageEvent, stage: PipelineBuildStage): Boolean { // #115 只有在非手动触发该Stage的首次运行做审核暂停 if (event.source == BS_MANUAL_START_STAGE || stage.checkIn?.manualTrigger != true) { diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index 55f24966c38..dfddb4b2072 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -27,7 +27,6 @@ package com.tencent.devops.process.engine.control.command.stage.impl -import com.tencent.devops.common.client.Client import com.tencent.devops.common.event.dispatcher.pipeline.PipelineEventDispatcher import com.tencent.devops.common.event.enums.ActionType import com.tencent.devops.common.event.pojo.pipeline.PipelineBuildStatusBroadCastEvent @@ -44,9 +43,6 @@ import com.tencent.devops.process.engine.pojo.event.PipelineBuildStageEvent import com.tencent.devops.process.engine.service.PipelineRuntimeService import com.tencent.devops.process.engine.service.PipelineStageService import com.tencent.devops.process.engine.service.detail.StageBuildDetailService -import com.tencent.devops.quality.api.v2.pojo.ControlPointPosition -import com.tencent.devops.quality.api.v3.ServiceQualityRuleResource -import com.tencent.devops.quality.api.v3.pojo.request.BuildCheckParamsV3 import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import java.time.LocalDateTime @@ -60,8 +56,7 @@ class UpdateStateForStageCmdFinally( private val pipelineRuntimeService: PipelineRuntimeService, private val stageBuildDetailService: StageBuildDetailService, private val pipelineEventDispatcher: PipelineEventDispatcher, - private val buildLogPrinter: BuildLogPrinter, - private val client: Client + private val buildLogPrinter: BuildLogPrinter ) : StageCmd { override fun canExecute(commandContext: StageContext): Boolean { @@ -136,7 +131,7 @@ class UpdateStateForStageCmdFinally( } // #5019 在结束阶段做stage准出判断 - if (checkOutQualityFailed(event, stage, commandContext.variables)) { + if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_FAIL.name commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL @@ -274,36 +269,6 @@ class UpdateStateForStageCmdFinally( ) } - private fun checkOutQualityFailed( - event: PipelineBuildStageEvent, - stage: PipelineBuildStage, - variables: Map - ): Boolean { - if (stage.checkOut?.ruleIds.isNullOrEmpty()) return false - return try { - val request = BuildCheckParamsV3( - projectId = event.projectId, - pipelineId = event.pipelineId, - buildId = event.buildId, - position = ControlPointPosition.AFTER_POSITION, - templateId = null, - interceptName = null, - ruleBuildIds = stage.checkOut?.ruleIds!!.toSet(), - runtimeVariable = variables - ) - LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_OUT_REQUEST|${event.stageId}|" + - "request=$request|ruleIds=${stage.checkOut?.ruleIds}") - val result = client.get(ServiceQualityRuleResource::class).check(request).data!! - LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_OUT_RESPONSE|${event.stageId}|" + - "response=$result|ruleIds=${stage.checkOut?.ruleIds}") - stage.checkOut!!.checkTimes = result.checkTimes - !result.success - } catch (ignore: Throwable) { - LOG.error("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_OUT_ERROR|${event.stageId}", ignore) - true - } - } - companion object { private val LOG = LoggerFactory.getLogger(UpdateStateForStageCmdFinally::class.java) } From f0fabf228f8f43139a4cb82130f1ac1411b9ac54 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Sun, 5 Sep 2021 23:07:47 +0800 Subject: [PATCH 042/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/command/stage/impl/UpdateStateForStageCmdFinally.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index dfddb4b2072..7caead331db 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -138,7 +138,6 @@ class UpdateStateForStageCmdFinally( commandContext.latestSummary = "s(${stage.stageId}) failed with QUALITY_CHECK_OUT" return finishBuild(commandContext = commandContext) - } else if (nextStage != null) { LOG.info("ENGINE|${event.buildId}|${event.source}|NEXT_STAGE|${event.stageId}|gotoFinal=$gotoFinal|" + "next_s(${nextStage.stageId})|e=${stage.executeCount}|summary=${commandContext.latestSummary}") From 2962c574298eb34c9570046661fea9910c1ff01c Mon Sep 17 00:00:00 2001 From: sawyersong2 Date: Mon, 6 Sep 2021 12:31:02 +0800 Subject: [PATCH 043/120] =?UTF-8?q?feat:=20openapi=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=9A=90=E8=97=8FchannelCode=E5=8F=82=E6=95=B0=20#5084?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/apigw/v3/ApigwBuildResourceV3.kt | 33 +++------------ .../api/apigw/v3/ApigwPipelineResourceV3.kt | 1 - .../apigw/v3/ApigwBuildResourceV3Impl.kt | 32 ++++++--------- .../devops/openapi/utils/ChannelUtils.kt | 40 ------------------- 4 files changed, 18 insertions(+), 88 deletions(-) delete mode 100644 src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ChannelUtils.kt diff --git a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt index 809a3ab18ce..eaa549ba145 100644 --- a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt +++ b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt @@ -86,10 +86,7 @@ interface ApigwBuildResourceV3 { values: Map, @ApiParam("手动指定构建版本参数", required = false) @QueryParam("buildNo") - buildNo: Int? = null, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + buildNo: Int? = null ): Result @ApiOperation("停止构建") @@ -113,10 +110,7 @@ interface ApigwBuildResourceV3 { pipelineId: String, @ApiParam("构建ID", required = true) @PathParam("buildId") - buildId: String, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + buildId: String ): Result @ApiOperation("重试构建-重试或者跳过失败插件") @@ -149,10 +143,7 @@ interface ApigwBuildResourceV3 { failedContainer: Boolean? = false, @ApiParam("跳过失败插件,为true时需要传taskId值(值为stageId则表示跳过Stage下所有失败插件)", required = false) @QueryParam("skip") - skipFailedTask: Boolean? = false, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + skipFailedTask: Boolean? = false ): Result @ApiOperation("查看构建状态信息,#4295增加stageStatus等") @@ -176,10 +167,7 @@ interface ApigwBuildResourceV3 { pipelineId: String, @ApiParam("构建ID", required = true) @PathParam("buildId") - buildId: String, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + buildId: String ): Result @ApiOperation("获取流水线构建历史") @@ -206,10 +194,7 @@ interface ApigwBuildResourceV3 { page: Int?, @ApiParam("每页多少条", required = false, defaultValue = "20") @QueryParam("pageSize") - pageSize: Int?, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + pageSize: Int? ): Result> @ApiOperation("获取流水线手动启动参数") @@ -230,10 +215,7 @@ interface ApigwBuildResourceV3 { projectId: String, @ApiParam("流水线ID", required = true) @PathParam("pipelineId") - pipelineId: String, - @ApiParam("渠道号,默认为BS", required = false) - @QueryParam("channelCode") - channelCode: ChannelCode? = ChannelCode.BS + pipelineId: String ): Result @ApiOperation("构建详情") @@ -249,9 +231,6 @@ interface ApigwBuildResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, - @ApiParam(value = "网关路由tag", required = true) - @HeaderParam(AUTH_HEADER_GATEWAY_TAG) - gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, diff --git a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt index 6750509e3de..fac641218ad 100644 --- a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt +++ b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt @@ -36,7 +36,6 @@ import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID_DEFAULT_VALUE import com.tencent.devops.common.api.pojo.Page import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.pipeline.Model -import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.process.pojo.Pipeline import com.tencent.devops.process.pojo.PipelineCopy import com.tencent.devops.process.pojo.PipelineId diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt index 6bcd91aeb8d..57420c09867 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt @@ -29,7 +29,6 @@ package com.tencent.devops.openapi.resources.apigw.v3 import com.tencent.devops.common.api.pojo.BuildHistoryPage import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.client.Client -import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.common.pipeline.pojo.StageReviewRequest import com.tencent.devops.common.web.RestResource import com.tencent.devops.openapi.api.apigw.v3.ApigwBuildResourceV3 @@ -54,15 +53,14 @@ class ApigwBuildResourceV3Impl @Autowired constructor( apigwType: String?, userId: String, projectId: String, - pipelineId: String, - channelCode: ChannelCode? + pipelineId: String ): Result { logger.info("$pipelineId|manualStartupInfo|user($userId)") return client.get(ServiceBuildResource::class).manualStartupInfo( userId = userId, projectId = projectId, pipelineId = pipelineId, - channelCode = channelCode ?: ChannelCode.BS + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -70,7 +68,6 @@ class ApigwBuildResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, - gatewayTag: String, projectId: String, pipelineId: String, buildId: String @@ -92,8 +89,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( projectId: String, pipelineId: String, page: Int?, - pageSize: Int?, - channelCode: ChannelCode? + pageSize: Int? ): Result> { logger.info("$pipelineId|getHistoryBuild|user($userId)") return client.get(ServiceBuildResource::class).getHistoryBuild( @@ -102,7 +98,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( pipelineId = pipelineId, page = page, pageSize = pageSize, - channelCode = channelCode ?: ChannelCode.BS + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -113,8 +109,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( projectId: String, pipelineId: String, values: Map, - buildNo: Int?, - channelCode: ChannelCode? + buildNo: Int? ): Result { logger.info("$pipelineId|manualStartup|user($userId)") return client.get(ServiceBuildResource::class).manualStartup( @@ -123,7 +118,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( pipelineId = pipelineId, values = values, buildNo = buildNo, - channelCode = channelCode ?: ChannelCode.BS + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -133,8 +128,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( userId: String, projectId: String, pipelineId: String, - buildId: String, - channelCode: ChannelCode? + buildId: String ): Result { logger.info("$pipelineId|manualShutdown|user($userId)") return client.get(ServiceBuildResource::class).manualShutdown( @@ -142,7 +136,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( projectId = projectId, pipelineId = pipelineId, buildId = buildId, - channelCode = channelCode ?: ChannelCode.BS + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -155,8 +149,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( buildId: String, taskId: String?, failedContainer: Boolean?, - skipFailedTask: Boolean?, - channelCode: ChannelCode? + skipFailedTask: Boolean? ): Result { logger.info("$pipelineId|retry|user($userId)") return client.get(ServiceBuildResource::class).retry( @@ -167,7 +160,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( taskId = taskId, failedContainer = failedContainer, skipFailedTask = skipFailedTask, - channelCode = channelCode ?: ChannelCode.BS + channelCode = apiGatewayUtil.getChannelCode() ) } @@ -177,8 +170,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( userId: String, projectId: String, pipelineId: String, - buildId: String, - channelCode: ChannelCode? + buildId: String ): Result { logger.info("$pipelineId|getBuildStatus|user($userId)|build($buildId)") return client.get(ServiceBuildResource::class).getBuildStatus( @@ -186,7 +178,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( projectId = projectId, pipelineId = pipelineId, buildId = buildId, - channelCode = channelCode ?: ChannelCode.BS + channelCode = apiGatewayUtil.getChannelCode() ) } diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ChannelUtils.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ChannelUtils.kt deleted file mode 100644 index e6a819d316b..00000000000 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ChannelUtils.kt +++ /dev/null @@ -1,40 +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.openapi.utils - -import com.tencent.devops.common.pipeline.enums.ChannelCode - -object ChannelUtils { - fun getChannelCode(gatewayTag: String): ChannelCode { - return if (gatewayTag.contains("stream") or gatewayTag.contains("gitci")) { - ChannelCode.GIT - } else { - ChannelCode.BS - } - } -} From 1b6831db3fe6655cb65f21dffd5eafc2362bef41 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Mon, 6 Sep 2021 14:54:06 +0800 Subject: [PATCH 044/120] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86bkci=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20#4293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gateway/core/lua/util/tag_util.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gateway/core/lua/util/tag_util.lua b/src/gateway/core/lua/util/tag_util.lua index dff3d295fc0..87e7a3f7951 100644 --- a/src/gateway/core/lua/util/tag_util.lua +++ b/src/gateway/core/lua/util/tag_util.lua @@ -116,7 +116,7 @@ function _M:get_frontend_path(tag, project) local red, err = redisUtil:new() if not red then ngx.log(ngx.ERR, "tag failed to new redis ", err) - return tag + return config.static_dir end local red_key = "ci:frontend:path:" .. tag if project == "codecc" then From 96122a15281416e96e44067af33833bd74fe474a Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 6 Sep 2021 15:11:50 +0800 Subject: [PATCH 045/120] =?UTF-8?q?feat:=20Stage=E5=87=86=E5=85=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AE=A1=E6=A0=B8=E6=B5=81=20#4531?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/command/stage/impl/UpdateStateForStageCmdFinally.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index 7caead331db..e50a52369e5 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -136,6 +136,7 @@ class UpdateStateForStageCmdFinally( commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_FAIL.name commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL commandContext.latestSummary = "s(${stage.stageId}) failed with QUALITY_CHECK_OUT" + pipelineStageService.checkQualityFailStage(userId = event.userId, buildStage = commandContext.stage) return finishBuild(commandContext = commandContext) } else if (nextStage != null) { From 3b256dd69382573fd5b7947baa45883b31adfbd7 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 6 Sep 2021 15:44:53 +0800 Subject: [PATCH 046/120] =?UTF-8?q?feat:=20Stage=E5=87=86=E5=85=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AE=A1=E6=A0=B8=E6=B5=81=20#4531?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/service/PipelineStageService.kt | 12 ++++++------ .../command/stage/impl/CheckPauseReviewStageCmd.kt | 2 +- .../stage/impl/UpdateStateForStageCmdFinally.kt | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt index 8aca88ffa6a..4f81e80f4ac 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt @@ -398,7 +398,7 @@ class PipelineStageService @Autowired constructor( } else { Pair(stage.checkOut, ControlPointPosition.AFTER_POSITION) } - if (check?.ruleIds.isNullOrEmpty()) return false + if (check?.ruleIds.isNullOrEmpty()) return true return try { val request = BuildCheckParamsV3( projectId = event.projectId, @@ -407,20 +407,20 @@ class PipelineStageService @Autowired constructor( position = position, templateId = null, interceptName = null, - ruleBuildIds = stage.checkIn?.ruleIds!!.toSet(), + ruleBuildIds = check?.ruleIds!!.toSet(), runtimeVariable = variables ) logger.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_REQUEST|${event.stageId}|" + - "inOrOut=$inOrOut|request=$request|ruleIds=${stage.checkIn?.ruleIds}") + "inOrOut=$inOrOut|request=$request|ruleIds=${check.ruleIds}") val result = client.get(ServiceQualityRuleResource::class).check(request).data!! logger.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_RESPONSE|${event.stageId}|" + - "inOrOut=$inOrOut|response=$result|ruleIds=${stage.checkIn?.ruleIds}") - stage.checkIn!!.checkTimes = result.checkTimes + "inOrOut=$inOrOut|response=$result|ruleIds=${check.ruleIds}") + check.checkTimes = result.checkTimes result.success } catch (ignore: Throwable) { logger.error("ENGINE|${event.buildId}|${event.source}|inOrOut=$inOrOut|" + "STAGE_QUALITY_CHECK_OUT_ERROR|${event.stageId}", ignore) - true + false } } diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index 3920b41f595..9573ae996c0 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -70,7 +70,7 @@ class CheckPauseReviewStageCmd( } else if (commandContext.buildStatus.isReadyToRun()) { // 质量红线 - if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { + if (!pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { // #4732 优先判断是否能通过质量红线检查 LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_FAILED|${event.stageId}") commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_FAIL.name diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index e50a52369e5..9176e3fa653 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -131,7 +131,7 @@ class UpdateStateForStageCmdFinally( } // #5019 在结束阶段做stage准出判断 - if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { + if (!pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_FAIL.name commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL From d6a2d22ee6cb9f0bda470da19f9096999099ac71 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 6 Sep 2021 16:21:19 +0800 Subject: [PATCH 047/120] =?UTF-8?q?feat:=20Stage=E5=87=86=E5=85=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AE=A1=E6=A0=B8=E6=B5=81=20#4531?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/service/detail/StageBuildDetailService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt index 88d7ce4ad21..fe7561bac95 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt @@ -195,7 +195,6 @@ class StageBuildDetailService( override fun onFindStage(stage: Stage, model: Model): Traverse { if (stage.id == stageId) { update = true - stage.status = null stage.reviewStatus = BuildStatus.QUALITY_CHECK_FAIL.name stage.stageControlOption = controlOption.stageControlOption stage.checkIn = checkIn From ec104d948780df9af4546c3e4283bf276f837f57 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 6 Sep 2021 16:37:03 +0800 Subject: [PATCH 048/120] =?UTF-8?q?feat:=20Stage=E5=87=86=E5=85=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AE=A1=E6=A0=B8=E6=B5=81=20#4531?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/common/pipeline/pojo/StageReviewGroup.kt | 2 +- .../process/service/builds/PipelineBuildFacadeService.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StageReviewGroup.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StageReviewGroup.kt index c50b34ff0e3..7bd1c25c3bb 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StageReviewGroup.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StageReviewGroup.kt @@ -36,7 +36,7 @@ data class StageReviewGroup( @ApiModelProperty("审核组ID(后台生成)", required = false) var id: String? = null, @ApiModelProperty("审核组名称", required = true) - val name: String = "default", + val name: String = "Flow 1", @ApiModelProperty("审核人员", required = true) var reviewers: List = listOf(), @ApiModelProperty("审核结果(枚举)", required = false) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index e4dfaa02f7a..d1c05edf3f1 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -809,8 +809,8 @@ class PipelineBuildFacadeService( throw ErrorCodeException( statusCode = Response.Status.FORBIDDEN.statusCode, errorCode = ProcessMessageCode.ERROR_PIPELINE_STAGE_REVIEW_GROUP_NOT_FOUND, - defaultMessage = "(${group?.name ?: "default"})非Stage($stageId)当前待审核组", - params = arrayOf(stageId, reviewRequest?.id ?: "default") + defaultMessage = "(${group?.name ?: "Flow 1"})非Stage($stageId)当前待审核组", + params = arrayOf(stageId, reviewRequest?.id ?: "Flow 1") ) } From ed06d26d88faff2509f8482d21695b0273835074 Mon Sep 17 00:00:00 2001 From: sawyersong2 Date: Mon, 6 Sep 2021 20:22:07 +0800 Subject: [PATCH 049/120] =?UTF-8?q?feat:=20openapi=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=9A=90=E8=97=8FchannelCode=E5=8F=82=E6=95=B0=20#5084?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/apigw/v3/ApigwPipelineResourceV3.kt | 24 ------------------- .../apigw/v3/ApigwPipelineResourceV3Impl.kt | 8 ------- .../devops/openapi/utils/ApiGatewayUtil.kt | 2 +- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt index fac641218ad..2dd2c76943d 100644 --- a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt +++ b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt @@ -81,9 +81,6 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, - @ApiParam(value = "网关路由tag", required = true) - @HeaderParam(AUTH_HEADER_GATEWAY_TAG) - gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -105,9 +102,6 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, - @ApiParam(value = "网关路由tag", required = true) - @HeaderParam(AUTH_HEADER_GATEWAY_TAG) - gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -131,9 +125,6 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, - @ApiParam(value = "网关路由tag", required = true) - @HeaderParam(AUTH_HEADER_GATEWAY_TAG) - gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -155,9 +146,6 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, - @ApiParam(value = "网关路由tag", required = true) - @HeaderParam(AUTH_HEADER_GATEWAY_TAG) - gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -182,9 +170,6 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, - @ApiParam(value = "网关路由tag", required = true) - @HeaderParam(AUTH_HEADER_GATEWAY_TAG) - gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -206,9 +191,6 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, - @ApiParam(value = "网关路由tag", required = true) - @HeaderParam(AUTH_HEADER_GATEWAY_TAG) - gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -246,9 +228,6 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, - @ApiParam(value = "网关路由tag", required = true) - @HeaderParam(AUTH_HEADER_GATEWAY_TAG) - gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -270,9 +249,6 @@ interface ApigwPipelineResourceV3 { @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) userId: String, - @ApiParam(value = "网关路由tag", required = true) - @HeaderParam(AUTH_HEADER_GATEWAY_TAG) - gatewayTag: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt index 04e0b53d643..ad937af5fe5 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwPipelineResourceV3Impl.kt @@ -70,7 +70,6 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, - gatewayTag: String, projectId: String, pipeline: Model ): Result { @@ -87,7 +86,6 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, - gatewayTag: String, projectId: String, pipelineId: String, pipeline: Model @@ -106,7 +104,6 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, - gatewayTag: String, projectId: String, pipelineId: String, modelAndSetting: PipelineModelAndSetting @@ -125,7 +122,6 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, - gatewayTag: String, projectId: String, modelAndSetting: PipelineModelAndSetting ): Result { @@ -142,7 +138,6 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, - gatewayTag: String, projectId: String, pipelineId: String ): Result { @@ -160,7 +155,6 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, - gatewayTag: String, projectId: String, pipelineIds: List ): Result> { @@ -177,7 +171,6 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, - gatewayTag: String, projectId: String, pipelineId: String ): Result { @@ -209,7 +202,6 @@ class ApigwPipelineResourceV3Impl @Autowired constructor( appCode: String?, apigwType: String?, userId: String, - gatewayTag: String, projectId: String, page: Int?, pageSize: Int? diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt index cff2f6175d5..23dbd5cb766 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt @@ -38,7 +38,7 @@ class ApiGatewayUtil { @Value("\${api.gateway.auth:#{false}}") private val apiGatewayAuth: Boolean = false - @Value("\${spring.cloud.consul.discovery.tag:prod}") + @Value("\${spring.cloud.consul.discovery.tags:prod}") private val consulTag: String = "prod" fun isAuth() = apiGatewayAuth From bd7f4367fdee5d42225df74759773d3ab75b475f Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 6 Sep 2021 21:08:57 +0800 Subject: [PATCH 050/120] =?UTF-8?q?perf:=20Windows=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=9C=BA=E7=9A=84batch=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98=20#4601=20=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../worker/common/utils/BatScriptUtil.kt | 2 +- .../worker/common/utils/CommandLineUtils.kt | 42 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt index 3d4eeea2900..b4b3414b762 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt @@ -73,7 +73,7 @@ object BatScriptUtil { workspace: File = dir, print2Logger: Boolean = true, elementId: String? = null, - charSetType: String? = CharSetType.UTF_8.name + charSetType: String? = null ): String { try { val file = getCommandFile( diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt index 49c73891e76..b17d4aa197b 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt @@ -57,7 +57,7 @@ object CommandLineUtils { executeErrorMessage: String? = null, buildId: String? = null, elementId: String? = null, - charSetType: String? = CharSetType.UTF_8.name + charSetType: String? = null ): String { val result = StringBuilder() @@ -73,20 +73,21 @@ object CommandLineUtils { null } - val charset = when (charSetType?.let { CharSetType.valueOf(it) }) { - CharSetType.UTF_8 -> "UTF-8" - CharSetType.GBK -> "GBK" - else -> "UTF-8" - } +// val charset = when (charSetType?.let { CharSetType.valueOf(it) }) { +// CharSetType.UTF_8 -> "UTF-8" +// CharSetType.GBK -> "GBK" +// else -> "UTF-8" +// } val outputStream = object : LogOutputStream() { - override fun processBuffer() { - val privateStringField = LogOutputStream::class.java.getDeclaredField("buffer") - privateStringField.isAccessible = true - val buffer = privateStringField.get(this) as ByteArrayOutputStream - processLine(buffer.toString(charset)) - buffer.reset() - } + +// override fun processBuffer() { +// val privateStringField = LogOutputStream::class.java.getDeclaredField("buffer") +// privateStringField.isAccessible = true +// val buffer = privateStringField.get(this) as ByteArrayOutputStream +// processLine(buffer.toString(charset)) +// buffer.reset() +// } override fun processLine(line: String?, level: Int) { if (line == null) @@ -107,13 +108,14 @@ object CommandLineUtils { } val errorStream = object : LogOutputStream() { - override fun processBuffer() { - val privateStringField = LogOutputStream::class.java.getDeclaredField("buffer") - privateStringField.isAccessible = true - val buffer = privateStringField.get(this) as ByteArrayOutputStream - processLine(buffer.toString(charset)) - buffer.reset() - } + +// override fun processBuffer() { +// val privateStringField = LogOutputStream::class.java.getDeclaredField("buffer") +// privateStringField.isAccessible = true +// val buffer = privateStringField.get(this) as ByteArrayOutputStream +// processLine(buffer.toString(charset)) +// buffer.reset() +// } override fun processLine(line: String?, level: Int) { if (line == null) { From 443c625b5ada8368d55e8e3fe5ca3a6d0eaa4074 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 6 Sep 2021 21:12:38 +0800 Subject: [PATCH 051/120] =?UTF-8?q?perf:=20Windows=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=9C=BA=E7=9A=84batch=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98=20#4601=20=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/worker/common/task/script/ICommand.kt | 2 +- .../tencent/devops/worker/common/task/script/ScriptTask.kt | 6 ++---- .../com/tencent/devops/worker/common/utils/BatScriptUtil.kt | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ICommand.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ICommand.kt index 89f1cbe8c84..8d0cd7b7e67 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ICommand.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ICommand.kt @@ -51,7 +51,7 @@ interface ICommand { continueNoneZero: Boolean = false, errorMessage: String? = null, elementId: String? = null, - charSetType: String? = CharSetType.UTF_8.name + charSetType: String? = null ) fun parseTemplate(buildId: String, command: String, data: Map, dir: File): String { diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt index 3726cd96875..e28cd812be7 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt @@ -67,7 +67,7 @@ open class ScriptTask : ITask() { errorType = ErrorType.USER, errorCode = ErrorCode.USER_INPUT_INVAILD ) - val charSetType = taskParams["charSetType"] ?: CharSetType.UTF_8.name +// val charSetType = taskParams["charSetType"] ?: CharSetType.UTF_8.name val continueNoneZero = taskParams["continueNoneZero"] ?: "false" // 如果脚本执行失败之后可以选择归档这个问题 @@ -107,9 +107,7 @@ open class ScriptTask : ITask() { buildEnvs = takeBuildEnvs(buildTask, buildVariables), continueNoneZero = continueNoneZero.toBoolean(), errorMessage = "Fail to run the plugin", - charSetType = if (BuildScriptType.valueOf(scriptType) == BuildScriptType.BAT) { - charSetType - } else null + charSetType = null ) } catch (ignore: Throwable) { logger.warn("Fail to run the script task", ignore) diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt index b4b3414b762..e172a0f3764 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt @@ -108,7 +108,7 @@ object BatScriptUtil { runtimeVariables: Map, dir: File, workspace: File = dir, - charSetType: String? = CharSetType.UTF_8.name + charSetType: String? = null ): File { val tmpDir = System.getProperty("java.io.tmpdir") val file = if (tmpDir.isNullOrBlank()) { From 6c6c6b8d775b7b23a31b652ead8906d46b18759c Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 6 Sep 2021 21:21:40 +0800 Subject: [PATCH 052/120] =?UTF-8?q?perf:=20Windows=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=9C=BA=E7=9A=84batch=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98=20#4601=20=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/pipeline/pojo/element/agent/WindowsScriptElement.kt | 1 - .../com/tencent/devops/worker/common/task/script/ICommand.kt | 1 - .../com/tencent/devops/worker/common/task/script/ScriptTask.kt | 1 - .../com/tencent/devops/worker/common/utils/BatScriptUtil.kt | 1 - .../com/tencent/devops/worker/common/utils/CommandLineUtils.kt | 1 - 5 files changed, 5 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt index 9e521353428..2fe787a7dbb 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt @@ -28,7 +28,6 @@ package com.tencent.devops.common.pipeline.pojo.element.agent import com.tencent.devops.common.pipeline.enums.BuildScriptType -import com.tencent.devops.common.pipeline.enums.CharSetType import com.tencent.devops.common.pipeline.pojo.element.Element import io.swagger.annotations.ApiModel import io.swagger.annotations.ApiModelProperty diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ICommand.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ICommand.kt index 8d0cd7b7e67..ac12a9607ef 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ICommand.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ICommand.kt @@ -28,7 +28,6 @@ package com.tencent.devops.worker.common.task.script import com.tencent.devops.common.api.util.ReplacementUtils -import com.tencent.devops.common.pipeline.enums.CharSetType import com.tencent.devops.store.pojo.app.BuildEnv import com.tencent.devops.worker.common.CI_TOKEN_CONTEXT import com.tencent.devops.worker.common.JOB_OS_CONTEXT diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt index e28cd812be7..c42cdc390dc 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt @@ -38,7 +38,6 @@ import com.tencent.devops.worker.common.api.ApiFactory import com.tencent.devops.worker.common.api.quality.QualityGatewaySDKApi import com.tencent.devops.common.api.exception.TaskExecuteException import com.tencent.devops.common.pipeline.enums.BuildScriptType -import com.tencent.devops.common.pipeline.enums.CharSetType import com.tencent.devops.process.utils.PIPELINE_START_USER_ID import com.tencent.devops.worker.common.api.archive.pojo.TokenType import com.tencent.devops.worker.common.env.AgentEnv diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt index e172a0f3764..744b37e37be 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt @@ -27,7 +27,6 @@ package com.tencent.devops.worker.common.utils -import com.tencent.devops.common.pipeline.enums.CharSetType import com.tencent.devops.worker.common.CommonEnv import com.tencent.devops.worker.common.WORKSPACE_ENV import com.tencent.devops.worker.common.task.script.ScriptEnvUtils diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt index b17d4aa197b..4041dd07db8 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt @@ -31,7 +31,6 @@ import com.tencent.devops.common.api.enums.OSType import com.tencent.devops.common.api.exception.TaskExecuteException import com.tencent.devops.common.api.pojo.ErrorCode import com.tencent.devops.common.api.pojo.ErrorType -import com.tencent.devops.common.pipeline.enums.CharSetType import com.tencent.devops.worker.common.env.AgentEnv.getOS import com.tencent.devops.worker.common.logger.LoggerService import com.tencent.devops.worker.common.task.script.ScriptEnvUtils From 9cd2492a3c9886f0f92e60115469382de32ba5ed Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 6 Sep 2021 21:28:20 +0800 Subject: [PATCH 053/120] =?UTF-8?q?perf:=20Windows=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=9C=BA=E7=9A=84batch=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98=20#4601=20=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/element/agent/WindowsScriptElement.kt | 1 + .../worker/common/task/script/ScriptTask.kt | 1 - .../devops/worker/common/utils/BatScriptUtil.kt | 16 ++++++++-------- .../worker/common/utils/CommandLineUtils.kt | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt index 2fe787a7dbb..9e521353428 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt @@ -28,6 +28,7 @@ package com.tencent.devops.common.pipeline.pojo.element.agent import com.tencent.devops.common.pipeline.enums.BuildScriptType +import com.tencent.devops.common.pipeline.enums.CharSetType import com.tencent.devops.common.pipeline.pojo.element.Element import io.swagger.annotations.ApiModel import io.swagger.annotations.ApiModelProperty diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt index c42cdc390dc..4accef6ee0a 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt @@ -37,7 +37,6 @@ import com.tencent.devops.store.pojo.app.BuildEnv import com.tencent.devops.worker.common.api.ApiFactory import com.tencent.devops.worker.common.api.quality.QualityGatewaySDKApi import com.tencent.devops.common.api.exception.TaskExecuteException -import com.tencent.devops.common.pipeline.enums.BuildScriptType import com.tencent.devops.process.utils.PIPELINE_START_USER_ID import com.tencent.devops.worker.common.api.archive.pojo.TokenType import com.tencent.devops.worker.common.env.AgentEnv diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt index 744b37e37be..1c6846c26e7 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt @@ -148,14 +148,14 @@ object BatScriptUtil { newValue = File(dir, ScriptEnvUtils.getQualityGatewayEnvFile()).canonicalPath )) - val charset = when (charSetType?.let { CharSetType.valueOf(it) }) { - CharSetType.UTF_8 -> Charsets.UTF_8 - CharSetType.GBK -> Charset.forName(CharSetType.GBK.name) - else -> Charsets.UTF_8 - } - logger.info("The default charset is $charset") - - file.writeText(command.toString(), charset) +// val charset = when (charSetType?.let { CharSetType.valueOf(it) }) { +// CharSetType.UTF_8 -> Charsets.UTF_8 +// CharSetType.GBK -> Charset.forName(CharSetType.GBK.name) +// else -> Charsets.UTF_8 +// } +// logger.info("The default charset is $charset") + + file.writeText(command.toString()) logger.info("start to run windows script - ($command)") return file } diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt index 4041dd07db8..9dff7dd09b9 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt @@ -38,7 +38,6 @@ import org.apache.commons.exec.CommandLine import org.apache.commons.exec.LogOutputStream import org.apache.commons.exec.PumpStreamHandler import org.slf4j.LoggerFactory -import java.io.ByteArrayOutputStream import java.io.File import java.util.regex.Pattern From c23e3223831b518942beb794a732583caa5fdd16 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 6 Sep 2021 21:33:52 +0800 Subject: [PATCH 054/120] =?UTF-8?q?perf:=20Windows=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=9C=BA=E7=9A=84batch=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98=20#4601=20=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/worker/common/utils/BatScriptUtil.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt index 1c6846c26e7..dd2f9b52e6b 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt @@ -32,7 +32,6 @@ import com.tencent.devops.worker.common.WORKSPACE_ENV import com.tencent.devops.worker.common.task.script.ScriptEnvUtils import org.slf4j.LoggerFactory import java.io.File -import java.nio.charset.Charset object BatScriptUtil { private const val setEnv = ":setEnv\r\n" + From 03126a5330bbb5d046aecaecf4f8c824d2699bf5 Mon Sep 17 00:00:00 2001 From: ddlin0719 Date: Mon, 6 Sep 2021 22:32:10 +0800 Subject: [PATCH 055/120] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9C=BA=E5=88=B6=E5=8F=AF=E9=85=8D=E7=BD=AE=20#5091?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/atom/plugin/MarketBuildUtils.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt index 8a7fe2f112d..8e5ff76d891 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt @@ -61,6 +61,7 @@ object MarketBuildUtils { ) fun beforeDelete(inputMap: Map<*, *>, atomCode: String, param: BeforeDeleteParam, codeccApi: CodeccApi) { + logger.info("start to do before delete: $inputMap, $atomCode") marketBuildExecutorService.execute { val bkAtomHookUrl = inputMap.getOrDefault( BK_ATOM_HOOK_URL, @@ -72,7 +73,10 @@ object MarketBuildUtils { ) as String val bkAtomHookBody = inputMap.getOrDefault(BK_ATOM_HOOK_URL_BODY, "") as String - if (bkAtomHookUrl.isBlank()) return@execute + if (bkAtomHookUrl.isBlank()) { + logger.info("bk atom hook url is blank: $atomCode") + return@execute + } doHttp(bkAtomHookUrl, bkAtomHookUrlMethod, bkAtomHookBody, param) } @@ -88,6 +92,8 @@ object MarketBuildUtils { var request = Request.Builder() .url(url) + logger.info("start to market build atom http: $url, $bkAtomHookUrlMethod, $bkAtomHookBody") + when (bkAtomHookUrlMethod) { HttpMethod.GET -> { request = request.get() @@ -107,7 +113,7 @@ object MarketBuildUtils { OkhttpUtils.doHttp(request.build()).use { response -> val body = response.body()!!.string() - logger.info("before delete execute result: $url, $body") + logger.info("before delete execute result: $body") } } From 917f589d3669d21c709fe71c9d1b77262d5bc98b Mon Sep 17 00:00:00 2001 From: sawyersong2 Date: Tue, 7 Sep 2021 10:16:47 +0800 Subject: [PATCH 056/120] =?UTF-8?q?feat:=20openapi=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=9A=90=E8=97=8FchannelCode=E5=8F=82=E6=95=B0=20#5084?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt | 2 -- .../devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt | 1 - 2 files changed, 3 deletions(-) diff --git a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt index eaa549ba145..822990d890a 100644 --- a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt +++ b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwBuildResourceV3.kt @@ -30,12 +30,10 @@ import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_APP_CODE import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_APP_CODE_DEFAULT_VALUE import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE -import com.tencent.devops.common.api.auth.AUTH_HEADER_GATEWAY_TAG import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID_DEFAULT_VALUE import com.tencent.devops.common.api.pojo.BuildHistoryPage import com.tencent.devops.common.api.pojo.Result -import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.common.pipeline.pojo.StageReviewRequest import com.tencent.devops.process.pojo.BuildHistory import com.tencent.devops.process.pojo.BuildHistoryWithVars diff --git a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt index 2dd2c76943d..0cb45da8b5b 100644 --- a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt +++ b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwPipelineResourceV3.kt @@ -30,7 +30,6 @@ import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_APP_CODE import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_APP_CODE_DEFAULT_VALUE import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE -import com.tencent.devops.common.api.auth.AUTH_HEADER_GATEWAY_TAG import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID_DEFAULT_VALUE import com.tencent.devops.common.api.pojo.Page From 934249ad85c8d7fd76e1dc616b922541318f1d70 Mon Sep 17 00:00:00 2001 From: fitzcao Date: Tue, 7 Sep 2021 17:11:26 +0800 Subject: [PATCH 057/120] =?UTF-8?q?feat:=20=E6=9D=83=E9=99=90=E4=B8=AD?= =?UTF-8?q?=E5=BF=83V3=E4=BC=98=E5=8C=96=E9=A1=B9=20#5053=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4isProject=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91,?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E7=94=A8=E6=88=B7=E6=98=AF=E5=90=A6=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E4=BA=86=E9=A1=B9=E7=9B=AE=E4=B8=8B=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fitzcao --- .../service/iam/impl/AbsPermissionProjectService.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/impl/AbsPermissionProjectService.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/impl/AbsPermissionProjectService.kt index 979b810fb77..de54e74e000 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/impl/AbsPermissionProjectService.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/impl/AbsPermissionProjectService.kt @@ -136,14 +136,11 @@ abstract class AbsPermissionProjectService @Autowired constructor( return true } var checkProjectUser = false - val projectUsers = getProjectGroupAndUserList(projectCode) - projectUsers.forEach { - // 此处可以考虑将list内的用户全部加到cache里面,但是要考虑userList过大占用较大内存 - if (it.userIdList.contains(userId)) { - iamCacheService.cacheProjectUser(userId, projectCode) - checkProjectUser = true - return@forEach - } + + val extProjectId = getProjectId(projectCode) + val userGroupInfos = permissionRoleMemberService.getUserGroups(extProjectId, userId) + if (userGroupInfos != null && userGroupInfos.isNotEmpty()) { + iamCacheService.cacheProjectUser(userId, projectCode) } return checkProjectUser } From 9f798ec8719221d32a1eb78f4588d3c51747662f Mon Sep 17 00:00:00 2001 From: fitzcao Date: Tue, 7 Sep 2021 17:28:23 +0800 Subject: [PATCH 058/120] =?UTF-8?q?feat:=20=E6=9D=83=E9=99=90=E4=B8=AD?= =?UTF-8?q?=E5=BF=83V3=E4=BC=98=E5=8C=96=E9=A1=B9=20#5053=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4isProject=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91,?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E7=94=A8=E6=88=B7=E6=98=AF=E5=90=A6=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E4=BA=86=E9=A1=B9=E7=9B=AE=E4=B8=8B=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fitzcao --- .../devops/auth/service/iam/impl/AbsPermissionProjectService.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/impl/AbsPermissionProjectService.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/impl/AbsPermissionProjectService.kt index de54e74e000..5e8a6f7a0b1 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/impl/AbsPermissionProjectService.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/impl/AbsPermissionProjectService.kt @@ -141,6 +141,7 @@ abstract class AbsPermissionProjectService @Autowired constructor( val userGroupInfos = permissionRoleMemberService.getUserGroups(extProjectId, userId) if (userGroupInfos != null && userGroupInfos.isNotEmpty()) { iamCacheService.cacheProjectUser(userId, projectCode) + checkProjectUser = true } return checkProjectUser } From ce4da2729384325ab185789b56ba052016106bb5 Mon Sep 17 00:00:00 2001 From: fitzcao Date: Tue, 7 Sep 2021 20:15:11 +0800 Subject: [PATCH 059/120] =?UTF-8?q?feat:=20=E6=9D=83=E9=99=90=E4=B8=AD?= =?UTF-8?q?=E5=BF=83V3=E4=BC=98=E5=8C=96=E9=A1=B9=20#5053=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E7=BC=93=E5=AD=98=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fitzcao --- .../com/tencent/devops/auth/service/iam/IamCacheService.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/IamCacheService.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/IamCacheService.kt index e34547e27fe..d69c4990d32 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/IamCacheService.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/iam/IamCacheService.kt @@ -17,16 +17,16 @@ class IamCacheService @Autowired constructor( val policyService: PolicyService? ) { - // 用户-管理员项目 缓存, 10分钟有效时间 + // 用户-管理员项目 缓存, 5分钟有效时间 private val projectManager = CacheBuilder.newBuilder() .maximumSize(5000) .expireAfterWrite(5, TimeUnit.MINUTES) .build>() - // 用户-project_view项目 缓存, 10分钟有效时间 + // 用户-project_view项目 缓存, 1分钟有效时间 private val projectViewCache = CacheBuilder.newBuilder() .maximumSize(5000) - .expireAfterWrite(10, TimeUnit.MINUTES) + .expireAfterWrite(1, TimeUnit.MINUTES) .build>() // 用户 -- action下策略 From 3b47ad8fbbb4b378ec517fd9def30cd4831cb40f Mon Sep 17 00:00:00 2001 From: ddlin0719 Date: Wed, 8 Sep 2021 11:36:01 +0800 Subject: [PATCH 060/120] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9C=BA=E5=88=B6=E5=8F=AF=E9=85=8D=E7=BD=AE=20#5091?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/MarketBuildAtomElementBizPlugin.kt | 2 +- .../engine/atom/plugin/MarketBuildUtils.kt | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt index 406ae07e0c3..10e884c2043 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt @@ -56,7 +56,7 @@ class MarketBuildAtomElementBizPlugin constructor( ) = Unit override fun beforeDelete(element: MarketBuildAtomElement, param: BeforeDeleteParam) { - val inputMap = element.data["input"] as Map<*, *> + val inputMap = element.data["input"] as Map MarketBuildUtils.beforeDelete(inputMap, element.getAtomCode(), param, codeccApi) } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt index 8e5ff76d891..7d601d32f59 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt @@ -60,7 +60,7 @@ object MarketBuildUtils { ArrayBlockingQueue(16000) ) - fun beforeDelete(inputMap: Map<*, *>, atomCode: String, param: BeforeDeleteParam, codeccApi: CodeccApi) { + fun beforeDelete(inputMap: Map, atomCode: String, param: BeforeDeleteParam, codeccApi: CodeccApi) { logger.info("start to do before delete: $inputMap, $atomCode") marketBuildExecutorService.execute { val bkAtomHookUrl = inputMap.getOrDefault( @@ -78,7 +78,7 @@ object MarketBuildUtils { return@execute } - doHttp(bkAtomHookUrl, bkAtomHookUrlMethod, bkAtomHookBody, param) + doHttp(bkAtomHookUrl, bkAtomHookUrlMethod, bkAtomHookBody, param, inputMap) } } @@ -86,9 +86,10 @@ object MarketBuildUtils { bkAtomHookUrl: String, bkAtomHookUrlMethod: String, bkAtomHookBody: String, - param: BeforeDeleteParam + param: BeforeDeleteParam, + inputMap: Map ) { - val url = resolveParam(bkAtomHookUrl, param) + val url = resolveParam(bkAtomHookUrl, param, inputMap) var request = Request.Builder() .url(url) @@ -99,11 +100,11 @@ object MarketBuildUtils { request = request.get() } HttpMethod.POST -> { - val requestBody = resolveParam(bkAtomHookBody, param) + val requestBody = resolveParam(bkAtomHookBody, param, inputMap) request = request.post(RequestBody.create(OkhttpUtils.jsonMediaType, requestBody)) } HttpMethod.PUT -> { - val requestBody = resolveParam(bkAtomHookBody, param) + val requestBody = resolveParam(bkAtomHookBody, param, inputMap) request = request.put(RequestBody.create(OkhttpUtils.jsonMediaType, requestBody)) } HttpMethod.DELETE -> { @@ -131,9 +132,15 @@ object MarketBuildUtils { return "DELETE" } - private fun resolveParam(str: String, param: BeforeDeleteParam): String { - return str.replace("{$PROJECT_ID}", param.projectId) + private fun resolveParam(str: String, param: BeforeDeleteParam, inputMap: Map): String { + var result = str.replace("{$PROJECT_ID}", param.projectId) .replace("{$PIPELINE_ID}", param.pipelineId) .replace("{$USER_ID}", param.userId) + + inputMap.forEach { (key, value) -> + result = result.replace("{$key}", value.toString()) + } + + return result } } From a439ac5a7e99b1a79f464efe671edaf64ed8bcb7 Mon Sep 17 00:00:00 2001 From: ddlin0719 Date: Wed, 8 Sep 2021 11:41:06 +0800 Subject: [PATCH 061/120] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9C=BA=E5=88=B6=E5=8F=AF=E9=85=8D=E7=BD=AE=20#5091?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/atom/plugin/MarketBuildUtils.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt index 7d601d32f59..91a4729a5d0 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt @@ -141,6 +141,7 @@ object MarketBuildUtils { result = result.replace("{$key}", value.toString()) } - return result + // 没有变量值的变量默认置空 + return result.replace(Regex("\\{.*}"), "") } } From 23d09019fbc64929e1ea277f621b95640fce5313 Mon Sep 17 00:00:00 2001 From: ddlin0719 Date: Wed, 8 Sep 2021 12:10:48 +0800 Subject: [PATCH 062/120] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9C=BA=E5=88=B6=E5=8F=AF=E9=85=8D=E7=BD=AE=20#5091?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt index 0bc585d7fb4..60c5a3137ad 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt @@ -56,7 +56,7 @@ class MarketBuildLessAtomElementBizPlugin constructor( ) = Unit override fun beforeDelete(element: MarketBuildLessAtomElement, param: BeforeDeleteParam) { - val inputMap = element.data["input"] as Map<*, *> + val inputMap = element.data["input"] as Map MarketBuildUtils.beforeDelete(inputMap, element.getAtomCode(), param, codeccApi) } From 3d7551d675e57b17ebcf0fc39270737d85382d9e Mon Sep 17 00:00:00 2001 From: sawyersong2 Date: Wed, 8 Sep 2021 12:27:38 +0800 Subject: [PATCH 063/120] =?UTF-8?q?feat:=20openapi=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=9A=90=E8=97=8FchannelCode=E5=8F=82=E6=95=B0=20#5084?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt index 23dbd5cb766..c79ac86c572 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/utils/ApiGatewayUtil.kt @@ -44,8 +44,10 @@ class ApiGatewayUtil { fun isAuth() = apiGatewayAuth fun getChannelCode(): ChannelCode { - return if (consulTag.contains("stream") or consulTag.contains("gitci")) { + return if (consulTag.contains("stream") || consulTag.contains("gitci")) { ChannelCode.GIT + } else if (consulTag.contains("auto")) { + ChannelCode.GONGFENGSCAN } else { ChannelCode.BS } From 23263795a31ff412c07456e15d7235a85dc8e95b Mon Sep 17 00:00:00 2001 From: ddlin0719 Date: Wed, 8 Sep 2021 13:27:01 +0800 Subject: [PATCH 064/120] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9C=BA=E5=88=B6=E5=8F=AF=E9=85=8D=E7=BD=AE=20#5091?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/atom/plugin/MarketBuildUtils.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt index 91a4729a5d0..618be120065 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt @@ -136,12 +136,17 @@ object MarketBuildUtils { var result = str.replace("{$PROJECT_ID}", param.projectId) .replace("{$PIPELINE_ID}", param.pipelineId) .replace("{$USER_ID}", param.userId) + .replace("%7B$PROJECT_ID%7D", param.projectId) + .replace("%7B$PIPELINE_ID%7D", param.pipelineId) + .replace("%7B$USER_ID%7D", param.userId) inputMap.forEach { (key, value) -> result = result.replace("{$key}", value.toString()) + .replace("%7B$key%7D", value.toString()) } // 没有变量值的变量默认置空 return result.replace(Regex("\\{.*}"), "") + .replace(Regex("%7B.*%7D"), "") } } From 36f73a906b14c50facf6a0714a71f5e4bf719ba4 Mon Sep 17 00:00:00 2001 From: fitzcao Date: Wed, 8 Sep 2021 16:02:25 +0800 Subject: [PATCH 065/120] =?UTF-8?q?feat:=20=E6=9D=83=E9=99=90=E4=B8=AD?= =?UTF-8?q?=E5=BF=83V3=E4=BC=98=E5=8C=96=E9=A1=B9=20#5053=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0approve=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fitzcao --- .../common-auth-api/lib/iam-sdk-1.0.1.jar | Bin 184973 -> 185252 bytes .../environment/service/AuthEnvService.kt | 1 + .../environment/service/AuthNodeService.kt | 1 + .../process/pojo/pipeline/SimplePipeline.kt | 4 +++- .../process/service/AuthPipelineService.kt | 1 + .../service/PipelineListFacadeService.kt | 6 ++++-- .../project/resources/AuthProjectService.kt | 1 + .../quality/service/v2/AuthQualityService.kt | 10 ++++++---- .../devops/repository/pojo/RepositoryInfo.kt | 4 +++- .../service/RepositoryAuthService.kt | 1 + .../repository/service/RepositoryService.kt | 3 ++- .../tencent/devops/ticket/pojo/Credential.kt | 4 +++- .../devops/ticket/service/AuthCertService.kt | 1 + .../ticket/service/AuthCredentialService.kt | 1 + .../ticket/service/CredentialServiceImpl.kt | 3 ++- 15 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/backend/ci/core/common/common-auth/common-auth-api/lib/iam-sdk-1.0.1.jar b/src/backend/ci/core/common/common-auth/common-auth-api/lib/iam-sdk-1.0.1.jar index d216573b23b7e124f2bc64a4acffdcddf71e92e1..d8569d0df20a30538ac42e2f235e790cae1d434b 100644 GIT binary patch delta 8865 zcmZu$cR-E%8$a*2)Jc2qaY{o=sf@N24V9VOKx8B>LPQCL!7*t$e{V7Ip&SmE%c)v#HX~im zSe*JjdJq2HWPpFaH=};@wFnDLcoHKpv7WG_2-wj`m_qk-AgLh6VOte+6K95C^a)89 ziV(b!Itkp_R;WquU6W3mhW0@3{Fczj$*Q;_&&3+BYyC# zDcH~PSqo|F@_2L4M*-G0JM@beXct2=z^p@0VpK zc(SRB&Y@|mGEUi%*EUgz{H{VNk4Gun@bz}8CC!eU@o1(>qIK3k+R`Bv?hh)=&2Oiq z)TtL+MF$2hJ1l*4<6rkG>@O53%*k+Q9Qm!ZSL`2k*H@{xHFILWc;|Hc^-eDCeKc%m z+R@#qVwF8r?JI9?$mLgmNc!1pw^4ELomX|IRLad77g;BNw^w=O^{nENdchB0rJdo9 zuwc>H?JY?KMP-go3To%!R9^zINloe#qWC!E%uy_pbKyk9u`!OfF; z-vs6g`lGGxWT|XZm6*+Ka7fsde$19(gegg0_txkf?A=|R zRC}+YGuE){OQyVf$8B-F)1P-lO>Mqs7WL}Ahs}=cX3g1i=VTwuS{$+Wd3M3NyGLw` zGskASTnxLPvm>@Lv+swMzi;@yDd=T{ zL;4kSy(J$Bk1@s*E|$x;4b@1KOUeOY5dx@dM-!6x`e|;_qi&2FmdllfeITAC@ znZ$gbD0M7On4TIpX{^b)zEK+YGOJ?_uU(y4KfE^FQmI3uFrbdV(bDajyL3{6SnrL` zX9er0NZogL+jIY%@b)jqL!*Pg7*0y=i`|fAz3al05;@mDdvChksdsp(b{Ecxji;d&jPr*1rrQuPx-)=6kN2doXNUMQE@LfA9KX@yp73#R5BB z7EJAVC1-fma{AD;J96eznjeT+b{zepXHlDJQTty+%F3y#H`DnZDLq*a6h9s1R<5m8 zSi7{-)T}3W!i{S^X$F3tQI&i5_M|fE>R8pEGo~3h$q{2$xEptDDZA%- zMEOz9vnQkd_q9JOMR%1$MNr?62bH|VA3ol_@@!=%*naKhpXXA|Yc3ylD6Mj@w+q|) zxk=A=v|*daU0!9~=aZ@1FT20jZ2Pp#^)Yw)Y9s%yKHq4Gb{+TEPmF>KFH6hErc|gY zt<*h|bmm(8AjsO%ro%%E-u88WOcmc=Gxd`#h}FIG#nkh)te4f&=Y5H9 zYVNe0xb(Wl=r*hyI$G!=SCpQg4P`I~+~=ARU&-^rz= zv?>yMq?h86fHBu%M1+5NJF*5J4Ht^1D;Q_-C}N(zqP5j;M^K+6K4DmZ^W z0N?I02~oF@(eUDGS|{?R5Sy|ERV!W^ z^5TFlzwDcWV8gR2+L}vO4(YtY|@9Y@D0P}>w z;)E1UhI0vhtSwBHCA6_gVUYr{jOJ>p5ijsMKK@(nbpuLZyBvq(0tpMk1R9(IT)2n) z=f6{6sL)TFxIILQY(Wk=E3B!4q2h!CoL>TDgb_TVj<)S!OkALIURsLl22Cvpd8(>H zM++i^24-0kYw*JS=-bxWifXcv%RIX>@TN5}6wWFGio!5EqD_qIj+CNH8;>E}D%AW~ zlAQ!BB>{<}iPIQxwLl|E5v{O4mj(#uIuVw1DR#RNc{tNkR^CtdBiL~CJdY&p2ty_k zLK>#wNqnbkqv}W4(xlf+;x>*OqV3>Dg_C0CYPcDNGfA4mSp>%|LEq^`-Q|knk%=2$djN<020EL@kATFRZ;KcjtjjniEyT4zq^Gnm7=&6yNM_9rr>otrBQLmr5Wf`~r#3 zbS7`J2pe2CvTd`5{^x-NKR#N9O3wabXIn06X2+2=g0cC8sSxH7jRa-hFQ`LyHxg=! z!HzA&FiI0Po(DR@Gx@{;+(XuNh}6bXt(@MD}F*@jY1oR>PcbgMW7(Gt|I#ARYvWu zE3RZrHBnEe>r_ijz$AGU!TFcLP~E}zP+*bFh-Q@7K4hM3;k8JZj!>e3xQkOE=LJV> zTDOVVOq(vaK{)UzE^L2KIAOWY2SS_9-{~WvMC(uM7AnLZAy)qtDOLKAcnlwj2oXX_hCP=*CT+Tbzm$VC^((sq3Hks}Ho7yRvF z1A@PXt){?Lc!~!e(C{5bz>tQQ83SdStTzRcSo5K5XE|BjlUP&J96X{mzgqwu8m?(A z(zLMwJeoUeB+yc&R^PGCa$*ZI(uJ1Dg<7IKB_IpuUk8fNrWqBgda@{>98Y9`(wg?B zc}_3Vaz(prkd{!=2Mnd%sQLn)0$vlxxuBblZp3_`MW5=ai$ODu)d>eV7yvIW1CQ|X z=R|-pn0gQa@X#pKS`LzFONSzXAD#m@jS5>@h*FT3gh_FP?*8RqC~S=c`oi%s;1<2D z)Z>66?aXpDP?o1MNeH_jPrgBK(C#-U^GB*fgwZJ=o7R%w4lHTXEfpAG5-!{W=!rLT z55R{5KH3AUajP# zF3aPe-ZX-rdq}@Oh6S@aJW|m!NGPI*n}yz0z*qFp<(D2&hu)QR#4!PX+Lofjnu^|M zCl)%qh(ts0d|-)VOUOsD#gn0yv}L!`zVvZ@GVf^B4y@qTJBpY<%ugd3bjPwvH$sh)Q7%|R z5X*(rB#cKxk$OM=)=T?EC(*?41C56cEIiK(;i79C{jP8$9P2{4AiBKC3t^0S;~lT#Q( zQ<&L+3*Z+CSP_Et5P-h;V-OU$gpq6;Sak-BrE2qf*=E%#=%jX{vCNf~tNKz5Ee<9W z;QTXmDy%V%g})F*;_-Vs(LVp3HA=V@y>+21RN^Wemsthyq5@#edn~BMS`1~zKl;F< zwn7U8ZiIvojHE0CI_sBrpyMnasXZ8~pN-y$`R4%svk6Q+hvG`e7$7T2C!}DhaT#hv$ z8bo>heMSE;I=BLnM<@^EWQr>gs+{yG4NU=P?i+L?|8bOr`cid@oj7^pK2&`pRQ=hk z045(JQMRz`0;Vfb0D- zW+##CS4~(&wi-yn2Bbpeuy3ci%viJ@ZS;)2-jEB?=}fR&o=d=Pyfd4NY@99N24Pbwp26GcT}S=jXw^M>0AMNxKOTF$YOL4 zkR@CJMp%Xq@F$T>_P0$9BfpiWqdh(q9n*=TP{{5hcYqpf>?RE0jV8J@D>p@}FGlyx z7d7;OmZg;bv)>o2>LUy(B^*rKRTOBDBs^S;4nOn#K!vLH)$p$&x#-4@R33b5$4QCs zY6EN)*C1QV6iJyQw63A+8o4s_YCSqeIcVA3SaEGq#?Yu*piFtJ3jMn8B7%~i+St%S zRT4UtLTz6Ah(pfw7k)!kt7C(|)X<*syT&ZkylW_~e>Ab|>@{XHUnki*I+$%(N5?QK z-)!<3WIf?G>mGU-x`%-}wvXt!fS@VAK?4jhw2y&`K7$}A`1${9#xod7X**Ey=Dl!EE;iI%dV;mCH*}AOXKwZ#BbEIWr*n+cpz@Vfjt%p*dF5 zXk;9ZXhe>I746s(#k#YRi8YIq8IHiRk4S}DCe2@22O3dOFMqQ>))qs9n`o%4uCr~e z3Wu}Hox^cvZIQWlByX(~+Cw;q;Kv(Eq}iR(ZGpBTOCC;&Y_k<5rP^G%?WoP~UQAm8j1Cd|XosJTD` za%-8Qb(3bsgoI{7o+~(`U+#~{0(Hwco~*? zhokwcU#4{v$?77o?4M;oiIP!%NYl)Xrz7%14q%1LA@3H@QyBc(;`#O&B{lkOKdte# znKT^LARZZIZ*rqZ(w-6YUXEU@s1_#f#1<6W@hDO@4!(~>%R<(Nimm^P*WeE7M-0aM zw*qSl`XgcWqkQC+{JX*|Q5xiJX|M`IJ6eGu1r5D7Z^RkY)!Lh*@6;@)!x|DggF>-B znz2wmTS=52L?6)PVD&8~kJei#4~-pI=CmDsTkOx#;x>{^*@a~hsi^*IZUY60WocyP F{|B{X%HjY3 delta 8404 zcmZu$c|c9u_dk0#+$QNZi-uboG^fFoGD{f}nUZ8Gqb1?uyz zPd;g?rn1cMh&{5O=)aqd$Zw|w^DEQ?R)m-a>=>kQD{y2u=yNkL7v2LJ%wOf*phAxD z--SSPVH;1I@c-cnWeF9hGL@ySsXdkD)9y+=U845^iVB4ko6cX zxjF)~lrY?W1S1p{ z+q)6eTl)lgLTwnambLMGOa!S$x&Qb>B-h610fVDtDasmG-%1!5ZBTAIC4+@Gc($=F zvuAE5#)P`Q?#1;Tr>e4a9ajR~7ZSigt8ARedOI&tcE?D3r< zMNPsU?aNCdidc_}H-D66Y8Rofdiw_%ih9ap3X8n+pdNaZ2M3fNivA(PtkQlTmC}nC z@)_6Pld>KSS^u~))i zb5-?P;VEUG_!STLjdA>PEoWbMZ}06r?%+=C68YVQ*OsaJYMoI@FDxiCeO`TYy<_s1 z;Sr%;Ehn8qy<#@cxtikiD2?A0^e)a-dp26+e|0DH{Oe;iyjw5xLAgWs+lCv#ck%-G zSz}8F>US8bTE|__s=gOo-LNBU)Vh}LQh?Oya(FExaaThQ0`b!Jg0vB?78P1z8x~)p_~u1 ze0om1ADzE@=K+(GvNL-+PL5#;o4u@`5uj{ z=DgVKwN%bBvNiT)d4=xYZNq(C6aKSR*qrim`qG>Ry;(LYwI4PKs1+9neR}q^EA2m* z&zoKk+f%1!+p$5;ZnDvU=J>6?)<0t7W2^Fk)Ff-VRLsaUi6R2wUpE*|9rP?+Ck}K>n0tji1Si^;=U|m*Xf0p z(cAa_>hn!*eSk@Z>#!e5RWC-j+sWTv_FD79!TR{>H?A%j@59cP9{;{8VP{)&akIi* zqY0y85}lU`ES8x}cUnD3WAfft0rin5Ix=gWTaQimOD`*~$;c0%c{<_v{$3d!-x`-5 z^Y@lZUfNwRDPR2c_r~O<{v&Oh9uK{hkl-lvn4#q1ux{7_ncjuQStYuMy_Yo2J09|3 zf=zyP=E;a@F1a>i;};nSzN}vN_Vv)+Pu^HeO^<(c`M%S~V~M@0XJj|}sb>x~bq>9` z{G6tb#O)!7SpemQQPnC0y1P1;wP;-% z$x=tIJY{E1Qe!rc;H=tavr{tmmOC?}92*2R@_790m7^#-Vc<)%^3S)1uzK3}X0g=j zhed33+D|7EQ~pmsu)?`7b6NABIv0`2H`nUx+qZavRw^???WHA3DTX{W@HkX0Kk)ts z8)5#JOXQf*+4baEGY+Cy0sV3W2+C8xePwMY_g*09jA#}BMzV@@owrP?QmjJbje)c1 zq#U?GkfK;cU?|6=)TQ}{d?`M(&ftkUn@$OZmtf}?PeOB%>_Bi14xp`E&Y62!2Pa)8 z>>Oi^N>4&vk(@d(Cuxf8b-;5HrD)I)U`UE4ay14jEO)vYs1`4nmC&e50l8U&flO^g zv#o)@40B3+e44*X9~WYzB9j?|Tj~UqL|t}ZG;7Mn30Sb?!ja%Dn~$d}m`_fck5Mgq zeX)&8iu55Y5Veg1>>7)vO$L9ns&<~>D;vDEH*jFdKwof^7!=0dvO?a$Kmn~;h_j$e zAlkAJKvq50A2hI8daVGrNc6AQY}fLTr>JLYTF^M!4Gop5JepZuUInZ2>6F3eUAY- zHj*VLKn_dxmVrfVB#Y00aV$6g99YFRq0)IUf)os2W2{j4CH594+Ia~ykeZ!c+xqKQ z+Y|7iFp&+fx)nGJn0qDq*agNgdeK=~ppBxaO@O(qp;R7JK#rH8I*ND)?lD{A zu+5MymodZ>-yK~Lcn6G8`emqtvbw=FVlDW+c(LAtE+taV13y4LyI8AvP>XEZ%d0>6 z=ix23P6K%dLQ9l;1!{|~DZ)Y?V@b4$4>chnQ#GIw96;ZfYXU!IoX5_$qfjI0F8Zzo zTLHne>Ocz?{%sJnW=YE-(2Quh9I}{Nfiamb^P1&SFXHSx}%x0J8&NH)~-^Ak>p5+!aBv1u{#;uh`@@ z8#^?|Gio?lD%BfMLln6N`T=IW^ZeJ%O~Z?Mnvz)W&>MKYwL)MvV-Hn?z>$Q)C&yUg z!(knaV?9@fibGTU1>%c5y+$J2NXUnLnhd-ZU{|3^QBIZ=H5pwBfrg^6jqs%^!7bVW z8)Z~!oUQK7;m>i?XUhu%&GeD|FHr87&n_rKaPyL(5h2l*ROrYsQCTV^?*Q~671}a= zhD_6-3!wti;3z`nq_J_MhiPy;;Tfkxa2L|*wWUKZLKzBS0HL-Cp+BLX3gL1> zdG6(S#d|rPdIk(8(&!Ahh)@qQpdX>eWWxD`%FKkz2=zUallmdJknqkTIGIo&3r;80 z>?{sfngs(1Pir6Nck4b*dVe4EB~qvTTmcNf_Vc9l2RGbejjp*aVIXUZU6`osD@UzJq_a*nQAntiOha4cByH^`MJ^)o1m9E6w zH>$CUD^~I0@c6eNP6g2_!q6|Fpi12 z83owfzB7!u*Oi7yIS-OU8{tORgQn+DdjYg#QhGD4r)vfd(gl~rMauFj24y0wsn$XZ zj&M1hu2e9?@Gb?4a+ZSgF49I#g#NXfs2ambBrQjqoQ<#4y z>@P*BQE$il{V8m}W!kUAQg>Og0^Ln{w1NX_*~cZ7b_^%geFt;Rgt-sZg^TYA`Vw23 zlyH0wUaB8>sa&P(OnSg-=%VmK&Q@$8ZR?3J@cpoUA%#Ad@rcJQy9qatuav2gf1~a~ zxSYwf=u1%E6kJJ4i=xI#q3mAJs8Q%-5maZO!%nS>dxER-3c~}Wplxq)1a3(GIJ6@R z=Y1T%d*t0smjqN%62;QUYF;FPtAOr-=WqElGL*m`tF`*kC3pG16cO0VWe zJu%*ptdSi(HFN}oy|D!9G8UYR3nNxy3$t)E(hX>CN<&Rij2Re&-j;BS$_$?umPF=O z3duVJ%`U~(t*r<<-Wu@x^=IGvWyWt&EE( znU*=&7Gm8A8^3w9QR->VdOj^1 zI*G{co`xn&H8aaGS7{pIF7gC={nA~i88+b&_HTx_qx2Bw%_3?!<2gudNrWM1C22Jf>> zd~QvYQu15e=ZjX-L$4~?PTVH*Dm@T;I*PZ6pOli>a-vjwhP$b#RpNB1Ah9hI)LF@u zdn+v~SSOZgpvFo#oRq1TmIXzKWeUh$1U-o?8Q)u=<|YZ*#Ymvb#76-1#Rg7{Aprca zQ$%iOIj1wvV%bhfS?XCxKB}XOw5%astf!1*s-PLMX;Xz|?~}zcKH69XEtvMRo-r-{ z3Eo#acxOrb4>URpM)SS(XSf#x+Q$kJ7*x~bP!frW-M^M`ZZuH{YwH`F8 zMP(P^(0-e1O7e5Ht$4}e@m_I|3TGM7KvkE(z`irA@3~G<_ELD8E3^mpjlx{IA{yv; z2GP%VrGAbV6|2~_;P+YvcJ3%;=!}FKQf>n3%sqrD360|>h=Ev%zT&hu5ns&f|F2rE zGrDSV?gN`8WcbT~0a^GNm#{4Jy0lCQITqt-KtIwXof%3wyU~e$xeNvUa_ak{@N+R$ zyBH0GKQ9;<($`z5FAHMh^xew_@h?N>JA(;%`O%vmOhn-{w{0ktLp_(d^pxwcXs3ke z@q1u|mbP;8->@8R`A&Q@x)(C74@}MpA!CcKBC@-RZLL+80K{K~nk2OxTDC`1Le`CC zjI-^VA5b^2Gy1vXE>)l+Z3+C6dKRCO@~Ef-;|u%Y|J0Shw{ZB#AXnS#7+=~CFE>~M zKeB;~)w==5YNszDJ0g~yr)A>|C1fXz@W&**MqE&)2$qc)us|RIh-rixOrqZlOKh8Q zAm{s4b*qU4{tbs0f1c@wKV&L_$DeI@Xh{&)aq@VbD>%lZ{d~T$lF-d=W^+>7pH)YHLfX&|uWT!U=e0l$5{E$xj>FiV$d<8?s(PbIj1=>u@L& z=9_0VcJ=rOEy7pR(Nb+JSSp69q5E}sS~Dq!w_-Eyt7w@3oot2V|H)B1%~oAa*!aU1 zdmnbVf!QT%2pfOPG9X4$Y4)DAsH_bdpynG~6EIV`g<+eZL2Ya$H_o)5JPcQI6P~Qn z+gc@rwqSyS+u$%Jo20DUBReq^;3H|OR5oerXs9o7uhfp+KMSKd6VO8Zp$sLqv(9>= zHas|lEwtfflYZbSMi6{-B>rBla+8aB$W3g^U;`~1k7C-mGVP(+&IvTz05#!1nE3j> ttNnbqf?, token: String): FetchInstanceInfoResponseDTO? { val ids = encodeIds?.map { HashUtil.decodeIdToLong(it.toString()) } authTokenApi.checkToken(token) - val certInfos = qualityRuleDao.listByIds( + val qualityRuleInfos = qualityRuleDao.listByIds( dslContext = dslContext, ruleIds = ids!!.toSet() as Set) val result = FetchInstanceInfo() - if (certInfos == null || certInfos.isEmpty()) { + if (qualityRuleInfos == null || qualityRuleInfos.isEmpty()) { logger.info("$ids 无红线规则") return result.buildFetchInstanceFailResult() } val entityInfo = mutableListOf() - certInfos?.map { + qualityRuleInfos?.map { val entity = InstanceInfoDTO() entity.id = HashUtil.encodeLongId(it.id) entity.displayName = it.name + entity.iamApprover = arrayListOf(it.createUser) entityInfo.add(entity) } - logger.info("entityInfo $entityInfo, count ${certInfos.size.toLong()}") + logger.info("entityInfo $entityInfo, count ${qualityRuleInfos.size.toLong()}") return result.buildFetchInstanceResult(entityInfo) } @@ -176,6 +177,7 @@ class AuthQualityService @Autowired constructor( val entity = InstanceInfoDTO() entity.id = HashUtil.encodeLongId(it.id) entity.displayName = it.name + entity.iamApprover = arrayListOf(it.creator) entityInfo.add(entity) } logger.info("entityInfo $entityInfo, count ${qualityGroupInfos.size.toLong()}") diff --git a/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepositoryInfo.kt b/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepositoryInfo.kt index f3d248fe1c0..19b642aa45d 100644 --- a/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepositoryInfo.kt +++ b/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepositoryInfo.kt @@ -44,5 +44,7 @@ data class RepositoryInfo( @ApiModelProperty("类型", required = true) val type: ScmType, @ApiModelProperty("最后更新时间", required = true) - val updatedTime: Long + val updatedTime: Long, + @ApiModelProperty("创建人", required = false) + val createUser: String? = null ) diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryAuthService.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryAuthService.kt index 14d662097b2..2938e009939 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryAuthService.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryAuthService.kt @@ -84,6 +84,7 @@ class RepositoryAuthService @Autowired constructor( val entity = InstanceInfoDTO() entity.id = it.repositoryHashId entity.displayName = it.aliasName + entity.iamApprover = arrayListOf(it.createUser) entityInfo.add(entity) } logger.info("entityInfo $entityInfo, count ${repositoryInfos.size.toLong()}") diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryService.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryService.kt index d6f15451974..f07185dba16 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryService.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryService.kt @@ -1244,7 +1244,8 @@ class RepositoryService @Autowired constructor( aliasName = it.aliasName, url = it.url, type = ScmType.valueOf(it.type), - updatedTime = it.updatedTime.timestampmilli() + updatedTime = it.updatedTime.timestampmilli(), + createUser = it.userId ) ) } diff --git a/src/backend/ci/core/ticket/api-ticket/src/main/kotlin/com/tencent/devops/ticket/pojo/Credential.kt b/src/backend/ci/core/ticket/api-ticket/src/main/kotlin/com/tencent/devops/ticket/pojo/Credential.kt index ce154b85d20..70b2458da7d 100644 --- a/src/backend/ci/core/ticket/api-ticket/src/main/kotlin/com/tencent/devops/ticket/pojo/Credential.kt +++ b/src/backend/ci/core/ticket/api-ticket/src/main/kotlin/com/tencent/devops/ticket/pojo/Credential.kt @@ -52,5 +52,7 @@ data class Credential( @ApiModelProperty("凭据内容", required = true) val v4: String? = null, @ApiModelProperty("最后更新者", required = true) - val updateUser: String? = null + val updateUser: String? = null, + @ApiModelProperty("创建人", required = true) + val createUser: String? = null ) diff --git a/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/AuthCertService.kt b/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/AuthCertService.kt index 8c02efcf725..8d4aa869900 100644 --- a/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/AuthCertService.kt +++ b/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/AuthCertService.kt @@ -76,6 +76,7 @@ class AuthCertService @Autowired constructor( val entity = InstanceInfoDTO() entity.id = it.certId entity.displayName = it.certId + entity.iamApprover = arrayListOf(it.creator) entityInfo.add(entity) } logger.info("entityInfo $entityInfo, count ${certInfos.size.toLong()}") diff --git a/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/AuthCredentialService.kt b/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/AuthCredentialService.kt index 47974899ef7..a2ca99f33ae 100644 --- a/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/AuthCredentialService.kt +++ b/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/AuthCredentialService.kt @@ -76,6 +76,7 @@ class AuthCredentialService @Autowired constructor( val entity = InstanceInfoDTO() entity.id = it.credentialId entity.displayName = it.credentialId + entity.iamApprover = arrayListOf(it.createUser) entityInfo.add(entity) } logger.info("entityInfo $entityInfo, count ${credentialInfos.size.toLong()}") diff --git a/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/CredentialServiceImpl.kt b/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/CredentialServiceImpl.kt index 2dc8c14ef38..0eeb2b587fc 100644 --- a/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/CredentialServiceImpl.kt +++ b/src/backend/ci/core/ticket/biz-ticket/src/main/kotlin/com/tencent/devops/ticket/service/CredentialServiceImpl.kt @@ -529,7 +529,8 @@ class CredentialServiceImpl @Autowired constructor( v2 = credentialHelper.credentialMixer, v3 = credentialHelper.credentialMixer, v4 = credentialHelper.credentialMixer, - updateUser = it.updateUser + updateUser = it.updateUser, + createUser = it.credentialUserId ) } } From fe6cca654b687c77bc0a6ea3a2f0ff54fdfd3f47 Mon Sep 17 00:00:00 2001 From: vhwweng <1010382269@qq.com> Date: Wed, 8 Sep 2021 16:59:07 +0800 Subject: [PATCH 066/120] =?UTF-8?q?fix:=20=E4=BA=BA=E5=B7=A5=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=8F=92=E4=BB=B6=EF=BC=8C=E5=A4=8D=E9=80=89=E6=A1=86?= =?UTF-8?q?=E6=97=A0=E9=BB=98=E8=AE=A4=E5=80=BC=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=20issue=20#5126?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/AtomFormComponent/DefineParam/show.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/devops-pipeline/src/components/AtomFormComponent/DefineParam/show.vue b/src/frontend/devops-pipeline/src/components/AtomFormComponent/DefineParam/show.vue index 6ed19cc6cd1..4cf5111f1d6 100644 --- a/src/frontend/devops-pipeline/src/components/AtomFormComponent/DefineParam/show.vue +++ b/src/frontend/devops-pipeline/src/components/AtomFormComponent/DefineParam/show.vue @@ -127,7 +127,7 @@ if (isMultipleParam(valueType)) { const isString = typeof value === 'string' const isArray = Array.isArray(value) - return isString ? (value || '').split(',') : (isArray ? value : []) + return isString ? (value.length ? (value).split(',') : []) : (isArray ? value : []) } return value }, From 4a77ed9971bf5ea40bf8b51253c44e0f65f61c75 Mon Sep 17 00:00:00 2001 From: fromschen Date: Wed, 8 Sep 2021 17:19:17 +0800 Subject: [PATCH 067/120] =?UTF-8?q?chore:=20turbo=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E9=80=82=E9=85=8D=20#5038?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/bk-ci-setup.sh | 6 ++++++ scripts/bk-ci-start.sh | 1 + 2 files changed, 7 insertions(+) diff --git a/scripts/bk-ci-setup.sh b/scripts/bk-ci-setup.sh index 63cec23d692..e81657a2b9a 100755 --- a/scripts/bk-ci-setup.sh +++ b/scripts/bk-ci-setup.sh @@ -255,6 +255,12 @@ setup_ci_dockerhost (){ env_line_set "$start_env" "LD_LIBRARY_PATH" "$BK_CI_HOME/$proj/sigar/" } +setup_ci_turbo (){ + local proj=$1 + setup_ci__ms_common "$proj" || return 11 + render_ci quartz # 渲染 #etc#ci#thirdparty#quartz.properties +} + # 校验网关关键配置, 设置家目录, 设置启动用户或setcap? setup_ci_gateway (){ #check_empty_var BK_CI_DATA_DIR BK_CI_HOME BK_CI_LOGS_DIR || return 15 diff --git a/scripts/bk-ci-start.sh b/scripts/bk-ci-start.sh index 8a9e7097395..acef483af44 100755 --- a/scripts/bk-ci-start.sh +++ b/scripts/bk-ci-start.sh @@ -128,6 +128,7 @@ start_ci__springboot (){ java_pid=$! echo "$java_pid" > "$pid_file" || return 24 echo "java pid is $java_pid." + [ "$MS_NAME" = "turbo" ] && return 0 # 此处阻塞. if ! wait_springboot_up "$java_pid" "$API_PORT"; then echo "wait_springboot_up: unable to confirm app status from http://127.0.0.1:$API_PORT/management/health" From 17eddf141f02dfe50ec02d58e95c79758d855ce9 Mon Sep 17 00:00:00 2001 From: fitzcao Date: Wed, 8 Sep 2021 17:30:15 +0800 Subject: [PATCH 068/120] =?UTF-8?q?feat:=20=E6=9D=83=E9=99=90=E4=B8=AD?= =?UTF-8?q?=E5=BF=83V3=E4=BC=98=E5=8C=96=E9=A1=B9=20#5053=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0project=20routerTag=E6=A0=A1=E9=AA=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fitzcao --- .../template/TemplateInstanceCronService.kt | 9 ++- .../api/service/ServiceProjectTagResource.kt | 55 +++++++++++++++++++ .../ServiceProjectTagResourceImpl.kt | 43 +++++++++++++++ .../project/service/ProjectRouteTagService.kt | 50 +++++++++++++++++ 4 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt create mode 100644 src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/ServiceProjectTagResourceImpl.kt create mode 100644 src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectRouteTagService.kt diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/template/TemplateInstanceCronService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/template/TemplateInstanceCronService.kt index 22eb19e7c7b..c342f035b90 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/template/TemplateInstanceCronService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/template/TemplateInstanceCronService.kt @@ -42,6 +42,7 @@ import com.tencent.devops.process.pojo.template.TemplateInstanceBaseStatus import com.tencent.devops.process.pojo.template.TemplateInstanceUpdate import com.tencent.devops.process.service.template.TemplateFacadeService import com.tencent.devops.process.util.TempNotifyTemplateUtils +import com.tencent.devops.project.api.service.ServiceProjectTagResource import org.jooq.DSLContext import org.jooq.impl.DSL import org.slf4j.LoggerFactory @@ -91,6 +92,13 @@ class TemplateInstanceCronService @Autowired constructor( ) templateInstanceBaseList?.forEach { templateInstanceBase -> val baseId = templateInstanceBase.id + val projectId = templateInstanceBase.projectId + val projectRouterTagCheck = client.get(ServiceProjectTagResource::class).checkProjectRouter(projectId).data + if (!projectRouterTagCheck!!) { + logger.info("project $projectId router tag is not this cluster") + return@forEach + } + // 把模板批量更新记录状态置为”实例化中“ templateInstanceBaseDao.updateTemplateInstanceBase( dslContext = dslContext, @@ -98,7 +106,6 @@ class TemplateInstanceCronService @Autowired constructor( status = TemplateInstanceBaseStatus.INSTANCING.name, userId = "system" ) - val projectId = templateInstanceBase.projectId val successPipelines = ArrayList() val failurePipelines = ArrayList() val templateInstanceItemCount = templateInstanceItemDao.getTemplateInstanceItemCountByBaseId( diff --git a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt new file mode 100644 index 00000000000..75db09092b8 --- /dev/null +++ b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt @@ -0,0 +1,55 @@ +/* + * 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.project.api.service + +import com.tencent.devops.common.api.auth.AUTH_HEADER_PROJECT_ID +import com.tencent.devops.project.pojo.Result +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam +import javax.ws.rs.Consumes +import javax.ws.rs.GET +import javax.ws.rs.HeaderParam +import javax.ws.rs.Path +import javax.ws.rs.Produces +import javax.ws.rs.core.MediaType + +@Api(tags = ["SERVICE_TAG"], description = "项目流量信息") +@Path("/service/projects/tag") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +interface ServiceProjectTagResource { + @GET + @Path("/checkProject/router") + @ApiOperation("判断项目指向是否一致") + fun checkProjectRouter( + @ApiParam("项目id", required = true) + @HeaderParam(AUTH_HEADER_PROJECT_ID) + projectId: String + ): Result +} diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/ServiceProjectTagResourceImpl.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/ServiceProjectTagResourceImpl.kt new file mode 100644 index 00000000000..69ed55b2068 --- /dev/null +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/ServiceProjectTagResourceImpl.kt @@ -0,0 +1,43 @@ +/* + * 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.project.resources + +import com.tencent.devops.common.web.RestResource +import com.tencent.devops.project.api.service.ServiceProjectTagResource +import com.tencent.devops.project.pojo.Result +import com.tencent.devops.project.service.ProjectRouteTagService +import org.springframework.beans.factory.annotation.Autowired + +@RestResource +class ServiceProjectTagResourceImpl @Autowired constructor( + val projectRouteTag: ProjectRouteTagService +) : ServiceProjectTagResource { + override fun checkProjectRouter(projectId: String): Result { + return Result(projectRouteTag.checkProjectTag(projectId)) + } +} diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectRouteTagService.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectRouteTagService.kt new file mode 100644 index 00000000000..afc5341e40f --- /dev/null +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectRouteTagService.kt @@ -0,0 +1,50 @@ +/* + * 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.project.service + +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Value +import org.springframework.stereotype.Service + +@Service +class ProjectRouteTagService @Autowired constructor( + val projectService: ProjectService +) { + @Value("\${spring.cloud.consul.discovery.tags:#{null}}") + private val tag: String? = null + + // 判断当前项目流量与当前集群匹配 + fun checkProjectTag(projectId: String): Boolean { + val routerTag = projectService.getByEnglishName(projectId)?.routerTag ?: return false + // 默认集群是不会有routerTag的信息 + if (routerTag.isNullOrEmpty()) { + return true + } + return tag == routerTag + } +} From 1e03b936202b96265d532947f576ca0ea1227542 Mon Sep 17 00:00:00 2001 From: fitzcao Date: Wed, 8 Sep 2021 17:45:14 +0800 Subject: [PATCH 069/120] =?UTF-8?q?feat:=20=E6=9D=83=E9=99=90=E4=B8=AD?= =?UTF-8?q?=E5=BF=83V3=E4=BC=98=E5=8C=96=E9=A1=B9=20#5053=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0project=20routerTag=E6=A0=A1=E9=AA=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fitzcao --- .../devops/project/api/service/ServiceProjectTagResource.kt | 5 +++-- .../devops/project/service/ProjectRouteTagService.kt | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt index 75db09092b8..bd6bd8cb65b 100644 --- a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt +++ b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt @@ -36,6 +36,7 @@ import javax.ws.rs.Consumes import javax.ws.rs.GET import javax.ws.rs.HeaderParam import javax.ws.rs.Path +import javax.ws.rs.PathParam import javax.ws.rs.Produces import javax.ws.rs.core.MediaType @@ -45,11 +46,11 @@ import javax.ws.rs.core.MediaType @Consumes(MediaType.APPLICATION_JSON) interface ServiceProjectTagResource { @GET - @Path("/checkProject/router") + @Path("/checkProject/{projectId}/router") @ApiOperation("判断项目指向是否一致") fun checkProjectRouter( @ApiParam("项目id", required = true) - @HeaderParam(AUTH_HEADER_PROJECT_ID) + @PathParam("projectId") projectId: String ): Result } diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectRouteTagService.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectRouteTagService.kt index afc5341e40f..d1932e176a5 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectRouteTagService.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectRouteTagService.kt @@ -38,12 +38,16 @@ class ProjectRouteTagService @Autowired constructor( @Value("\${spring.cloud.consul.discovery.tags:#{null}}") private val tag: String? = null + @Value("\${prod.tag:#{null}}") + private val prodTag: String? = null + // 判断当前项目流量与当前集群匹配 fun checkProjectTag(projectId: String): Boolean { val routerTag = projectService.getByEnglishName(projectId)?.routerTag ?: return false // 默认集群是不会有routerTag的信息 if (routerTag.isNullOrEmpty()) { - return true + // 只有默认集群在routerTag为空的时候才返回true + return tag == prodTag } return tag == routerTag } From 156b94a4b4d742054d4e18b133e7c4ea31709259 Mon Sep 17 00:00:00 2001 From: fitzcao Date: Wed, 8 Sep 2021 19:34:17 +0800 Subject: [PATCH 070/120] =?UTF-8?q?feat:=20=E6=9D=83=E9=99=90=E4=B8=AD?= =?UTF-8?q?=E5=BF=83V3=E4=BC=98=E5=8C=96=E9=A1=B9=20#5053=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0project=20routerTag=E6=A0=A1=E9=AA=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fitzcao --- .../devops/project/api/service/ServiceProjectTagResource.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt index bd6bd8cb65b..cab8e3a6fd0 100644 --- a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt +++ b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/service/ServiceProjectTagResource.kt @@ -27,14 +27,12 @@ package com.tencent.devops.project.api.service -import com.tencent.devops.common.api.auth.AUTH_HEADER_PROJECT_ID import com.tencent.devops.project.pojo.Result import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation import io.swagger.annotations.ApiParam import javax.ws.rs.Consumes import javax.ws.rs.GET -import javax.ws.rs.HeaderParam import javax.ws.rs.Path import javax.ws.rs.PathParam import javax.ws.rs.Produces From 7798e8f2a32c7a55136e17487cab3c16927e7187 Mon Sep 17 00:00:00 2001 From: vhwweng <1010382269@qq.com> Date: Wed, 8 Sep 2021 20:27:57 +0800 Subject: [PATCH 071/120] =?UTF-8?q?fix:=20=E4=BA=BA=E5=B7=A5=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=8F=92=E4=BB=B6=EF=BC=8C=E5=A4=8D=E9=80=89=E6=A1=86?= =?UTF-8?q?=E6=97=A0=E9=BB=98=E8=AE=A4=E5=80=BC=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=20issue=20#5126?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/AtomFormComponent/DefineParam/show.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/devops-pipeline/src/components/AtomFormComponent/DefineParam/show.vue b/src/frontend/devops-pipeline/src/components/AtomFormComponent/DefineParam/show.vue index 4cf5111f1d6..05b60ae7ccb 100644 --- a/src/frontend/devops-pipeline/src/components/AtomFormComponent/DefineParam/show.vue +++ b/src/frontend/devops-pipeline/src/components/AtomFormComponent/DefineParam/show.vue @@ -127,7 +127,7 @@ if (isMultipleParam(valueType)) { const isString = typeof value === 'string' const isArray = Array.isArray(value) - return isString ? (value.length ? (value).split(',') : []) : (isArray ? value : []) + return isString ? (value.split(',').filter(i => i.trim() !== '')) : (isArray ? value : []) } return value }, From 515b853c15fd9e4e6177c3ce6c5feea235a68d69 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 10:03:07 +0800 Subject: [PATCH 072/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/common/pipeline/enums/BuildStatus.kt | 3 ++- .../command/stage/impl/CheckPauseReviewStageCmd.kt | 5 ++++- .../stage/impl/UpdateStateForStageCmdFinally.kt | 11 +++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/enums/BuildStatus.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/enums/BuildStatus.kt index 00ef2ef768a..6ae5a82c37a 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/enums/BuildStatus.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/enums/BuildStatus.kt @@ -57,13 +57,14 @@ enum class BuildStatus(val statusName: String, val visible: Boolean) { STAGE_SUCCESS("阶段性完成", true), // 22 当Stage人工审核取消运行时,成功(Stage/Pipeline最终态) QUOTA_FAILED("配额不够失败", true), // 23 失败 (未使用) DEPENDENT_WAITING("依赖等待", true), // 24 依赖等待 等待依赖的job完成才会进入准备环境(Job中间态) + QUALITY_CHECK_PASS("质量红线检查通过", true), // 25 质量红线检查通过 UNKNOWN("未知状态", false); // 99 fun isFinish(): Boolean = isFailure() || isSuccess() || isCancel() fun isFailure(): Boolean = this == FAILED || isPassiveStop() || isTimeout() || this == QUOTA_FAILED - fun isSuccess(): Boolean = this == SUCCEED || this == SKIP || this == REVIEW_PROCESSED + fun isSuccess(): Boolean = this == SUCCEED || this == SKIP || this == REVIEW_PROCESSED || this == QUALITY_CHECK_PASS fun isCancel(): Boolean = this == CANCELED diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index 9573ae996c0..e7ce29ab4f5 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -70,7 +70,10 @@ class CheckPauseReviewStageCmd( } else if (commandContext.buildStatus.isReadyToRun()) { // 质量红线 - if (!pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { + if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { + LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") + commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_PASS.name + } else { // #4732 优先判断是否能通过质量红线检查 LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_FAILED|${event.stageId}") commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_FAIL.name diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index 9176e3fa653..251bbd710ba 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -131,15 +131,18 @@ class UpdateStateForStageCmdFinally( } // #5019 在结束阶段做stage准出判断 - if (!pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { - + if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { + LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") + commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_PASS.name + } else { commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_FAIL.name commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL commandContext.latestSummary = "s(${stage.stageId}) failed with QUALITY_CHECK_OUT" pipelineStageService.checkQualityFailStage(userId = event.userId, buildStage = commandContext.stage) - return finishBuild(commandContext = commandContext) - } else if (nextStage != null) { + } + + if (nextStage != null) { LOG.info("ENGINE|${event.buildId}|${event.source}|NEXT_STAGE|${event.stageId}|gotoFinal=$gotoFinal|" + "next_s(${nextStage.stageId})|e=${stage.executeCount}|summary=${commandContext.latestSummary}") event.sendNextStage(source = "From_s(${stage.stageId})", stageId = nextStage.stageId) From 151d6caa36d69ecb5d33c6ed49eb508530a73653 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 10:05:16 +0800 Subject: [PATCH 073/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/service/PipelineStageService.kt | 2 +- .../control/command/stage/impl/CheckPauseReviewStageCmd.kt | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt index 4f81e80f4ac..7a7fe9cf558 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt @@ -295,7 +295,7 @@ class PipelineStageService @Autowired constructor( action = ManualReviewAction.ABORT, suggest = if (timeout == true) "TIMEOUT" else reviewRequest?.suggest ) - // TODO 暂时只处理准入逻辑,后续和checkOut保持逻辑一致 + // 5019 暂时只有准入有审核逻辑,准出待产品规划 checkIn?.status = BuildStatus.REVIEW_ABORT.name stageBuildDetailService.stageCancel( buildId = buildId, stageId = stageId, controlOption = controlOption!!, diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index e7ce29ab4f5..ec7dc44c152 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -139,9 +139,7 @@ class CheckPauseReviewStageCmd( if (event.source == BS_MANUAL_START_STAGE || stage.checkIn?.manualTrigger != true) { return false } - // TODO 下次发布去掉对triggered的判断 - return stage.checkIn?.groupToReview() != null || - stage.controlOption?.stageControlOption?.triggered != true + return stage.checkIn?.groupToReview() != null } companion object { From ca3a11e14ef07807c7f080e1cff326893822819d Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 10:08:04 +0800 Subject: [PATCH 074/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/common/pipeline/container/Stage.kt | 9 ++++----- .../process/service/builds/PipelineBuildFacadeService.kt | 3 --- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/container/Stage.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/container/Stage.kt index da574c7e4e5..7796e7a39a6 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/container/Stage.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/container/Stage.kt @@ -77,10 +77,9 @@ data class Stage( if (originControlOption.manualTrigger == true) { checkIn = StagePauseCheck.convertControlOption(originControlOption) } - // TODO 在下一次发布中增加抹除旧数据逻辑 -// stageControlOption?.triggerUsers = null -// stageControlOption?.triggered = null -// stageControlOption?.reviewParams = null -// stageControlOption?.reviewDesc = null + stageControlOption?.triggerUsers = null + stageControlOption?.triggered = null + stageControlOption?.reviewParams = null + stageControlOption?.reviewDesc = null } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index d1c05edf3f1..f0e1818b251 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -846,9 +846,6 @@ class PipelineBuildFacadeService( reviewRequest = reviewRequest ) } else { - // TODO 暂时兼容前端显示的变量刷新,下次发版去掉 - buildStage.controlOption!!.stageControlOption.reviewParams = reviewRequest?.reviewParams - buildStage.controlOption!!.stageControlOption.triggered = true pipelineStageService.startStage( userId = userId, buildStage = buildStage, From 05dfbf30a8dc7eb4a8f6a7a0e3e21be5ea91c126 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 11:05:06 +0800 Subject: [PATCH 075/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/command/stage/impl/UpdateStateForStageCmdFinally.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index 251bbd710ba..21156129477 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -133,7 +133,7 @@ class UpdateStateForStageCmdFinally( // #5019 在结束阶段做stage准出判断 if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") - commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_PASS.name + commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_PASS.name } else { commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_FAIL.name commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL From 08dbc508143fc3d9443b388e8b7611deec2d98fb Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 11:09:31 +0800 Subject: [PATCH 076/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/stage/impl/CheckPauseReviewStageCmd.kt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index ec7dc44c152..5040a5f8ea4 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -88,15 +88,6 @@ class CheckPauseReviewStageCmd( // #3742 进入暂停状态则刷新完状态后直接返回,等待手动触发 LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_PAUSE|${event.stageId}") - // TODO 避免前端显示未替换的审核信息,将老数据也做变量替换,下一版去掉 - val triggerUsers = stage.controlOption?.stageControlOption?.triggerUsers?.joinToString(",") ?: "" - val realUsers = EnvUtils.parseEnv(triggerUsers, commandContext.variables).split(",").toList() - stage.controlOption!!.stageControlOption.triggerUsers = realUsers - var reviewDesc = stage.controlOption!!.stageControlOption.reviewDesc - reviewDesc = EnvUtils.parseEnv(reviewDesc, commandContext.variables) - stage.controlOption!!.stageControlOption.reviewDesc = reviewDesc - // --- - stage.checkIn?.parseReviewVariables(commandContext.variables) pipelineStageService.pauseStageNotify( userId = event.userId, From 1950e6d15081bb02e6d8c474929f3289f5a2f175 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 11:18:09 +0800 Subject: [PATCH 077/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/command/stage/impl/CheckPauseReviewStageCmd.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index 5040a5f8ea4..73a92a243ee 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -27,7 +27,6 @@ package com.tencent.devops.process.engine.control.command.stage.impl -import com.tencent.devops.common.api.util.EnvUtils import com.tencent.devops.common.pipeline.enums.BuildStatus import com.tencent.devops.process.engine.common.BS_MANUAL_START_STAGE import com.tencent.devops.process.engine.control.command.CmdFlowState From fd0750b7ec9aef1be61b7d7528a0436d66f156fe Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 11:21:35 +0800 Subject: [PATCH 078/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/common/pipeline/container/Stage.kt | 2 -- .../devops/process/engine/service/PipelineRuntimeService.kt | 4 ---- .../process/engine/service/detail/StageBuildDetailService.kt | 4 ---- 3 files changed, 10 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/container/Stage.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/container/Stage.kt index 7796e7a39a6..4b5b3e9902c 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/container/Stage.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/container/Stage.kt @@ -44,8 +44,6 @@ data class Stage( var tag: List? = null, @ApiModelProperty("阶段状态", required = false, hidden = true) var status: String? = null, - @ApiModelProperty("阶段手动审核状态", required = false, hidden = true) - var reviewStatus: String? = null, @ApiModelProperty("阶段启动时间", required = false, hidden = true) var startEpoch: Long? = null, @ApiModelProperty("容器运行时间", required = false, hidden = true) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt index 338ad51b7cb..108624bae28 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt @@ -1062,10 +1062,6 @@ class PipelineRuntimeService @Autowired constructor( // TODO 只在第一次启动时刷新为QUEUE,后续只需保留兼容数据刷新 stage.refreshReviewOption(true) - if (stage.checkIn?.manualTrigger == true && - stage.checkIn?.groupToReview() != null) { - stage.reviewStatus = BuildStatus.QUEUE.name - } if (lastTimeBuildStageRecords.isNotEmpty()) { if (needUpdateStage) { diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt index fe7561bac95..43bdd80fafa 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt @@ -132,7 +132,6 @@ class StageBuildDetailService( if (stage.id == stageId) { update = true stage.status = BuildStatus.PAUSE.name - stage.reviewStatus = BuildStatus.REVIEWING.name stage.stageControlOption = controlOption.stageControlOption stage.startEpoch = System.currentTimeMillis() stage.checkIn = checkIn @@ -165,7 +164,6 @@ class StageBuildDetailService( if (stage.id == stageId) { update = true stage.status = "" - stage.reviewStatus = BuildStatus.REVIEW_ABORT.name stage.stageControlOption = controlOption.stageControlOption stage.checkIn = checkIn stage.checkOut = checkOut @@ -195,7 +193,6 @@ class StageBuildDetailService( override fun onFindStage(stage: Stage, model: Model): Traverse { if (stage.id == stageId) { update = true - stage.reviewStatus = BuildStatus.QUALITY_CHECK_FAIL.name stage.stageControlOption = controlOption.stageControlOption stage.checkIn = checkIn stage.checkOut = checkOut @@ -256,7 +253,6 @@ class StageBuildDetailService( if (stage.id == stageId) { update = true stage.status = BuildStatus.QUEUE.name - stage.reviewStatus = BuildStatus.REVIEW_PROCESSED.name stage.stageControlOption = controlOption.stageControlOption stage.checkIn = checkIn stage.checkOut = checkOut From d0fbf0234fd3f19a6a8448a2e5c17741132493e2 Mon Sep 17 00:00:00 2001 From: mingshewhe Date: Fri, 10 Sep 2021 11:34:29 +0800 Subject: [PATCH 079/120] =?UTF-8?q?feat:=20bash=E6=8F=92=E4=BB=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0XDG=5FCONFIG=5FHOME=E7=8E=AF=E5=A2=83=E5=8F=98?= =?UTF-8?q?=E9=87=8F-revert=20#4812?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../worker/common/task/script/ScriptTask.kt | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt index b66861b7ce9..35ee7f4aa47 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt @@ -27,16 +27,16 @@ package com.tencent.devops.worker.common.task.script +import com.tencent.devops.common.api.exception.TaskExecuteException +import com.tencent.devops.common.api.pojo.ErrorCode +import com.tencent.devops.common.api.pojo.ErrorType import com.tencent.devops.common.pipeline.pojo.element.agent.LinuxScriptElement import com.tencent.devops.common.pipeline.pojo.element.agent.WindowsScriptElement -import com.tencent.devops.common.api.pojo.ErrorCode import com.tencent.devops.process.pojo.BuildTask import com.tencent.devops.process.pojo.BuildVariables -import com.tencent.devops.common.api.pojo.ErrorType import com.tencent.devops.store.pojo.app.BuildEnv import com.tencent.devops.worker.common.api.ApiFactory import com.tencent.devops.worker.common.api.quality.QualityGatewaySDKApi -import com.tencent.devops.common.api.exception.TaskExecuteException import com.tencent.devops.worker.common.env.AgentEnv import com.tencent.devops.worker.common.logger.LoggerService import com.tencent.devops.worker.common.task.ITask @@ -45,7 +45,6 @@ import com.tencent.devops.worker.common.utils.ArchiveUtils import org.slf4j.LoggerFactory import java.io.File import java.net.URLDecoder -import java.nio.file.Paths /** * 构建脚本任务 @@ -79,13 +78,11 @@ open class ScriptTask : ITask() { ScriptEnvUtils.cleanEnv(buildId, workspace) ScriptEnvUtils.cleanContext(buildId, workspace) - var variables = if (buildTask.buildVariable == null) { + val variables = if (buildTask.buildVariable == null) { runtimeVariables } else { runtimeVariables.plus(buildTask.buildVariable!!) } - // #4812 提供给git插件使用 - variables = variables.plus(XDG_CONFIG_HOME to getXdgConfigHomePath(buildVariables.pipelineId)) try { command.execute( @@ -162,20 +159,7 @@ open class ScriptTask : ITask() { } } - private fun getXdgConfigHomePath(pipelineId: String): String { - try { - return System.getenv(XDG_CONFIG_HOME) ?: Paths.get( - System.getProperty("user.home"), - ".checkout", pipelineId - ).normalize().toString() - } catch (ignore: Exception) { - logger.error("get xdg_config_home error", ignore) - } - return "" - } - companion object { private val logger = LoggerFactory.getLogger(ScriptTask::class.java) - private const val XDG_CONFIG_HOME = "XDG_CONFIG_HOME" } } From 8df51c1d778215c60ea4dae26d02444980846019 Mon Sep 17 00:00:00 2001 From: ddlin0719 Date: Fri, 10 Sep 2021 15:15:47 +0800 Subject: [PATCH 080/120] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9C=BA=E5=88=B6=E5=8F=AF=E9=85=8D=E7=BD=AE=20#5091?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/MarketBuildAtomElementBizPlugin.kt | 7 +- .../MarketBuildLessAtomElementBizPlugin.kt | 7 +- .../engine/atom/plugin/MarketBuildUtils.kt | 69 ++++++++++++++----- 3 files changed, 55 insertions(+), 28 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt index 10e884c2043..c4e1121cc24 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt @@ -31,14 +31,11 @@ import com.tencent.devops.common.pipeline.container.Container import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.common.pipeline.pojo.element.atom.BeforeDeleteParam import com.tencent.devops.common.pipeline.pojo.element.market.MarketBuildAtomElement -import com.tencent.devops.plugin.codecc.CodeccApi import com.tencent.devops.process.plugin.ElementBizPlugin import com.tencent.devops.process.plugin.annotation.ElementBiz @ElementBiz -class MarketBuildAtomElementBizPlugin constructor( - private val codeccApi: CodeccApi -) : ElementBizPlugin { +class MarketBuildAtomElementBizPlugin constructor() : ElementBizPlugin { override fun elementClass(): Class { return MarketBuildAtomElement::class.java @@ -57,7 +54,7 @@ class MarketBuildAtomElementBizPlugin constructor( override fun beforeDelete(element: MarketBuildAtomElement, param: BeforeDeleteParam) { val inputMap = element.data["input"] as Map - MarketBuildUtils.beforeDelete(inputMap, element.getAtomCode(), param, codeccApi) + MarketBuildUtils.beforeDelete(inputMap, element.getAtomCode(), element.version, param) } override fun check(element: MarketBuildAtomElement, appearedCnt: Int) = Unit diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt index 60c5a3137ad..b2252a0507b 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt @@ -31,14 +31,11 @@ import com.tencent.devops.common.pipeline.container.Container import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.common.pipeline.pojo.element.atom.BeforeDeleteParam import com.tencent.devops.common.pipeline.pojo.element.market.MarketBuildLessAtomElement -import com.tencent.devops.plugin.codecc.CodeccApi import com.tencent.devops.process.plugin.ElementBizPlugin import com.tencent.devops.process.plugin.annotation.ElementBiz @ElementBiz -class MarketBuildLessAtomElementBizPlugin constructor( - private val codeccApi: CodeccApi -) : ElementBizPlugin { +class MarketBuildLessAtomElementBizPlugin constructor() : ElementBizPlugin { override fun elementClass(): Class { return MarketBuildLessAtomElement::class.java @@ -57,7 +54,7 @@ class MarketBuildLessAtomElementBizPlugin constructor( override fun beforeDelete(element: MarketBuildLessAtomElement, param: BeforeDeleteParam) { val inputMap = element.data["input"] as Map - MarketBuildUtils.beforeDelete(inputMap, element.getAtomCode(), param, codeccApi) + MarketBuildUtils.beforeDelete(inputMap, element.getAtomCode(), element.version, param) } override fun check(element: MarketBuildLessAtomElement, appearedCnt: Int) = Unit diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt index 618be120065..19a677ff499 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt @@ -27,11 +27,15 @@ package com.tencent.devops.process.engine.atom.plugin +import com.google.common.cache.CacheBuilder +import com.google.common.cache.CacheLoader import com.tencent.devops.common.api.util.OkhttpUtils +import com.tencent.devops.common.client.Client import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.common.pipeline.pojo.element.atom.BeforeDeleteParam -import com.tencent.devops.plugin.codecc.CodeccApi -import com.tencent.devops.plugin.codecc.CodeccUtils +import com.tencent.devops.common.service.utils.SpringContextUtil +import com.tencent.devops.store.api.atom.ServiceAtomResource +import com.tencent.devops.store.pojo.atom.PipelineAtom import okhttp3.Request import okhttp3.RequestBody import org.slf4j.LoggerFactory @@ -51,6 +55,19 @@ object MarketBuildUtils { private val logger = LoggerFactory.getLogger(MarketBuildUtils::class.java) + private val atomCache = CacheBuilder.newBuilder() + .maximumSize(1000) + .expireAfterWrite(10, TimeUnit.MINUTES) + .build(object : CacheLoader() { + override fun load(atomCodeAndVersion: String): PipelineAtom? { + val client = SpringContextUtil.getBean(Client::class.java) + val arr = atomCodeAndVersion.split("|") + val atomCode = arr[0] + val atomVersion = arr[1] + return client.get(ServiceAtomResource::class).getAtomVersionInfo(atomCode, atomVersion).data + } + }) + @Suppress("ALL") private val marketBuildExecutorService = ThreadPoolExecutor( Runtime.getRuntime().availableProcessors(), @@ -60,24 +77,28 @@ object MarketBuildUtils { ArrayBlockingQueue(16000) ) - fun beforeDelete(inputMap: Map, atomCode: String, param: BeforeDeleteParam, codeccApi: CodeccApi) { - logger.info("start to do before delete: $inputMap, $atomCode") + fun beforeDelete(inputMap: Map, atomCode: String, atomVersion: String, param: BeforeDeleteParam) { + logger.info("start to do before delete: $inputMap, $atomCode, $atomVersion") marketBuildExecutorService.execute { val bkAtomHookUrl = inputMap.getOrDefault( BK_ATOM_HOOK_URL, - getDefaultHookUrl(atomCode = atomCode, codeccApi = codeccApi, channelCode = param.channelCode) - ) as String - val bkAtomHookUrlMethod = inputMap.getOrDefault( - key = BK_ATOM_HOOK_URL_METHOD, - defaultValue = getDefaultHookMethod(atomCode) + getDefaultHookUrl(atomCode = atomCode, atomVersion = atomVersion, channelCode = param.channelCode) ) as String - val bkAtomHookBody = inputMap.getOrDefault(BK_ATOM_HOOK_URL_BODY, "") as String if (bkAtomHookUrl.isBlank()) { logger.info("bk atom hook url is blank: $atomCode") return@execute } + val bkAtomHookUrlMethod = inputMap.getOrDefault( + key = BK_ATOM_HOOK_URL_METHOD, + defaultValue = getDefaultHookMethod(atomCode, atomVersion) + ) as String + val bkAtomHookBody = inputMap.getOrDefault( + BK_ATOM_HOOK_URL_BODY, + getDefaultHookBody(atomCode, atomVersion) + ) as String + doHttp(bkAtomHookUrl, bkAtomHookUrlMethod, bkAtomHookBody, param, inputMap) } } @@ -119,17 +140,29 @@ object MarketBuildUtils { } @Suppress("ALL") - private fun getDefaultHookUrl(atomCode: String, codeccApi: CodeccApi, channelCode: ChannelCode): String { - if (!CodeccUtils.isCodeccNewAtom(atomCode)) return "" + private fun getDefaultHookUrl(atomCode: String, atomVersion: String, channelCode: ChannelCode): String { if (channelCode != ChannelCode.BS) return "" - return codeccApi.getExecUrl( - path = "/ms/task/api/service/task/pipeline/stop?userName={userId}&pipelineId={$PIPELINE_ID}" - ) + val bkAtomHookUrlItem = atomCache.get("$atomCode|$atomVersion")?.props?.get(BK_ATOM_HOOK_URL) + if (bkAtomHookUrlItem != null && bkAtomHookUrlItem is Map<*, *>) { + return bkAtomHookUrlItem["default"]?.toString() ?: "" + } + return "" } - private fun getDefaultHookMethod(atomCode: String): String { - if (!CodeccUtils.isCodeccNewAtom(atomCode)) return "GET" - return "DELETE" + private fun getDefaultHookMethod(atomCode: String, atomVersion: String): String { + val bkAtomHookUrlItem = atomCache.get("$atomCode|$atomVersion")?.props?.get(BK_ATOM_HOOK_URL_METHOD) + if (bkAtomHookUrlItem != null && bkAtomHookUrlItem is Map<*, *>) { + return bkAtomHookUrlItem["default"]?.toString() ?: "GET" + } + return "GET" + } + + private fun getDefaultHookBody(atomCode: String, atomVersion: String): String { + val bkAtomHookUrlItem = atomCache.get("$atomCode|$atomVersion")?.props?.get(BK_ATOM_HOOK_URL_BODY) + if (bkAtomHookUrlItem != null && bkAtomHookUrlItem is Map<*, *>) { + return bkAtomHookUrlItem["default"]?.toString() ?: "" + } + return "" } private fun resolveParam(str: String, param: BeforeDeleteParam, inputMap: Map): String { From 56a2d5ae4bcd4d97b94987ef2888fc9d08233b11 Mon Sep 17 00:00:00 2001 From: ddlin0719 Date: Fri, 10 Sep 2021 15:22:42 +0800 Subject: [PATCH 081/120] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9C=BA=E5=88=B6=E5=8F=AF=E9=85=8D=E7=BD=AE=20#5091?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt | 2 +- .../engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt index c4e1121cc24..125a0b021b1 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildAtomElementBizPlugin.kt @@ -35,7 +35,7 @@ import com.tencent.devops.process.plugin.ElementBizPlugin import com.tencent.devops.process.plugin.annotation.ElementBiz @ElementBiz -class MarketBuildAtomElementBizPlugin constructor() : ElementBizPlugin { +class MarketBuildAtomElementBizPlugin : ElementBizPlugin { override fun elementClass(): Class { return MarketBuildAtomElement::class.java diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt index b2252a0507b..c4348f35cbf 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildLessAtomElementBizPlugin.kt @@ -35,7 +35,7 @@ import com.tencent.devops.process.plugin.ElementBizPlugin import com.tencent.devops.process.plugin.annotation.ElementBiz @ElementBiz -class MarketBuildLessAtomElementBizPlugin constructor() : ElementBizPlugin { +class MarketBuildLessAtomElementBizPlugin : ElementBizPlugin { override fun elementClass(): Class { return MarketBuildLessAtomElement::class.java From 28bee3c4dfe6ef8c1f22637e01c54dfd4de68e94 Mon Sep 17 00:00:00 2001 From: ddlin0719 Date: Fri, 10 Sep 2021 16:06:35 +0800 Subject: [PATCH 082/120] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9C=BA=E5=88=B6=E5=8F=AF=E9=85=8D=E7=BD=AE=20#5091?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/atom/plugin/MarketBuildUtils.kt | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt index 19a677ff499..d4fa2469300 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt @@ -45,6 +45,7 @@ import java.util.concurrent.TimeUnit import javax.ws.rs.HttpMethod object MarketBuildUtils { + private const val INPUT_PARAM = "input" private const val BK_ATOM_HOOK_URL = "bk_atom_del_hook_url" private const val BK_ATOM_HOOK_URL_METHOD = "bk_atom_del_hook_url_method" private const val BK_ATOM_HOOK_URL_BODY = "bk_atom_del_hook_url_body" @@ -86,7 +87,7 @@ object MarketBuildUtils { ) as String if (bkAtomHookUrl.isBlank()) { - logger.info("bk atom hook url is blank: $atomCode") + logger.info("bk atom hook url is blank: $atomCode, $atomVersion") return@execute } @@ -142,7 +143,11 @@ object MarketBuildUtils { @Suppress("ALL") private fun getDefaultHookUrl(atomCode: String, atomVersion: String, channelCode: ChannelCode): String { if (channelCode != ChannelCode.BS) return "" - val bkAtomHookUrlItem = atomCache.get("$atomCode|$atomVersion")?.props?.get(BK_ATOM_HOOK_URL) + val inputMap = atomCache.get("$atomCode|$atomVersion")?.props?.get(INPUT_PARAM) + if (inputMap == null || inputMap !is Map<*, *>) { + return "" + } + val bkAtomHookUrlItem = inputMap[BK_ATOM_HOOK_URL] if (bkAtomHookUrlItem != null && bkAtomHookUrlItem is Map<*, *>) { return bkAtomHookUrlItem["default"]?.toString() ?: "" } @@ -150,7 +155,11 @@ object MarketBuildUtils { } private fun getDefaultHookMethod(atomCode: String, atomVersion: String): String { - val bkAtomHookUrlItem = atomCache.get("$atomCode|$atomVersion")?.props?.get(BK_ATOM_HOOK_URL_METHOD) + val inputMap = atomCache.get("$atomCode|$atomVersion")?.props?.get(INPUT_PARAM) + if (inputMap == null || inputMap !is Map<*, *>) { + return "" + } + val bkAtomHookUrlItem = inputMap[BK_ATOM_HOOK_URL_METHOD] if (bkAtomHookUrlItem != null && bkAtomHookUrlItem is Map<*, *>) { return bkAtomHookUrlItem["default"]?.toString() ?: "GET" } @@ -158,7 +167,11 @@ object MarketBuildUtils { } private fun getDefaultHookBody(atomCode: String, atomVersion: String): String { - val bkAtomHookUrlItem = atomCache.get("$atomCode|$atomVersion")?.props?.get(BK_ATOM_HOOK_URL_BODY) + val inputMap = atomCache.get("$atomCode|$atomVersion")?.props?.get(INPUT_PARAM) + if (inputMap == null || inputMap !is Map<*, *>) { + return "" + } + val bkAtomHookUrlItem = inputMap[BK_ATOM_HOOK_URL_BODY] if (bkAtomHookUrlItem != null && bkAtomHookUrlItem is Map<*, *>) { return bkAtomHookUrlItem["default"]?.toString() ?: "" } From 925d4cb08069849297a35d88a6f0d7236962ef19 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 16:14:39 +0800 Subject: [PATCH 083/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/service/PipelineStageService.kt | 32 ++++++++++++++++++- .../service/detail/StageBuildDetailService.kt | 5 +-- .../stage/impl/CheckPauseReviewStageCmd.kt | 1 + .../impl/UpdateStateForStageCmdFinally.kt | 1 + 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt index 7a7fe9cf558..7a1e53aba80 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt @@ -153,7 +153,7 @@ class PipelineStageService @Autowired constructor( fun checkQualityFailStage(userId: String, buildStage: PipelineBuildStage) { with(buildStage) { - val allStageStatus = stageBuildDetailService.stageCheckQualityFail( + val allStageStatus = stageBuildDetailService.stageCheckQuality( buildId = buildId, stageId = stageId, controlOption = controlOption!!, @@ -181,6 +181,36 @@ class PipelineStageService @Autowired constructor( } } + fun checkQualityPassStage(userId: String, buildStage: PipelineBuildStage) { + with(buildStage) { + val allStageStatus = stageBuildDetailService.stageCheckQuality( + buildId = buildId, + stageId = stageId, + controlOption = controlOption!!, + checkIn = checkIn, + checkOut = checkOut + ) + dslContext.transaction { configuration -> + val context = DSL.using(configuration) + pipelineBuildStageDao.updateStatus( + dslContext = context, buildId = buildId, + stageId = stageId, controlOption = controlOption!!, + buildStatus = BuildStatus.QUALITY_CHECK_PASS, + checkIn = checkIn, checkOut = checkOut + ) + pipelineBuildDao.updateBuildStageStatus( + dslContext = context, buildId = buildId, stageStatus = allStageStatus + ) + } + pipelineEventDispatcher.dispatch( + PipelineBuildWebSocketPushEvent( + source = "checkQualityPassStage", projectId = projectId, pipelineId = pipelineId, + userId = userId, buildId = buildId, refreshTypes = RefreshType.HISTORY.binary + ) + ) + } + } + fun pauseStage(buildStage: PipelineBuildStage) { with(buildStage) { checkIn?.status = BuildStatus.REVIEWING.name diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt index 43bdd80fafa..a95e30ef027 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt @@ -178,14 +178,15 @@ class StageBuildDetailService( }, BuildStatus.STAGE_SUCCESS) } - fun stageCheckQualityFail( + fun stageCheckQuality( buildId: String, stageId: String, controlOption: PipelineBuildStageControlOption, checkIn: StagePauseCheck?, checkOut: StagePauseCheck? ): List { - logger.info("[$buildId]|stage_cancel|stageId=$stageId") + logger.info("[$buildId]|stage_check_quality|stageId=$stageId" + + "|checkIn=$checkIn|checkOut=$checkOut") var allStageStatus: List? = null update(buildId, object : ModelInterface { var update = false diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index 73a92a243ee..ea4aa55b127 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -72,6 +72,7 @@ class CheckPauseReviewStageCmd( if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_PASS.name + pipelineStageService.checkQualityPassStage(event.userId, commandContext.stage) } else { // #4732 优先判断是否能通过质量红线检查 LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_FAILED|${event.stageId}") diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index 21156129477..2ae64a6a450 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -134,6 +134,7 @@ class UpdateStateForStageCmdFinally( if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_PASS.name + pipelineStageService.checkQualityPassStage(userId = event.userId, buildStage = commandContext.stage) } else { commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_FAIL.name commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL From 904bb09ccfc2512395f4c1efe1d8ce0ba9460f12 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 16:59:41 +0800 Subject: [PATCH 084/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/service/PipelineStageService.kt | 14 ++++++-------- .../service/detail/StageBuildDetailService.kt | 6 ++++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt index 7a1e53aba80..5b92d1adc38 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt @@ -154,11 +154,10 @@ class PipelineStageService @Autowired constructor( fun checkQualityFailStage(userId: String, buildStage: PipelineBuildStage) { with(buildStage) { val allStageStatus = stageBuildDetailService.stageCheckQuality( - buildId = buildId, - stageId = stageId, + buildId = buildId, stageId = stageId, controlOption = controlOption!!, - checkIn = checkIn, - checkOut = checkOut + buildStatus = BuildStatus.FAILED, + checkIn = checkIn, checkOut = checkOut ) dslContext.transaction { configuration -> val context = DSL.using(configuration) @@ -184,11 +183,10 @@ class PipelineStageService @Autowired constructor( fun checkQualityPassStage(userId: String, buildStage: PipelineBuildStage) { with(buildStage) { val allStageStatus = stageBuildDetailService.stageCheckQuality( - buildId = buildId, - stageId = stageId, + buildId = buildId, stageId = stageId, controlOption = controlOption!!, - checkIn = checkIn, - checkOut = checkOut + buildStatus = BuildStatus.RUNNING, + checkIn = checkIn, checkOut = checkOut ) dslContext.transaction { configuration -> val context = DSL.using(configuration) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt index a95e30ef027..ac84ea743ca 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt @@ -39,6 +39,7 @@ import com.tencent.devops.process.engine.pojo.PipelineBuildStageControlOption import com.tencent.devops.process.pojo.BuildStageStatus import com.tencent.devops.process.service.StageTagService import org.jooq.DSLContext +import org.omg.PortableInterceptor.SUCCESSFUL import org.springframework.stereotype.Service @Suppress("LongParameterList", "MagicNumber") @@ -182,10 +183,11 @@ class StageBuildDetailService( buildId: String, stageId: String, controlOption: PipelineBuildStageControlOption, + buildStatus: BuildStatus, checkIn: StagePauseCheck?, checkOut: StagePauseCheck? ): List { - logger.info("[$buildId]|stage_check_quality|stageId=$stageId" + + logger.info("[$buildId]|stage_check_quality|buildStatus=$buildStatus|stageId=$stageId" + "|checkIn=$checkIn|checkOut=$checkOut") var allStageStatus: List? = null update(buildId, object : ModelInterface { @@ -206,7 +208,7 @@ class StageBuildDetailService( override fun needUpdate(): Boolean { return update } - }, BuildStatus.FAILED) + }, buildStatus) return allStageStatus ?: emptyList() } From 480d1f256a713d802ae39316a45b068d0f414174 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 18:35:45 +0800 Subject: [PATCH 085/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/service/detail/StageBuildDetailService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt index ac84ea743ca..ad926eea93a 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/detail/StageBuildDetailService.kt @@ -39,7 +39,6 @@ import com.tencent.devops.process.engine.pojo.PipelineBuildStageControlOption import com.tencent.devops.process.pojo.BuildStageStatus import com.tencent.devops.process.service.StageTagService import org.jooq.DSLContext -import org.omg.PortableInterceptor.SUCCESSFUL import org.springframework.stereotype.Service @Suppress("LongParameterList", "MagicNumber") From 28394ffbb29ef5364dbe90270fa1fab970a3c87a Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 19:24:05 +0800 Subject: [PATCH 086/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/stage/impl/CheckPauseReviewStageCmd.kt | 8 +++++++- .../command/stage/impl/UpdateStateForStageCmdFinally.kt | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index ea4aa55b127..6c7f510eb8d 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -69,7 +69,9 @@ class CheckPauseReviewStageCmd( } else if (commandContext.buildStatus.isReadyToRun()) { // 质量红线 - if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { + if (stage.checkIn?.ruleIds.isNullOrEmpty()) { + LOG.info("ENGINE|${event.buildId}|${event.source}|NO_STAGE_QUALITY_CHECK_IN|${event.stageId}") + } else if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_PASS.name pipelineStageService.checkQualityPassStage(event.userId, commandContext.stage) @@ -109,6 +111,10 @@ class CheckPauseReviewStageCmd( } } + private fun stageCheckIn() { + + } + private fun saveStageReviewParams(stage: PipelineBuildStage) { val reviewVariables = mutableMapOf() // # 4531 遍历全部审核组的参数,后序覆盖前序的同名变量 diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index 2ae64a6a450..b38929366a9 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -131,7 +131,9 @@ class UpdateStateForStageCmdFinally( } // #5019 在结束阶段做stage准出判断 - if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { + if (stage.checkOut?.ruleIds.isNullOrEmpty()) { + LOG.info("ENGINE|${event.buildId}|${event.source}|NO_STAGE_QUALITY_CHECK_IN|${event.stageId}") + } else if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_PASS.name pipelineStageService.checkQualityPassStage(userId = event.userId, buildStage = commandContext.stage) From febb6954f9cf8b80b3135f08df00efc29981118e Mon Sep 17 00:00:00 2001 From: fromschen Date: Fri, 10 Sep 2021 19:32:17 +0800 Subject: [PATCH 087/120] =?UTF-8?q?chore:=20turbo=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E9=80=82=E9=85=8D=20#5038?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/bk-ci-setup.sh | 8 ++++++-- scripts/bkenv.properties | 44 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/scripts/bk-ci-setup.sh b/scripts/bk-ci-setup.sh index e81657a2b9a..728490c0781 100755 --- a/scripts/bk-ci-setup.sh +++ b/scripts/bk-ci-setup.sh @@ -27,7 +27,7 @@ LAN_IP=${LAN_IP:-$(ip route show | grep -Pom 1 "(?<=src )[0-9.]+")} BKCE_RENDER_CMD="$CTRL_DIR/bin/render_tpl" # 蓝鲸社区版的render, 需要env文件及$BK_HOME. CI_RENDER_CMD="$(dirname "$0")/render_tpl" # bk-ci里的默认读取本地的bkenv.properties文件. -GEN_DOCKER_CONF_CMD="$(dirname "$0a")/bk-ci-gen-docker-conf.sh" +GEN_DOCKER_CONF_CMD="$(dirname "$0")/bk-ci-gen-docker-conf.sh" # 批量检查变量名为空的情况. check_empty_var (){ @@ -258,7 +258,11 @@ setup_ci_dockerhost (){ setup_ci_turbo (){ local proj=$1 setup_ci__ms_common "$proj" || return 11 - render_ci quartz # 渲染 #etc#ci#thirdparty#quartz.properties + # turbo日志路径为 turbo-devops/turbo-devops.log + update_link_to_target "$MS_DIR/logs/$MS_NAME.log" "$MS_LOGS_DIR/$MS_NAME-$BK_CI_CONSUL_DISCOVERY_TAG/$MS_NAME-$BK_CI_CONSUL_DISCERY_TAG.log" || return 3 + # 需要自定义启动参数. + env_line_set "$start_env" "JAVA_OPTS" "-Dturbo.thirdparty.propdir=$BK_HOME/etc/ci/thirdparty" + render_ci quartz # 额外渲染 #etc#ci#thirdparty#quartz.properties } # 校验网关关键配置, 设置家目录, 设置启动用户或setcap? diff --git a/scripts/bkenv.properties b/scripts/bkenv.properties index c3e0b93bc35..1491c612611 100644 --- a/scripts/bkenv.properties +++ b/scripts/bkenv.properties @@ -1,4 +1,4 @@ -# ci.env template, generated at 2021-05-27 19:57:19 +# ci.env template, generated at 2021-09-09 16:40:32 ########## # 0-依赖声明 @@ -33,6 +33,10 @@ BK_REPO_HOST= BK_SSM_HOST= # BK_SSM_PORT无默认值. 无需修改. 声明依赖, 蓝鲸环境下会自动填充. 其他环境无需填写. BK_SSM_PORT= +# BK_TURBO_PRIVATE_URL默认为http://bk-turbo.service.consul. 按需修改. turbo网关 +BK_TURBO_PRIVATE_URL=http://bk-turbo.service.consul +# BK_TURBO_PUBLIC_URL默认为http://turbo.$BK_DOMAIN. 按需修改. turbo网关 +BK_TURBO_PUBLIC_URL=http://turbo.$BK_DOMAIN ########## # 1-基础配置 @@ -73,6 +77,8 @@ BK_CI_HTTP_PORT=80 BK_CI_IAM_CALLBACK_USER=bk_iam # BK_CI_IAM_ENV默认为prod. 废弃. 待清理配置文件及相关代码. BK_CI_IAM_ENV=prod +# BK_CI_IAM_WEB_URL默认为$BK_PAAS_PUBLIC_URL/o/bk_iam. 请勿修改. IAM SaaS入口url, 用于拼接权限申请页面. +BK_CI_IAM_WEB_URL=$BK_PAAS_PUBLIC_URL/o/bk_iam # BK_CI_JOB_FQDN无默认值. 废弃. 待清理配置文件及相关代码. BK_CI_JOB_FQDN= # BK_CI_JWT_RSA_PRIVATE_KEY无默认值. 按需修改. JWT RSA密钥对. 单行, 需要确保最终渲染为\n. 建议使用附带的脚本生成. @@ -253,6 +259,40 @@ BK_CI_S3_BUCKET_NAME= BK_CI_S3_ENDPOINT_URL= # BK_CI_S3_SECRET_KEY无默认值. 废弃. 待清理配置文件及相关代码. BK_CI_S3_SECRET_KEY= +# BK_CI_TURBO_CONSUL_DISCOVERY_TAG默认为$BK_CI_CONSUL_DISCOVERY_TAG. 无需修改. 需要和ci保持一致 +BK_CI_TURBO_CONSUL_DISCOVERY_TAG=$BK_CI_CONSUL_DISCOVERY_TAG +# BK_CI_TURBO_MONGODB_ADDR默认为127.0.0.1:27017. 按需修改. +BK_CI_TURBO_MONGODB_ADDR=127.0.0.1:27017 +# BK_CI_TURBO_MONGODB_DB_NAME默认为turbo_prod. 无需修改. ci-turbo主数据库. +BK_CI_TURBO_MONGODB_DB_NAME=turbo_prod +# BK_CI_TURBO_MONGODB_PASSWORD无默认值. 按需修改. +BK_CI_TURBO_MONGODB_PASSWORD= +# BK_CI_TURBO_MONGODB_USER无默认值. 按需修改. +BK_CI_TURBO_MONGODB_USER= +# BK_CI_TURBO_QUARTZ_MONGODB_ADDR默认为127.0.0.1:27017. 按需修改. +BK_CI_TURBO_QUARTZ_MONGODB_ADDR=127.0.0.1:27017 +# BK_CI_TURBO_QUARTZ_MONGODB_DB_NAME默认为turbo_quartz. 无需修改. quartz需要独立db. +BK_CI_TURBO_QUARTZ_MONGODB_DB_NAME=turbo_quartz +# BK_CI_TURBO_QUARTZ_MONGODB_PASSWORD无默认值. 按需修改. +BK_CI_TURBO_QUARTZ_MONGODB_PASSWORD= +# BK_CI_TURBO_QUARTZ_MONGODB_USER无默认值. 按需修改. +BK_CI_TURBO_QUARTZ_MONGODB_USER= +# BK_CI_TURBO_RABBITMQ_ADDR默认为$BK_CI_RABBITMQ_ADDR. 按需修改. 独立mq, 可复用ci的. +BK_CI_TURBO_RABBITMQ_ADDR=$BK_CI_RABBITMQ_ADDR +# BK_CI_TURBO_RABBITMQ_PASSWORD默认为$BK_CI_RABBITMQ_PASSWORD. 按需修改. +BK_CI_TURBO_RABBITMQ_PASSWORD=$BK_CI_RABBITMQ_PASSWORD +# BK_CI_TURBO_RABBITMQ_USER默认为$BK_CI_RABBITMQ_USER. 按需修改. +BK_CI_TURBO_RABBITMQ_USER=$BK_CI_RABBITMQ_USER +# BK_CI_TURBO_RABBITMQ_VHOST默认为$BK_CI_RABBITMQ_VHOST. 按需修改. 独立mq, 可复用ci的. +BK_CI_TURBO_RABBITMQ_VHOST=$BK_CI_RABBITMQ_VHOST +# BK_CI_TURBO_REDIS_DB默认为$BK_CI_REDIS_DB. 按需修改. +BK_CI_TURBO_REDIS_DB=$BK_CI_REDIS_DB +# BK_CI_TURBO_REDIS_HOST默认为$BK_CI_REDIS_HOST. 按需修改. 独立redis, 可复用ci的. +BK_CI_TURBO_REDIS_HOST=$BK_CI_REDIS_HOST +# BK_CI_TURBO_REDIS_PASSWORD默认为$BK_CI_REDIS_PASSWORD. 按需修改. +BK_CI_TURBO_REDIS_PASSWORD=$BK_CI_REDIS_PASSWORD +# BK_CI_TURBO_REDIS_PORT默认为$BK_CI_REDIS_PORT. 按需修改. +BK_CI_TURBO_REDIS_PORT=$BK_CI_REDIS_PORT ########## # 5-api port @@ -303,5 +343,7 @@ BK_CI_SIGN_API_PORT=21950 BK_CI_STORE_API_PORT=21918 # BK_CI_TICKET_API_PORT默认为21915. 无需修改. BK_CI_TICKET_API_PORT=21915 +# BK_CI_TURBO_API_PORT默认为21955. 无需修改. +BK_CI_TURBO_API_PORT=21955 # BK_CI_WEBSOCKET_API_PORT默认为21924. 无需修改. BK_CI_WEBSOCKET_API_PORT=21924 From f3381a772868d1c2254eeee5505ebaf899695e26 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 19:34:33 +0800 Subject: [PATCH 088/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/service/PipelineStageService.kt | 1 - .../control/command/stage/impl/CheckPauseReviewStageCmd.kt | 6 +++--- .../command/stage/impl/UpdateStateForStageCmdFinally.kt | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt index 5b92d1adc38..58fd4a54266 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt @@ -426,7 +426,6 @@ class PipelineStageService @Autowired constructor( } else { Pair(stage.checkOut, ControlPointPosition.AFTER_POSITION) } - if (check?.ruleIds.isNullOrEmpty()) return true return try { val request = BuildCheckParamsV3( projectId = event.projectId, diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index 6c7f510eb8d..1aea50e390d 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -68,9 +68,9 @@ class CheckPauseReviewStageCmd( commandContext.cmdFlowState = CmdFlowState.BREAK } else if (commandContext.buildStatus.isReadyToRun()) { - // 质量红线 - if (stage.checkIn?.ruleIds.isNullOrEmpty()) { - LOG.info("ENGINE|${event.buildId}|${event.source}|NO_STAGE_QUALITY_CHECK_IN|${event.stageId}") + // 只用第一次进入时做准入质量红线检查 + if (stage.checkIn?.ruleIds.isNullOrEmpty() && !stage.checkIn?.status.isNullOrBlank()) { + LOG.info("ENGINE|${event.buildId}|${event.source}|SKIP_QUALITY_CHECK_IN|${event.stageId}") } else if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_PASS.name diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index b38929366a9..891b0a54133 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -132,7 +132,7 @@ class UpdateStateForStageCmdFinally( // #5019 在结束阶段做stage准出判断 if (stage.checkOut?.ruleIds.isNullOrEmpty()) { - LOG.info("ENGINE|${event.buildId}|${event.source}|NO_STAGE_QUALITY_CHECK_IN|${event.stageId}") + LOG.info("ENGINE|${event.buildId}|${event.source}|SKIP_STAGE_QUALITY_CHECK_OUT|${event.stageId}") } else if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_PASS.name From f56d4e9c91066e08e115246647c46ff4e8a88271 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 19:46:38 +0800 Subject: [PATCH 089/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/command/stage/impl/CheckPauseReviewStageCmd.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index 1aea50e390d..0242e9267db 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -111,10 +111,6 @@ class CheckPauseReviewStageCmd( } } - private fun stageCheckIn() { - - } - private fun saveStageReviewParams(stage: PipelineBuildStage) { val reviewVariables = mutableMapOf() // # 4531 遍历全部审核组的参数,后序覆盖前序的同名变量 From 8b3bda106101bd0aebc14cde12d6084add644cd3 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 10 Sep 2021 20:23:38 +0800 Subject: [PATCH 090/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/service/PipelineStageService.kt | 2 +- .../control/command/stage/impl/CheckPauseReviewStageCmd.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt index 58fd4a54266..1f85d1763bc 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt @@ -446,7 +446,7 @@ class PipelineStageService @Autowired constructor( result.success } catch (ignore: Throwable) { logger.error("ENGINE|${event.buildId}|${event.source}|inOrOut=$inOrOut|" + - "STAGE_QUALITY_CHECK_OUT_ERROR|${event.stageId}", ignore) + "STAGE_QUALITY_CHECK_ERROR|${event.stageId}", ignore) false } } diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index 0242e9267db..b091e355636 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -69,7 +69,7 @@ class CheckPauseReviewStageCmd( } else if (commandContext.buildStatus.isReadyToRun()) { // 只用第一次进入时做准入质量红线检查 - if (stage.checkIn?.ruleIds.isNullOrEmpty() && !stage.checkIn?.status.isNullOrBlank()) { + if (stage.checkIn?.ruleIds.isNullOrEmpty()) { LOG.info("ENGINE|${event.buildId}|${event.source}|SKIP_QUALITY_CHECK_IN|${event.stageId}") } else if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") From f5a62b3c17a70e3177241b6fc1b86a2be603507a Mon Sep 17 00:00:00 2001 From: irwinsun Date: Fri, 10 Sep 2021 23:23:35 +0800 Subject: [PATCH 091/120] =?UTF-8?q?feat:=20=E6=9C=8D=E5=8A=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0OP=E6=8E=A5=E5=8F=A3=20#5144=20=E9=87=8D=E7=BD=AESQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sql/1001_ci_project_ddl_mysql.sql | 5 ++-- .../sql/2003_ci_process-update_v1.0_mysql.sql | 1 - .../sql/2006_ci_project-update_v1.5_mysql.sql | 27 +++++++++++++++++++ .../sql/5001_ci_project-init_dml_mysql.sql | 22 +++++++-------- 4 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 support-files/sql/2006_ci_project-update_v1.5_mysql.sql diff --git a/support-files/sql/1001_ci_project_ddl_mysql.sql b/support-files/sql/1001_ci_project_ddl_mysql.sql index c5f5fd4d798..374027db70c 100644 --- a/support-files/sql/1001_ci_project_ddl_mysql.sql +++ b/support-files/sql/1001_ci_project_ddl_mysql.sql @@ -178,8 +178,9 @@ CREATE TABLE IF NOT EXISTS `T_SERVICE` ( `weight` int(11) DEFAULT NULL, `gray_iframe_url` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `service_name` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8; + UNIQUE KEY `service_name` (`name`), + UNIQUE KEY `IDX_UNIQUE_ENGLISH_NAME` (`english_name`) +) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for T_SERVICE_TYPE diff --git a/support-files/sql/2003_ci_process-update_v1.0_mysql.sql b/support-files/sql/2003_ci_process-update_v1.0_mysql.sql index 36bb882c137..f35f1667f96 100644 --- a/support-files/sql/2003_ci_process-update_v1.0_mysql.sql +++ b/support-files/sql/2003_ci_process-update_v1.0_mysql.sql @@ -12,7 +12,6 @@ BEGIN SET AUTOCOMMIT = 0; SELECT DATABASE() INTO db; - SELECT DATABASE() INTO db; IF EXISTS(SELECT 1 FROM information_schema.statistics WHERE TABLE_SCHEMA = db diff --git a/support-files/sql/2006_ci_project-update_v1.5_mysql.sql b/support-files/sql/2006_ci_project-update_v1.5_mysql.sql new file mode 100644 index 00000000000..8fd84fa92cb --- /dev/null +++ b/support-files/sql/2006_ci_project-update_v1.5_mysql.sql @@ -0,0 +1,27 @@ +USE devops_ci_project; +SET NAMES utf8mb4; + +DROP PROCEDURE IF EXISTS ci_project_schema_update; + +DELIMITER + +CREATE PROCEDURE ci_project_schema_update() +BEGIN + DECLARE db VARCHAR(100); + SET AUTOCOMMIT = 0; + SELECT DATABASE() INTO db; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.statistics + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_SERVICE' + AND INDEX_NAME = 'IDX_UNIQUE_ENGLISH_NAME') THEN + ALTER TABLE `T_SERVICE` + ADD INDEX `IDX_UNIQUE_ENGLISH_NAME` (`english_name`); + END IF; + + COMMIT; +END +DELIMITER ; +COMMIT; +CALL ci_project_schema_update(); diff --git a/support-files/sql/5001_ci_project-init_dml_mysql.sql b/support-files/sql/5001_ci_project-init_dml_mysql.sql index e868289c4de..86312b07599 100755 --- a/support-files/sql/5001_ci_project-init_dml_mysql.sql +++ b/support-files/sql/5001_ci_project-init_dml_mysql.sql @@ -2,17 +2,17 @@ USE devops_ci_project; SET NAMES utf8mb4; -- 服务初始化 -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('代码库(Code)', 'Code', 2, 'devops/codelib/', '/codelib/', 'amd', '', '/codelib/codelib.css', '/codelib/codelib.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:47', 'system', '2019-06-05 17:12:47', b'0', '', '', 99, 'codelib', ''); -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('流水线(Pipeline)', 'Pipeline', 2, 'devops/pipelines/', '/pipeline/', 'iframe', '/pipeline/', '', '', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'0', NULL, NULL, 97, 'pipeline', '^\/console\/pipeline\/[^\/]+\/list(\/)?(allPipeline|myPipeline|collect)?$,^\/console\/pipeline\/[^\/]+\/[^\/]+\/detail\/[^\/]+(\/executeDetail)?$,^\/console\/pipeline\/[^\/]+\/[^\/]+\/history$'); -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('制品库(Artifactory)', 'Artifactory', 2, 'devops/artifactory/', '/artifactory/', 'amd', '', '/artifactory/artifactory.css', '/artifactory/artifactory.js', b'1', b'1', 'path', 'disable', 'system', '2019-06-05 17:12:48', 'system', '2019-06-05 17:12:48', b'1', '', '', 96, 'artifactory', ''); -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('凭证管理(Ticket)', 'Ticket', 8, 'devops/ticket/', '/ticket/', 'amd', '', '/ticket/ticket.css', '/ticket/ticket.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:26', 'system', '2019-06-05 17:13:26', b'0', '', '', 95, 'ticket', ''); -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('环境管理(Env)', 'Env', 4, 'devops/environment/', '/environment/', 'amd', '', '/environment/environment.css', '/environment/environment.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:27', 'system', '2019-06-05 17:13:27', b'0', '', '', 94, 'environment', ''); -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('研发商店(Store)', 'Store', 8, '/devops/store/', '/store/', 'amd', '', '/store/store.css', '/store/store.js', b'0', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:29', 'system', '2019-06-05 17:13:29', b'0', '', '', 93, 'store', ''); -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('质量红线(Gate)', 'Gate', 3, '/devops/quality/', '/quality/', 'amd', '', '/quality/quality.css', '/quality/quality.js', b'1', b'1', 'path', 'disable', 'system', '2019-06-05 17:13:29', 'system', '2019-06-05 17:13:29', b'1', '', '', 92, 'quality', ''); -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('代码检查(CodeCC)', 'CodeCC', 2, 'devops/codecc/', '/codecc/', 'iframe', '/codecc/', '', '', b'1', b'1', 'path', 'disable', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 89, 'codecc', ''); -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('度量数据(Measure)', 'Measure', 2, 'devops/measure/', '/measure/', 'iframe', '/measure/', '', '', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 91, 'measure', ''); -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('敏捷开发(Teamwork)', 'Teamwork', 1, 'devops/teamwork/', '/teamwork/', 'amd', '', '/teamwork/teamwork.css', '/teamwork/teamwork.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:48', 'system', '2019-06-05 17:12:48', b'1', '', '', 90, 'teamwork', ''); -REPLACE INTO `T_SERVICE` (`name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES ('编译加速(Turbo)', 'Turbo', 2, 'devops/turbo/', '/turbo/', 'amd', '', '', '', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'0', NULL, NULL, 89, 'turbo', ''); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (1, '代码库(Code)', 'Code', 2, '/codelib/', '/codelib/', 'amd', '', '/codelib/codelib.css', '/codelib/codelib.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:47', 'system', '2019-06-05 17:12:47', b'0', '', '', 99, 'codelib', ''); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (2, '流水线(Pipeline)', 'Pipeline', 2, '/pipelines/', '/pipeline/', 'iframe', '/pipeline/', '', '', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'0', NULL, NULL, 97, 'pipeline', '^\/console\/pipeline\/[^\/]+\/list(\/)?(allPipeline|myPipeline|collect)?$,^\/console\/pipeline\/[^\/]+\/[^\/]+\/detail\/[^\/]+(\/executeDetail)?$,^\/console\/pipeline\/[^\/]+\/[^\/]+\/history$'); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (3, '制品库(Artifactory)', 'Artifactory', 2, '/artifactory/', '/artifactory/', 'amd', '', '/artifactory/artifactory.css', '/artifactory/artifactory.js', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:48', 'system', '2019-06-05 17:12:48', b'1', '', '', 96, 'artifactory', ''); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (4, '凭证管理(Ticket)', 'Ticket', 8, '/ticket/', '/ticket/', 'amd', '', '/ticket/ticket.css', '/ticket/ticket.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:26', 'system', '2019-06-05 17:13:26', b'0', '', '', 95, 'ticket', ''); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (5, '环境管理(Env)', 'Env', 4, '/environment/', '/environment/', 'amd', '', '/environment/environment.css', '/environment/environment.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:27', 'system', '2019-06-05 17:13:27', b'0', '', '', 94, 'environment', ''); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (6, '研发商店(Store)', 'Store', 8, '/store/', '/store/', 'amd', '', '/store/store.css', '/store/store.js', b'0', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:29', 'system', '2019-06-05 17:13:29', b'0', '', '', 93, 'store', ''); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (7, '质量红线(Gate)', 'Gate', 3, '/quality/', '/quality/', 'amd', '', '/quality/quality.css', '/quality/quality.js', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:13:29', 'system', '2019-06-05 17:13:29', b'1', '', '', 92, 'quality', ''); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (8, '代码检查(CodeCC)', 'CodeCC', 2, '/codecc/', '/codecc/', 'iframe', '/codecc/', '', '', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 89, 'codecc', ''); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (9, '度量数据(Measure)', 'Measure', 2, '/measure/', '/measure/', 'iframe', '/measure/', '', '', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 91, 'measure', ''); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (10, '敏捷开发(Teamwork)', 'Teamwork', 1, '/teamwork/', '/teamwork/', 'amd', '', '/teamwork/teamwork.css', '/teamwork/teamwork.js', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:48', 'system', '2019-06-05 17:12:48', b'1', '', '', 90, 'teamwork', ''); +REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (100, '编译加速(Turbo)', 'Turbo', 2, '/turbo/', '/turbo/', 'amd', '', '', '', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 89, 'turbo', ''); -- 服务分类初始化 INSERT IGNORE INTO `T_SERVICE_TYPE` (`id`, `title`, `english_title`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `weight`) VALUES (1, '项目管理', 'Case', 'system', '2019-06-05 17:13:55', 'system', '2019-06-05 17:13:55', b'1', NULL); From 1b74089e33e591f10d1cb9f4ffe416d873d7d462 Mon Sep 17 00:00:00 2001 From: irwinsun Date: Fri, 10 Sep 2021 23:37:54 +0800 Subject: [PATCH 092/120] =?UTF-8?q?feat:=20=E6=9C=8D=E5=8A=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0OP=E6=8E=A5=E5=8F=A3=20#5144?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/op/OPProjectServiceResource.kt | 38 +++-- .../project/pojo/service/ServiceCreateInfo.kt | 18 +- .../project/pojo/service/ServiceUpdateInfo.kt | 77 +++++++++ .../pojo/service/ServiceUrlUpdateInfo.kt | 44 ----- .../tencent/devops/project/dao/ServiceDao.kt | 157 +++++++++--------- .../resources/OPProjectServiceResourceImpl.kt | 22 +-- .../service/UserProjectServiceService.kt | 9 +- .../impl/AbsUserProjectServiceServiceImpl.kt | 25 +-- 8 files changed, 205 insertions(+), 185 deletions(-) create mode 100644 src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceUpdateInfo.kt delete mode 100644 src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceUrlUpdateInfo.kt diff --git a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/op/OPProjectServiceResource.kt b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/op/OPProjectServiceResource.kt index 5244e51d865..191b2ffea13 100644 --- a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/op/OPProjectServiceResource.kt +++ b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/api/op/OPProjectServiceResource.kt @@ -30,7 +30,6 @@ import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID import com.tencent.devops.project.pojo.Result -import com.tencent.devops.project.pojo.ServiceUpdateUrls import com.tencent.devops.project.pojo.service.GrayTestInfo import com.tencent.devops.project.pojo.service.GrayTestListInfo import com.tencent.devops.project.pojo.service.OPPServiceVO @@ -38,6 +37,7 @@ import com.tencent.devops.project.pojo.service.ServiceCreateInfo import com.tencent.devops.project.pojo.service.ServiceListVO import com.tencent.devops.project.pojo.service.ServiceType import com.tencent.devops.project.pojo.service.ServiceTypeModify +import com.tencent.devops.project.pojo.service.ServiceUpdateInfo import com.tencent.devops.project.pojo.service.ServiceVO import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation @@ -58,6 +58,7 @@ import javax.ws.rs.core.MediaType @Path("/op/services") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) +@Suppress("LongParameterList", "TooManyFunctions") interface OPProjectServiceResource { @POST @@ -70,9 +71,9 @@ interface OPProjectServiceResource { @ApiParam("服务类型名", required = true) @PathParam("title") title: String, - @ApiParam("权重", required = true) - @PathParam("weight") - weight: Int + @ApiParam("权重", required = false) + @QueryParam("weight") + weight: Int = 0 ): Result @DELETE @@ -142,17 +143,6 @@ interface OPProjectServiceResource { serviceCreateInfo: ServiceCreateInfo ): Result - @PUT - @Path("/") - @ApiOperation("批量修改服务") - fun updateServiceUrlByBatch( - @ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) - @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) - userId: String, - @ApiParam("修改服务的js和css连接", required = true) - serviceUpdateUrls: List - ): Result - @DELETE @Path("/{serviceId}") @ApiOperation("删除服务") @@ -167,7 +157,7 @@ interface OPProjectServiceResource { @PUT @Path("/{serviceId}") - @ApiOperation("修改服务信息") + @ApiOperation("根据ServiceId来修改服务信息") fun updateService( @ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) @@ -176,7 +166,21 @@ interface OPProjectServiceResource { @PathParam("serviceId") serviceId: Long, @ApiParam("修改服务所需信息", required = true) - serviceCreateInfo: ServiceCreateInfo + serviceUpdateInfo: ServiceUpdateInfo + ): Result + + @PUT + @Path("/update/{englishName}") + @ApiOperation("根据服务英文名称修改服务信息") + fun updateServiceByName( + @ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_DEVOPS_USER_ID) + userId: String, + @ApiParam("服务英文名(唯一)", required = true) + @PathParam("englishName") + englishName: String, + @ApiParam("修改服务所需信息", required = true) + serviceUpdateInfo: ServiceUpdateInfo ): Result @GET diff --git a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceCreateInfo.kt b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceCreateInfo.kt index 0fabf2ee04f..fcd68f43d10 100644 --- a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceCreateInfo.kt +++ b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceCreateInfo.kt @@ -35,22 +35,24 @@ import io.swagger.annotations.ApiModelProperty */ @ApiModel("服务-创建模型") data class ServiceCreateInfo( - @ApiModelProperty("服务名称", required = true) + @ApiModelProperty("服务名称,英文名,不传则从中文名中读取 流水线(Pipeline)") + var englishName: String?, + @ApiModelProperty("服务名称,中文名, 例如 流水线(Pipeline)", required = true) val name: String, - @ApiModelProperty("服务类型ID", required = true) + @ApiModelProperty("服务类型ID,1:项目管理 2:开发 3:测试 4:部署 5:运营 6:安全 8:管理工具", required = true) val serviceTypeId: Long, - @ApiModelProperty("是否在页面显示") + @ApiModelProperty("是否展示项目列表") val showProjectList: Boolean = true, - @ApiModelProperty("showNav") + @ApiModelProperty("是否在服务导航条上显示") val showNav: Boolean = true, - @ApiModelProperty("状态(是否默认显示灰色)") + @ApiModelProperty("服务状态 ok=正常(可用) planning=规划中(灰色不可用) new=新上线(可用)") val status: String = "ok", - @ApiModelProperty("链接1") + @ApiModelProperty("链接1,例如 /pipeline/") val link: String?, - @ApiModelProperty("链接2") + @ApiModelProperty("链接2与链接1保持一样,例如 /pipeline/") val linkNew: String?, - @ApiModelProperty("注入类型") + @ApiModelProperty("注入类型:amd/iframe") val injectType: String?, @ApiModelProperty("iframeUrl") val iframeUrl: String?, diff --git a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceUpdateInfo.kt b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceUpdateInfo.kt new file mode 100644 index 00000000000..8aab26c7a70 --- /dev/null +++ b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceUpdateInfo.kt @@ -0,0 +1,77 @@ +/* + * 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.project.pojo.service + +import io.swagger.annotations.ApiModel +import io.swagger.annotations.ApiModelProperty + +@ApiModel("服务-修改模型 只传要修改的字段,其他放空表示不修改)") +data class ServiceUpdateInfo( + @ApiModelProperty("服务ID,如果为空,则使用englishName作为主键进行检索更新,如果是要更新englishName,则该字段作为检索字段不能为空") + var serviceId: Long?, + @ApiModelProperty("服务名称,英文名") + var englishName: String?, + @ApiModelProperty("服务名称,中文名") + val name: String?, + @ApiModelProperty("服务类型ID,1:项目管理 2:开发 3:测试 4:部署 5:运营 6:安全 8:管理工具") + val serviceTypeId: Long?, + @ApiModelProperty("是否展示项目列表") + val showProjectList: Boolean?, + @ApiModelProperty("是否在服务导航条上显示") + val showNav: Boolean?, + @ApiModelProperty("服务状态 ok=正常(可用) planning=规划中(灰色不可用) new=新上线(可用)") + val status: String?, + @ApiModelProperty("是否被软删除,变成不可见") + val deleted: Boolean?, + @ApiModelProperty("链接1,例如 /pipeline/") + val link: String?, + @ApiModelProperty("链接2与链接1保持一样,例如 /pipeline/") + val linkNew: String?, + @ApiModelProperty("注入类型:amd/iframe") + val injectType: String?, + @ApiModelProperty("iframeUrl") + val iframeUrl: String?, + @ApiModelProperty("grayIframeUrl 目前没用") + val grayIframeUrl: String?, + @ApiModelProperty("cssUrl") + val cssUrl: String?, + @ApiModelProperty("jsUrl") + val jsUrl: String?, + @ApiModelProperty("grayCssUrl 目前没用") + val grayCssUrl: String?, + @ApiModelProperty("grayJsUrl 目前没用") + val grayJsUrl: String?, + @ApiModelProperty("projectIdType") + val projectIdType: String?, + @ApiModelProperty("权重") + val weight: Int?, + @ApiModelProperty("logo地址") + val logoUrl: String?, + @ApiModelProperty("支持webSocket的页面") + val webSocket: String? +) diff --git a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceUrlUpdateInfo.kt b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceUrlUpdateInfo.kt deleted file mode 100644 index 000303a0971..00000000000 --- a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/service/ServiceUrlUpdateInfo.kt +++ /dev/null @@ -1,44 +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.project.pojo.service - -import io.swagger.annotations.ApiModel -import io.swagger.annotations.ApiModelProperty - -/** - * Date on 2018-12-05. - */ -@ApiModel("服务-修改模型") -data class ServiceUrlUpdateInfo( - @ApiModelProperty("服务名称", required = true) - val name: String, - @ApiModelProperty("cssUrl") - val cssUrl: String, - @ApiModelProperty("jsUrl") - val jsUrl: String -) diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ServiceDao.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ServiceDao.kt index 326d96316a0..4da93477330 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ServiceDao.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ServiceDao.kt @@ -29,12 +29,11 @@ package com.tencent.devops.project.dao import com.tencent.devops.model.project.tables.TService import com.tencent.devops.model.project.tables.records.TServiceRecord -import com.tencent.devops.project.pojo.ServiceUpdateUrls import com.tencent.devops.project.pojo.service.ServiceCreateInfo +import com.tencent.devops.project.pojo.service.ServiceUpdateInfo import com.tencent.devops.project.pojo.service.ServiceVO import org.jooq.DSLContext import org.jooq.Result -import org.jooq.UpdateSetMoreStep import org.springframework.stereotype.Repository import java.time.LocalDateTime @@ -106,6 +105,7 @@ class ServiceDao { return dslContext.insertInto( this, NAME, + ENGLISH_NAME, SERVICE_TYPE_ID, LINK, LINK_NEW, @@ -127,6 +127,7 @@ class ServiceDao { GRAY_IFRAME_URL ).values( serviceCreateInfo.name, + serviceCreateInfo.englishName, serviceCreateInfo.serviceTypeId, serviceCreateInfo.link, serviceCreateInfo.linkNew, @@ -161,64 +162,83 @@ class ServiceDao { } } - fun update(dslContext: DSLContext, userId: String, serviceId: Long, serviceCreateInfo: ServiceCreateInfo): Boolean { + fun update(dslContext: DSLContext, userId: String, serviceUpdateInfo: ServiceUpdateInfo): Boolean { with(TService.T_SERVICE) { + + val whereCondition = if (serviceUpdateInfo.serviceId != null) { + ID.eq(serviceUpdateInfo.serviceId) + } else if (!serviceUpdateInfo.englishName.isNullOrBlank()) { + ENGLISH_NAME.eq(serviceUpdateInfo.englishName) + } else { + return false + } + val execute = dslContext.update(this) - .set(NAME, serviceCreateInfo.name) - .set(SERVICE_TYPE_ID, serviceCreateInfo.serviceTypeId) - .set(LINK, serviceCreateInfo.link) - .set(LINK_NEW, serviceCreateInfo.linkNew) - .set(INJECT_TYPE, serviceCreateInfo.injectType) - .set(IFRAME_URL, serviceCreateInfo.iframeUrl) - .set(GRAY_IFRAME_URL, serviceCreateInfo.grayIframeUrl) - .set(CSS_URL, serviceCreateInfo.cssUrl) - .set(JS_URL, serviceCreateInfo.jsUrl) - .set(GRAY_CSS_URL, serviceCreateInfo.grayCssUrl) - .set(GRAY_JS_URL, serviceCreateInfo.grayJsUrl) - .set(SHOW_PROJECT_LIST, serviceCreateInfo.showProjectList) - .set(SHOW_NAV, serviceCreateInfo.showNav) - .set(PROJECT_ID_TYPE, serviceCreateInfo.projectIdType) - .set(STATUS, serviceCreateInfo.status) - .set(LOGO_URL, serviceCreateInfo.logoUrl) - .set(WEB_SOCKET, serviceCreateInfo.webSocket) - .set(UPDATED_USER, userId) + if (!serviceUpdateInfo.name.isNullOrBlank()) { + execute.set(NAME, serviceUpdateInfo.name) + } + if (serviceUpdateInfo.serviceTypeId != null) { + execute.set(SERVICE_TYPE_ID, serviceUpdateInfo.serviceTypeId) + } + if (!serviceUpdateInfo.link.isNullOrBlank()) { + execute.set(LINK, serviceUpdateInfo.link) + } + if (!serviceUpdateInfo.linkNew.isNullOrBlank()) { + execute.set(LINK_NEW, serviceUpdateInfo.linkNew) + } + if (!serviceUpdateInfo.injectType.isNullOrBlank()) { + execute.set(INJECT_TYPE, serviceUpdateInfo.injectType) + } + if (!serviceUpdateInfo.iframeUrl.isNullOrBlank()) { + execute.set(IFRAME_URL, serviceUpdateInfo.iframeUrl) + } + if (!serviceUpdateInfo.grayIframeUrl.isNullOrBlank()) { + execute.set(GRAY_IFRAME_URL, serviceUpdateInfo.grayIframeUrl) + } + if (!serviceUpdateInfo.cssUrl.isNullOrBlank()) { + execute.set(CSS_URL, serviceUpdateInfo.cssUrl) + } + if (!serviceUpdateInfo.jsUrl.isNullOrBlank()) { + execute.set(JS_URL, serviceUpdateInfo.jsUrl) + } + if (!serviceUpdateInfo.grayCssUrl.isNullOrBlank()) { + execute.set(GRAY_CSS_URL, serviceUpdateInfo.grayCssUrl) + } + if (!serviceUpdateInfo.grayJsUrl.isNullOrBlank()) { + execute.set(GRAY_JS_URL, serviceUpdateInfo.grayJsUrl) + } + if (serviceUpdateInfo.showProjectList != null) { + execute.set(SHOW_PROJECT_LIST, serviceUpdateInfo.showProjectList) + } + if (serviceUpdateInfo.showNav != null) { + execute.set(SHOW_NAV, serviceUpdateInfo.showNav) + } + if (!serviceUpdateInfo.projectIdType.isNullOrBlank()) { + execute.set(PROJECT_ID_TYPE, serviceUpdateInfo.projectIdType) + } + if (!serviceUpdateInfo.status.isNullOrBlank()) { + execute.set(STATUS, serviceUpdateInfo.status) + } + if (!serviceUpdateInfo.logoUrl.isNullOrBlank()) { + execute.set(LOGO_URL, serviceUpdateInfo.logoUrl) + } + if (!serviceUpdateInfo.webSocket.isNullOrBlank()) { + execute.set(WEB_SOCKET, serviceUpdateInfo.webSocket) + } + if (!serviceUpdateInfo.englishName.isNullOrBlank()) { + execute.set(ENGLISH_NAME, serviceUpdateInfo.englishName) + } + if (serviceUpdateInfo.deleted != null) { + execute.set(DELETED, serviceUpdateInfo.deleted) + } + + return execute.set(UPDATED_USER, userId) .set(UPDATED_TIME, LocalDateTime.now()) - .where(ID.eq(serviceId)) - .and(DELETED.eq(false)) - .execute() - return execute > 0 + .where(whereCondition) + .execute() > 0 } } - fun updateUrlsByName(dslContext: DSLContext, serviceUpdateUrls: List): Int { - return with(TService.T_SERVICE) { - dslContext.batch( - serviceUpdateUrls.filter { - (!it.jsUrl.isNullOrBlank()) || - (!it.grayJsUrl.isNullOrBlank()) || - (!it.cssUrl.isNullOrBlank()) || - (!it.grayCssUrl.isNullOrBlank()) - }.map { - val step = dslContext.update(this) - var updateStep: UpdateSetMoreStep? = null - if (!it.jsUrl.isNullOrBlank()) { - updateStep = step.set(JS_URL, it.jsUrl) - } - if (!it.grayJsUrl.isNullOrBlank()) { - updateStep = step.set(GRAY_JS_URL, it.grayJsUrl) - } - if (!it.cssUrl.isNullOrBlank()) { - updateStep = step.set(CSS_URL, it.cssUrl) - } - if (!it.grayCssUrl.isNullOrBlank()) { - updateStep = step.set(GRAY_CSS_URL, it.grayCssUrl) - } - updateStep!!.where(NAME.eq(it.name)) - } - ).execute() - }.sum() - } - fun select(dslContext: DSLContext, serviceId: Long): TServiceRecord? { with(TService.T_SERVICE) { return dslContext.selectFrom(this) @@ -227,33 +247,4 @@ class ServiceDao { .fetchOne() } } - - fun updateUrls( - dslContext: DSLContext, - userId: String, - name: String, - serviceUpdateUrls: ServiceUpdateUrls - ): Boolean { - with(TService.T_SERVICE) { - val step = dslContext.update(this) - if (!serviceUpdateUrls.cssUrl.isNullOrBlank()) { - step.set(CSS_URL, serviceUpdateUrls.cssUrl) - } - if (!serviceUpdateUrls.jsUrl.isNullOrBlank()) { - step.set(JS_URL, serviceUpdateUrls.jsUrl) - } - if (!serviceUpdateUrls.grayCssUrl.isNullOrBlank()) { - step.set(GRAY_CSS_URL, serviceUpdateUrls.grayCssUrl) - } - if (!serviceUpdateUrls.grayJsUrl.isNullOrBlank()) { - step.set(GRAY_JS_URL, serviceUpdateUrls.grayJsUrl) - } - val execute = step.set(UPDATED_USER, userId) - .set(UPDATED_TIME, LocalDateTime.now()) - .where(NAME.eq(name)) - .and(DELETED.eq(false)) - .execute() - return execute > 0 - } - } } diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/OPProjectServiceResourceImpl.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/OPProjectServiceResourceImpl.kt index d03d02a0636..6ca610cfb1e 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/OPProjectServiceResourceImpl.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/OPProjectServiceResourceImpl.kt @@ -30,7 +30,6 @@ package com.tencent.devops.project.resources import com.tencent.devops.common.web.RestResource import com.tencent.devops.project.api.op.OPProjectServiceResource import com.tencent.devops.project.pojo.Result -import com.tencent.devops.project.pojo.ServiceUpdateUrls import com.tencent.devops.project.pojo.service.GrayTestInfo import com.tencent.devops.project.pojo.service.GrayTestListInfo import com.tencent.devops.project.pojo.service.OPPServiceVO @@ -38,23 +37,20 @@ import com.tencent.devops.project.pojo.service.ServiceCreateInfo import com.tencent.devops.project.pojo.service.ServiceListVO import com.tencent.devops.project.pojo.service.ServiceType import com.tencent.devops.project.pojo.service.ServiceTypeModify +import com.tencent.devops.project.pojo.service.ServiceUpdateInfo import com.tencent.devops.project.pojo.service.ServiceVO import com.tencent.devops.project.service.GrayTestService import com.tencent.devops.project.service.ServiceTypeService import com.tencent.devops.project.service.UserProjectServiceService -import org.slf4j.LoggerFactory @RestResource +@Suppress("TooManyFunctions") class OPProjectServiceResourceImpl constructor( private val userProjectServiceService: UserProjectServiceService, private val serviceTypeService: ServiceTypeService, private val grayTestService: GrayTestService ) : OPProjectServiceResource { - companion object { - private val logger = LoggerFactory.getLogger(OPProjectServiceResourceImpl::class.java) - } - override fun listUsers(userId: String): Result>> { return Result(grayTestService.listAllUsers()) } @@ -139,13 +135,19 @@ class OPProjectServiceResourceImpl constructor( override fun updateService( userId: String, serviceId: Long, - serviceCreateInfo: ServiceCreateInfo + serviceUpdateInfo: ServiceUpdateInfo ): Result { - return userProjectServiceService.updateService(userId, serviceId, serviceCreateInfo) + serviceUpdateInfo.serviceId = serviceId + return userProjectServiceService.updateService(userId, serviceUpdateInfo) } - override fun updateServiceUrlByBatch(userId: String, serviceUpdateUrls: List): Result { - return userProjectServiceService.updateServiceUrls(userId, serviceUpdateUrls) + override fun updateServiceByName( + userId: String, + englishName: String, + serviceUpdateInfo: ServiceUpdateInfo + ): Result { + serviceUpdateInfo.englishName = englishName + return userProjectServiceService.updateService(userId, serviceUpdateInfo) } override fun getService(userId: String, serviceId: Long): Result { diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/UserProjectServiceService.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/UserProjectServiceService.kt index 203c8261e45..f3367283cb0 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/UserProjectServiceService.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/UserProjectServiceService.kt @@ -28,10 +28,10 @@ package com.tencent.devops.project.service import com.tencent.devops.project.pojo.Result -import com.tencent.devops.project.pojo.ServiceUpdateUrls import com.tencent.devops.project.pojo.service.OPPServiceVO import com.tencent.devops.project.pojo.service.ServiceCreateInfo import com.tencent.devops.project.pojo.service.ServiceListVO +import com.tencent.devops.project.pojo.service.ServiceUpdateInfo import com.tencent.devops.project.pojo.service.ServiceVO /** @@ -66,12 +66,7 @@ interface UserProjectServiceService { /** * 更新服务信息 */ - fun updateService(userId: String, serviceId: Long, serviceCreateInfo: ServiceCreateInfo): Result - - /** - * 批量跟新服务URL信息 - */ - fun updateServiceUrls(userId: String, serviceUpdateUrls: List): Result + fun updateService(userId: String, serviceUpdateInfo: ServiceUpdateInfo): Result /** * 读取指定服务的信息 diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsUserProjectServiceServiceImpl.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsUserProjectServiceServiceImpl.kt index de8d96c07d8..46135742f8f 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsUserProjectServiceServiceImpl.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsUserProjectServiceServiceImpl.kt @@ -37,10 +37,10 @@ import com.tencent.devops.project.dao.FavoriteDao import com.tencent.devops.project.dao.ServiceDao import com.tencent.devops.project.dao.ServiceTypeDao import com.tencent.devops.project.pojo.Result -import com.tencent.devops.project.pojo.ServiceUpdateUrls import com.tencent.devops.project.pojo.service.OPPServiceVO import com.tencent.devops.project.pojo.service.ServiceCreateInfo import com.tencent.devops.project.pojo.service.ServiceListVO +import com.tencent.devops.project.pojo.service.ServiceUpdateInfo import com.tencent.devops.project.pojo.service.ServiceVO import com.tencent.devops.project.service.UserProjectServiceService import org.jooq.DSLContext @@ -91,21 +91,8 @@ abstract class AbsUserProjectServiceServiceImpl @Autowired constructor( /** * 修改服务 */ - override fun updateService(userId: String, serviceId: Long, serviceCreateInfo: ServiceCreateInfo): Result { - return Result(serviceDao.update(dslContext, userId, serviceId, serviceCreateInfo)) - } - - /** - * 批量修改服务url - */ - override fun updateServiceUrls( - userId: String, - serviceUpdateUrls: List - ): Result { - if (serviceUpdateUrls.isEmpty()) { - return Result(data = 0) - } - return Result(serviceDao.updateUrlsByName(dslContext, serviceUpdateUrls)) + override fun updateService(userId: String, serviceUpdateInfo: ServiceUpdateInfo): Result { + return Result(serviceDao.update(dslContext, userId, serviceUpdateInfo)) } /** @@ -160,6 +147,12 @@ abstract class AbsUserProjectServiceServiceImpl @Autowired constructor( * 添加服务 */ override fun createService(userId: String, serviceCreateInfo: ServiceCreateInfo): Result { + if (serviceCreateInfo.englishName.isNullOrBlank()) { + val matcher = Regex(".+\\((.+)\\)").toPattern().matcher(serviceCreateInfo.name) + if (matcher.find()) { + serviceCreateInfo.englishName = matcher.group(1) + } + } val tServiceRecord = serviceDao.create(dslContext, userId, serviceCreateInfo) if (tServiceRecord != null) { return Result(genServiceVO(tServiceRecord)) From d7a051fefcd5197bdf6e953c8373dcfdacb3f37e Mon Sep 17 00:00:00 2001 From: irwinsun Date: Sat, 11 Sep 2021 00:51:10 +0800 Subject: [PATCH 093/120] =?UTF-8?q?feat:=20=E6=9C=8D=E5=8A=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0OP=E6=8E=A5=E5=8F=A3=20#5144?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/com/tencent/devops/project/dao/ServiceDao.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ServiceDao.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ServiceDao.kt index 4da93477330..15fd4fbe332 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ServiceDao.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ServiceDao.kt @@ -38,6 +38,7 @@ import org.springframework.stereotype.Repository import java.time.LocalDateTime @Repository +@Suppress("ComplexMethod", "LongMethod") class ServiceDao { fun getServiceList(dslContext: DSLContext): Result { From b028d9e3963b0893105333614c7170bc6366d205 Mon Sep 17 00:00:00 2001 From: irwinsun Date: Sat, 11 Sep 2021 01:08:06 +0800 Subject: [PATCH 094/120] =?UTF-8?q?feat:=20=E6=9C=8D=E5=8A=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0OP=E6=8E=A5=E5=8F=A3=20#5144=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/tencent/devops/common/api/util/CsvUtil.kt | 1 + .../com/tencent/devops/openapi/aspect/ApiAspect.kt | 1 + .../container/impl/StartActionTaskContainerCmd.kt | 1 + .../devops/process/service/PipelineAtomService.kt | 1 + .../tencent/devops/store/constant/StoreMessageCode.kt | 9 ++++++--- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/CsvUtil.kt b/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/CsvUtil.kt index 6a3e4ccbfed..c23d60baf26 100644 --- a/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/CsvUtil.kt +++ b/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/CsvUtil.kt @@ -50,6 +50,7 @@ object CsvUtil { * @param cellList 表数据 * @return */ + @Suppress("SpreadOperator") fun writeCsv( headers: Array, cellList: List> diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/aspect/ApiAspect.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/aspect/ApiAspect.kt index 56cc5a415a0..6ede11279c6 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/aspect/ApiAspect.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/aspect/ApiAspect.kt @@ -64,6 +64,7 @@ class ApiAspect( "||execution(* com.tencent.devops.openapi.resources.apigw.v2.app.*.*(..))" + "||execution(* com.tencent.devops.openapi.resources.apigw.v2.user.*.*(..))" ) // 所有controller包下面的所有方法的所有参数 + @Suppress("ComplexMethod") fun beforeMethod(jp: JoinPoint) { if (!apiGatewayUtil.isAuth()) { return diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/container/impl/StartActionTaskContainerCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/container/impl/StartActionTaskContainerCmd.kt index 3b264923096..49056a4e3c7 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/container/impl/StartActionTaskContainerCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/container/impl/StartActionTaskContainerCmd.kt @@ -104,6 +104,7 @@ class StartActionTaskContainerCmd( * 如遇到[BuildStatus.isReadyToRun]待执行任务,则检查是否可以执行, * 包括「是否条件跳过」「当前是否构建机启动失败」「Post Action检查」等等,通过方能成为待执行的任务 */ + @Suppress("ComplexMethod", "NestedBlockDepth") private fun findTask(containerContext: ContainerContext): PipelineBuildTask? { var toDoTask: PipelineBuildTask? = null var continueWhenFailure = false // 失败继续 diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineAtomService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineAtomService.kt index 36b72e69747..eac820e9b5b 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineAtomService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineAtomService.kt @@ -74,6 +74,7 @@ import javax.servlet.http.HttpServletResponse @Service @RefreshScope +@Suppress("NestedBlockDepth", "LongMethod", "LongParameterList", "MagicNumber") class PipelineAtomService @Autowired constructor( private val dslContext: DSLContext, private val pipelineInfoDao: PipelineInfoDao, diff --git a/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/constant/StoreMessageCode.kt b/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/constant/StoreMessageCode.kt index 4527d64f649..561b768e9a4 100644 --- a/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/constant/StoreMessageCode.kt +++ b/src/backend/ci/core/store/api-store/src/main/kotlin/com/tencent/devops/store/constant/StoreMessageCode.kt @@ -77,9 +77,12 @@ object StoreMessageCode { const val USER_REPOSITORY_TASK_JSON_FIELD_IS_INVALID = "2120026" // 研发商店:插件配置文件[task.json]{0}格式不正确,请检查 const val USER_ATOM_IS_NOT_ALLOW_REPLACE = "2120027" // 研发商店:插件[{0}]的[{1}]版本无法被插件[{2}]的[{3}]版本替换,插件[{2}]的{4}参数无法映射替换 const val USER_TO_ATOM_IS_NOT_BE_HIS_ATOM = "2120028" // 研发商店:目标替换插件不能是历史内置老插件 - const val USER_ATOM_NOT_COMPATIBLE_INPUT_FIELD = "2120029" // 研发商店:插件当前版本新增了无默认值的必填入参[{0}],将导致存量流水线执行异常,请修改发布类型进行非兼容式升级 - const val USER_ATOM_COMPATIBLE_INPUT_FIELD_CONFIRM = "2120030" // 研发商店:插件当前版本新增了入参[{0}],请确认插件执行逻辑对这些参数不存在或值为空的情况做了兼容处理,否则有可能导致存量流水线执行异常 - const val USER_ATOM_COMPATIBLE_OUTPUT_FIELD_CONFIRM = "2120031" // 研发商店:插件当前版本减少了出参[{0}],请确认插件执行逻辑对这些参数不存在或值为空的情况做了兼容处理,否则有可能导致存量流水线执行异常 + // 研发商店:插件当前版本新增了无默认值的必填入参[{0}],将导致存量流水线执行异常,请修改发布类型进行非兼容式升级 + const val USER_ATOM_NOT_COMPATIBLE_INPUT_FIELD = "2120029" + // 研发商店:插件当前版本新增了入参[{0}],请确认插件执行逻辑对这些参数不存在或值为空的情况做了兼容处理,否则有可能导致存量流水线执行异常 + const val USER_ATOM_COMPATIBLE_INPUT_FIELD_CONFIRM = "2120030" + // 研发商店:插件当前版本减少了出参[{0}],请确认插件执行逻辑对这些参数不存在或值为空的情况做了兼容处理,否则有可能导致存量流水线执行异常 + const val USER_ATOM_COMPATIBLE_OUTPUT_FIELD_CONFIRM = "2120031" const val USER_ATOM_INPUT_NUM_IS_TOO_MANY = "2120032" // 研发商店:插件入参数量太多,系统规定的数量最大为:{0} const val USER_ATOM_OUTPUT_NUM_IS_TOO_MANY = "2120033" // 研发商店:插件出参数量太多,系统规定的数量最大为:{0} From 0b805d7e440f9bc8a0fbb8fa6ac5cea0a14a79c8 Mon Sep 17 00:00:00 2001 From: fromschen Date: Sun, 12 Sep 2021 21:07:51 +0800 Subject: [PATCH 095/120] =?UTF-8?q?chore:=20turbo=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E9=80=82=E9=85=8D=20#5038?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/bk-ci-setup.sh | 2 +- .../turbo/support-files/templates/#etc#ci#application-turbo.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bk-ci-setup.sh b/scripts/bk-ci-setup.sh index 728490c0781..12c877bcdec 100755 --- a/scripts/bk-ci-setup.sh +++ b/scripts/bk-ci-setup.sh @@ -259,7 +259,7 @@ setup_ci_turbo (){ local proj=$1 setup_ci__ms_common "$proj" || return 11 # turbo日志路径为 turbo-devops/turbo-devops.log - update_link_to_target "$MS_DIR/logs/$MS_NAME.log" "$MS_LOGS_DIR/$MS_NAME-$BK_CI_CONSUL_DISCOVERY_TAG/$MS_NAME-$BK_CI_CONSUL_DISCERY_TAG.log" || return 3 + update_link_to_target "$MS_DIR/logs/$MS_NAME.log" "$MS_LOGS_DIR/$MS_NAME-$BK_CI_CONSUL_DISCOVERY_TAG/$MS_NAME-$BK_CI_CONSUL_DISCOVERY_TAG.log" || return 3 # 需要自定义启动参数. env_line_set "$start_env" "JAVA_OPTS" "-Dturbo.thirdparty.propdir=$BK_HOME/etc/ci/thirdparty" render_ci quartz # 额外渲染 #etc#ci#thirdparty#quartz.properties diff --git a/src/backend/turbo/support-files/templates/#etc#ci#application-turbo.yml b/src/backend/turbo/support-files/templates/#etc#ci#application-turbo.yml index d449b7a2374..f5fcbaf6483 100644 --- a/src/backend/turbo/support-files/templates/#etc#ci#application-turbo.yml +++ b/src/backend/turbo/support-files/templates/#etc#ci#application-turbo.yml @@ -33,7 +33,7 @@ server: context-path: /api tbs: - rootpath: __BK_TURBO_GATEWAY_PRIVATE_URL__ + rootpath: __BK_TURBO_PRIVATE_URL__/gw/ urltemplate: api/v1/{engine}/resource/{resource_type} devops: From 7097c102fe63833004beb4350e6eca407e8fc126 Mon Sep 17 00:00:00 2001 From: irwinsun Date: Mon, 13 Sep 2021 09:57:58 +0800 Subject: [PATCH 096/120] =?UTF-8?q?feat:=20=E6=9C=8D=E5=8A=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0OP=E6=8E=A5=E5=8F=A3=20#5144=20fix=20suppress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/process/service/PipelineAtomService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineAtomService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineAtomService.kt index 2e1658ed5b4..74ed3f3443c 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineAtomService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineAtomService.kt @@ -72,7 +72,6 @@ import java.text.MessageFormat import java.time.LocalDateTime import javax.servlet.http.HttpServletResponse -@Suppress("ALL") @Service @RefreshScope @Suppress("NestedBlockDepth", "LongMethod", "LongParameterList", "MagicNumber") From ced5e17ecbbb307913ac1b8809f95ef8412e488b Mon Sep 17 00:00:00 2001 From: ddlin0719 Date: Mon, 13 Sep 2021 10:24:53 +0800 Subject: [PATCH 097/120] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9C=BA=E5=88=B6=E5=8F=AF=E9=85=8D=E7=BD=AE=20#5091?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/atom/plugin/MarketBuildUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt index d4fa2469300..eb290b4634a 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt @@ -79,8 +79,8 @@ object MarketBuildUtils { ) fun beforeDelete(inputMap: Map, atomCode: String, atomVersion: String, param: BeforeDeleteParam) { - logger.info("start to do before delete: $inputMap, $atomCode, $atomVersion") marketBuildExecutorService.execute { + logger.info("start to do before delete: $inputMap, $atomCode, $atomVersion") val bkAtomHookUrl = inputMap.getOrDefault( BK_ATOM_HOOK_URL, getDefaultHookUrl(atomCode = atomCode, atomVersion = atomVersion, channelCode = param.channelCode) From 0f7f08515b6ad4bc13825ae097b53697f1906f36 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 11:45:31 +0800 Subject: [PATCH 098/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/common/pipeline/pojo/StagePauseCheck.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt index 143d98764d9..c3d79ea1e75 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt @@ -171,7 +171,11 @@ data class StagePauseCheck( } reviewDesc = EnvUtils.parseEnv(reviewDesc, variables) reviewParams?.forEach { - it.value = ObjectReplaceEnvVarUtil.replaceEnvVar(it.value, variables) + it.value = if (variables.containsKey(it.key)) { + variables[it.key] + } else { + ObjectReplaceEnvVarUtil.replaceEnvVar(it.value, variables) + } } } From 83a8fafa3dd123df9a7f33f7ec587c371b682d21 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Mon, 13 Sep 2021 11:49:09 +0800 Subject: [PATCH 099/120] =?UTF-8?q?=E5=8E=BB=E9=99=A4quartz-scheduler=20?= =?UTF-8?q?=E5=86=85HikariCP=20=E4=BE=9D=E8=B5=96=20#5146?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/core/process/plugin-trigger/build.gradle.kts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/plugin-trigger/build.gradle.kts b/src/backend/ci/core/process/plugin-trigger/build.gradle.kts index 5e85d38bd5a..69e4103a29d 100644 --- a/src/backend/ci/core/process/plugin-trigger/build.gradle.kts +++ b/src/backend/ci/core/process/plugin-trigger/build.gradle.kts @@ -32,7 +32,9 @@ dependencies { api(project(":core:process:model-process")) api(project(":core:process:api-process")) api(project(":core:process:plugin-sdk")) - implementation("org.quartz-scheduler:quartz") + implementation("org.quartz-scheduler:quartz") { + exclude(group = "com.zaxxer", module = "HikariCP-java7") + } } plugins { From 3c573365d67a6e6027c33c10a9a7e5d134f53664 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 11:49:12 +0800 Subject: [PATCH 100/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/command/stage/impl/CheckPauseReviewStageCmd.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index b091e355636..1b3b1469142 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -68,8 +68,8 @@ class CheckPauseReviewStageCmd( commandContext.cmdFlowState = CmdFlowState.BREAK } else if (commandContext.buildStatus.isReadyToRun()) { - // 只用第一次进入时做准入质量红线检查 - if (stage.checkIn?.ruleIds.isNullOrEmpty()) { + // #5019 只用第一次进入时做准入质量红线检查,如果是审核后的检查则跳过红线 + if (stage.checkIn?.ruleIds.isNullOrEmpty() || event.source == BS_MANUAL_START_STAGE) { LOG.info("ENGINE|${event.buildId}|${event.source}|SKIP_QUALITY_CHECK_IN|${event.stageId}") } else if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") From 4d5313c2497e0b24aa047ad4486d542c10fba2ee Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 15:28:48 +0800 Subject: [PATCH 101/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/pipeline/pojo/StagePauseCheck.kt | 9 +------ .../pojo/element/atom/ManualReviewParam.kt | 26 +++++++++++++++++-- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt index c3d79ea1e75..d20be90f8b2 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt @@ -28,7 +28,6 @@ package com.tencent.devops.common.pipeline.pojo import com.tencent.devops.common.api.util.EnvUtils -import com.tencent.devops.common.api.util.ObjectReplaceEnvVarUtil import com.tencent.devops.common.api.util.UUIDUtil import com.tencent.devops.common.api.util.timestampmilli import com.tencent.devops.common.pipeline.enums.BuildStatus @@ -170,13 +169,7 @@ data class StagePauseCheck( } } reviewDesc = EnvUtils.parseEnv(reviewDesc, variables) - reviewParams?.forEach { - it.value = if (variables.containsKey(it.key)) { - variables[it.key] - } else { - ObjectReplaceEnvVarUtil.replaceEnvVar(it.value, variables) - } - } + reviewParams?.forEach { it.value = it.parseValueWithType(variables) } } /** diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt index ede1f8e345b..22d7757aa31 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt @@ -27,6 +27,9 @@ package com.tencent.devops.common.pipeline.pojo.element.atom +import com.fasterxml.jackson.module.kotlin.readValue +import com.tencent.devops.common.api.util.JsonUtil +import com.tencent.devops.common.api.util.ObjectReplaceEnvVarUtil import io.swagger.annotations.ApiModel import io.swagger.annotations.ApiModelProperty @@ -45,5 +48,24 @@ data class ManualReviewParam( @ApiModelProperty("下拉框列表") val options: List? = null, @ApiModelProperty("中文名称", required = false) - val chineseName: String? = null -) + val chineseName: String? = null, +) { + /** + * 变量值处理,如果是已有值则直接使用,如果是变量引用则做替换 + */ + fun parseValueWithType(variables: Map): Any? { + return if (variables.containsKey(key) && !variables[key].isNullOrBlank()) { + when (valueType) { + ManualReviewParamType.BOOLEAN -> variables[key].toBoolean() + ManualReviewParamType.MULTIPLE -> try { + JsonUtil.getObjectMapper().readValue(variables[key]!!) as List + } catch (ignore: Throwable) { + variables[key] + } + else -> variables[key] + } + } else { + ObjectReplaceEnvVarUtil.replaceEnvVar(value, variables) + } + } +} From 594f7a174ad94709d57f6b0bde711aeac0ecf464 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 17:09:05 +0800 Subject: [PATCH 102/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019=20=E5=A2=9E=E5=8A=A0VAR=E8=A1=A8=E8=BD=AC=E5=9B=9E?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E5=AF=B9=E8=B1=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/pipeline/pojo/StagePauseCheck.kt | 2 +- .../pojo/element/atom/ManualReviewParam.kt | 5 ++-- .../pipeline/pojo/StagePauseCheckTest.kt | 2 +- .../element/atom/ManualReviewParamTest.kt | 27 +++++++++++++++++++ .../devops/log/util/IndexNameUtilsTest.kt | 2 +- .../service/rule/PipelineRuleServiceTest.kt | 2 +- 6 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt index d20be90f8b2..382dfe7194c 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheck.kt @@ -169,7 +169,7 @@ data class StagePauseCheck( } } reviewDesc = EnvUtils.parseEnv(reviewDesc, variables) - reviewParams?.forEach { it.value = it.parseValueWithType(variables) } + reviewParams?.forEach { it.parseValueWithType(variables) } } /** diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt index 22d7757aa31..cf1239c999d 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt @@ -27,8 +27,6 @@ package com.tencent.devops.common.pipeline.pojo.element.atom -import com.fasterxml.jackson.module.kotlin.readValue -import com.tencent.devops.common.api.util.JsonUtil import com.tencent.devops.common.api.util.ObjectReplaceEnvVarUtil import io.swagger.annotations.ApiModel import io.swagger.annotations.ApiModelProperty @@ -58,7 +56,8 @@ data class ManualReviewParam( when (valueType) { ManualReviewParamType.BOOLEAN -> variables[key].toBoolean() ManualReviewParamType.MULTIPLE -> try { - JsonUtil.getObjectMapper().readValue(variables[key]!!) as List + // TODO 将入库保存的字符串转回数组对象 + throw Exception("${variables[key]} mapping error.") } catch (ignore: Throwable) { variables[key] } diff --git a/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheckTest.kt b/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheckTest.kt index 7f8cade18c4..f004ae17582 100644 --- a/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheckTest.kt +++ b/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/StagePauseCheckTest.kt @@ -2,7 +2,7 @@ package com.tencent.devops.common.pipeline.pojo import com.tencent.devops.common.pipeline.pojo.element.atom.ManualReviewParam import org.junit.Assert -import org.junit.jupiter.api.Test +import org.junit.Test internal class StagePauseCheckTest { diff --git a/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt b/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt new file mode 100644 index 00000000000..c78c4fde877 --- /dev/null +++ b/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt @@ -0,0 +1,27 @@ +package com.tencent.devops.common.pipeline.pojo.element.atom + +import org.junit.Assert +import org.junit.Test + + +internal class ManualReviewParamTest { + + @Test + fun parseReviewParams() { + val key = "p1" + val list = listOf("a", "b") + val map = mapOf(key to list.toString()) + val param = ManualReviewParam( + key = key, + value = listOf("aaa", "bbb"), + valueType = ManualReviewParamType.MULTIPLE + ) + try { + println(param.parseValueWithType(map)) + println(param.parseValueWithType(map)?.javaClass) + } catch (e: Exception) { + e.printStackTrace() + } + Assert.assertTrue(param.parseValueWithType(map)?.equals(list) ?: false) + } +} diff --git a/src/backend/ci/core/log/biz-log/src/test/kotlin/com/tencent/devops/log/util/IndexNameUtilsTest.kt b/src/backend/ci/core/log/biz-log/src/test/kotlin/com/tencent/devops/log/util/IndexNameUtilsTest.kt index e9022d22873..2520773b484 100644 --- a/src/backend/ci/core/log/biz-log/src/test/kotlin/com/tencent/devops/log/util/IndexNameUtilsTest.kt +++ b/src/backend/ci/core/log/biz-log/src/test/kotlin/com/tencent/devops/log/util/IndexNameUtilsTest.kt @@ -2,8 +2,8 @@ package com.tencent.devops.log.util import com.github.benmanes.caffeine.cache.Caffeine import junit.framework.Assert.assertEquals -import org.junit.jupiter.api.Test import java.util.concurrent.TimeUnit +import org.junit.Test class IndexNameUtilsTest { diff --git a/src/backend/ci/core/process/biz-base/src/test/kotlin/com/tencent/devops/process/engine/service/rule/PipelineRuleServiceTest.kt b/src/backend/ci/core/process/biz-base/src/test/kotlin/com/tencent/devops/process/engine/service/rule/PipelineRuleServiceTest.kt index fb415cf944a..addfab2b2eb 100644 --- a/src/backend/ci/core/process/biz-base/src/test/kotlin/com/tencent/devops/process/engine/service/rule/PipelineRuleServiceTest.kt +++ b/src/backend/ci/core/process/biz-base/src/test/kotlin/com/tencent/devops/process/engine/service/rule/PipelineRuleServiceTest.kt @@ -33,7 +33,7 @@ import com.tencent.devops.common.redis.RedisOperation import com.tencent.devops.process.engine.dao.PipelineRuleDao import org.jooq.DSLContext import org.junit.Assert -import org.junit.jupiter.api.Test +import org.junit.Test class PipelineRuleServiceTest { From 43a873045db751f176db235bdaadf33226abe831 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 17:17:34 +0800 Subject: [PATCH 103/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019=20=E5=A2=9E=E5=8A=A0VAR=E8=A1=A8=E8=BD=AC=E5=9B=9E?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E5=AF=B9=E8=B1=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/pipeline/pojo/element/atom/ManualReviewParam.kt | 2 +- .../common/pipeline/pojo/element/atom/ManualReviewParamTest.kt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt index cf1239c999d..1d4434828eb 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt @@ -46,7 +46,7 @@ data class ManualReviewParam( @ApiModelProperty("下拉框列表") val options: List? = null, @ApiModelProperty("中文名称", required = false) - val chineseName: String? = null, + val chineseName: String? = null ) { /** * 变量值处理,如果是已有值则直接使用,如果是变量引用则做替换 diff --git a/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt b/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt index c78c4fde877..cb6afcce76e 100644 --- a/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt +++ b/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt @@ -3,7 +3,6 @@ package com.tencent.devops.common.pipeline.pojo.element.atom import org.junit.Assert import org.junit.Test - internal class ManualReviewParamTest { @Test From 4a3636326d7f10a3467afb2ec12561b784fa3ac0 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 17:51:07 +0800 Subject: [PATCH 104/120] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E7=9A=84=E9=A2=84=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=20#5155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/api/service/ServiceVarResource.kt | 13 +++ .../devops/process/utils/PipelineVarUtil.kt | 56 +++++++++++++ .../process/service/PipelineContextService.kt | 79 ++----------------- .../api/service/ServiceVarResourceImpl.kt | 4 + 4 files changed, 79 insertions(+), 73 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt index 1aa47741d23..e9daa1ec82c 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt @@ -43,6 +43,7 @@ import javax.ws.rs.core.MediaType @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) interface ServiceVarResource { + @ApiOperation("获取指定构建或指定流水线下的构建变量") @Path("/get_build_variable") @GET @@ -54,4 +55,16 @@ interface ServiceVarResource { @QueryParam("varName") varName: String? ): Result> + + @ApiOperation("获取指定构建或指定构建下的上下文变量") + @Path("/context/get") + @GET + fun getContextVar( + @ApiParam(value = "构建ID", required = true) + @QueryParam("buildId") + buildId: String, + @ApiParam(value = "变量名称", required = false) + @QueryParam("varName") + varName: String? + ): Result> } diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt index 14f8fdf42bb..7b0d7cec9eb 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt @@ -28,6 +28,20 @@ package com.tencent.devops.process.utils import com.tencent.devops.common.pipeline.enums.BuildFormPropertyType +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_BASE_REF +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_BASE_REPO_URL +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_COMMIT_MESSAGE +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_EVENT_CONTENT +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_HEAD_REF +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_HEAD_REPO_URL +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_MR_URL +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_REF +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_REPO +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_REPO_GROUP +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_REPO_NAME +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_REPO_URL +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_SHA +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_SHA_SHORT object PipelineVarUtil { @@ -101,8 +115,50 @@ object PipelineVarUtil { "report.dynamic.root.url" to REPORT_DYNAMIC_ROOT_URL ) + + /** + * CI预置上下文转换映射关系 + */ + private val contextVarMappingBuildVar = mapOf( + "ci.pipeline_id" to PIPELINE_ID, + "ci.pipeline_name" to PIPELINE_NAME, + "ci.actor" to PIPELINE_START_USER_ID, + "ci.build_id" to PIPELINE_BUILD_ID, + "ci.build_num" to PIPELINE_BUILD_NUM, + "ci.ref" to PIPELINE_GIT_REF, + "ci.head_ref" to PIPELINE_GIT_HEAD_REF, + "ci.base_ref" to PIPELINE_GIT_BASE_REF, + "ci.repo" to PIPELINE_GIT_REPO, + "ci.repo_name" to PIPELINE_GIT_REPO_NAME, + "ci.repo_group" to PIPELINE_GIT_REPO_GROUP, + "ci.event_content" to PIPELINE_GIT_EVENT_CONTENT, + "ci.sha" to PIPELINE_GIT_SHA, + "ci.sha_short" to PIPELINE_GIT_SHA_SHORT, + "ci.commit_message" to PIPELINE_GIT_COMMIT_MESSAGE, + "ci.repo_url" to PIPELINE_GIT_REPO_URL, + "ci.base_repo_url" to PIPELINE_GIT_BASE_REPO_URL, + "ci.head_repo_url" to PIPELINE_GIT_HEAD_REPO_URL, + "ci.mr_url" to PIPELINE_GIT_MR_URL + ) + private val newVarMappingOldVar = oldVarMappingNewVar.map { kv -> kv.value to kv.key }.toMap() + /** + * 填充CI预置变量 + */ + fun fillContextVarMap(varMap: MutableMap, buildVar: Map) { + contextVarMappingBuildVar.forEach { (contextKey, varKey) -> + if (!buildVar[varKey].isNullOrBlank()) varMap[contextKey] = buildVar[varKey]!! + } + } + + /** + * 填充CI预置变量 + */ + fun fetchContextInBuildVars(contextKey: String, buildVar: Map): String? { + return buildVar[contextVarMappingBuildVar[contextKey]] + } + /** * 填充旧变量名,兼容用户在流水线中旧的写法 */ diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt index 7b13f4d6ad9..79f5bab62c2 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt @@ -33,36 +33,18 @@ import com.tencent.devops.common.pipeline.container.Stage import com.tencent.devops.common.pipeline.container.VMBuildContainer import com.tencent.devops.common.pipeline.enums.BuildStatus import com.tencent.devops.common.pipeline.enums.StartType -import com.tencent.devops.common.pipeline.enums.VMBaseOS import com.tencent.devops.common.pipeline.pojo.element.Element import com.tencent.devops.common.pipeline.type.BuildType -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_BASE_REF -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_BASE_REPO_URL -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_COMMIT_MESSAGE import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_EVENT -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_EVENT_CONTENT -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_HEAD_REF -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_HEAD_REPO_URL -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_MR_URL -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_REF -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_REPO -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_REPO_GROUP -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_REPO_NAME -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_REPO_URL -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_SHA -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_SHA_SHORT import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_TIME_TRIGGER_KIND import com.tencent.devops.process.engine.control.ControlUtils import com.tencent.devops.process.engine.service.PipelineBuildDetailService -import com.tencent.devops.process.pojo.pipeline.ModelDetail -import com.tencent.devops.process.utils.PIPELINE_BUILD_ID -import com.tencent.devops.process.utils.PIPELINE_BUILD_NUM import com.tencent.devops.process.utils.PIPELINE_START_TYPE +import com.tencent.devops.process.utils.PipelineVarUtil import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service -@Suppress("ALL") @Service class PipelineContextService@Autowired constructor( private val pipelineBuildDetailService: PipelineBuildDetailService @@ -80,7 +62,7 @@ class PipelineContextService@Autowired constructor( buildStepContext(c, varMap, buildVar) } } - buildCiContext(varMap, modelDetail, buildVar) + buildCiContext(varMap, buildVar) } catch (ignore: Throwable) { logger.warn("BKSystemErrorMonitor|buildContextFailed|", ignore) } @@ -90,54 +72,17 @@ class PipelineContextService@Autowired constructor( private fun buildCiContext( varMap: MutableMap, - modelDetail: ModelDetail, buildVar: Map ) { - varMap["ci.pipeline_id"] = modelDetail.pipelineId - varMap["ci.pipeline_name"] = modelDetail.pipelineName - varMap["ci.actor"] = modelDetail.userId - if (!buildVar[PIPELINE_BUILD_ID].isNullOrBlank()) - varMap["ci.build_id"] = buildVar[PIPELINE_BUILD_ID]!! - if (!buildVar[PIPELINE_BUILD_NUM].isNullOrBlank()) - varMap["ci.build_num"] = buildVar[PIPELINE_BUILD_NUM]!! - if (!buildVar[PIPELINE_GIT_REF].isNullOrBlank()) - varMap["ci.ref"] = buildVar[PIPELINE_GIT_REF]!! - if (!buildVar[PIPELINE_GIT_HEAD_REF].isNullOrBlank()) - varMap["ci.head_ref"] = buildVar[PIPELINE_GIT_HEAD_REF]!! - if (!buildVar[PIPELINE_GIT_BASE_REF].isNullOrBlank()) - varMap["ci.base_ref"] = buildVar[PIPELINE_GIT_BASE_REF]!! - if (!buildVar[PIPELINE_GIT_REPO].isNullOrBlank()) - varMap["ci.repo"] = buildVar[PIPELINE_GIT_REPO]!! - if (!buildVar[PIPELINE_GIT_REPO_NAME].isNullOrBlank()) - varMap["ci.repo_name"] = buildVar[PIPELINE_GIT_REPO_NAME]!! - if (!buildVar[PIPELINE_GIT_REPO_GROUP].isNullOrBlank()) - varMap["ci.repo_group"] = buildVar[PIPELINE_GIT_REPO_GROUP]!! - if (!buildVar[PIPELINE_GIT_EVENT_CONTENT].isNullOrBlank()) - varMap["ci.event_content"] = buildVar[PIPELINE_GIT_EVENT_CONTENT]!! - if (!buildVar[PIPELINE_GIT_SHA].isNullOrBlank()) - varMap["ci.sha"] = buildVar[PIPELINE_GIT_SHA]!! - if (!buildVar[PIPELINE_GIT_SHA_SHORT].isNullOrBlank()) - varMap["ci.sha_short"] = buildVar[PIPELINE_GIT_SHA_SHORT]!! - if (!buildVar[PIPELINE_GIT_COMMIT_MESSAGE].isNullOrBlank()) - varMap["ci.commit_message"] = buildVar[PIPELINE_GIT_COMMIT_MESSAGE]!! + // 将流水线变量按预置映射关系做替换 + PipelineVarUtil.fillContextVarMap(varMap, buildVar) + // 特殊处理触发类型以免定时触发无法记录 if (buildVar[PIPELINE_START_TYPE] == StartType.TIME_TRIGGER.name) { varMap["ci.event"] = PIPELINE_GIT_TIME_TRIGGER_KIND } else if (!buildVar[PIPELINE_GIT_EVENT].isNullOrBlank()) { varMap["ci.event"] = buildVar[PIPELINE_GIT_EVENT]!! } - if (!buildVar[PIPELINE_GIT_REPO_URL].isNullOrBlank()) { - varMap["ci.repo_url"] = buildVar[PIPELINE_GIT_REPO_URL]!! - } - if (!buildVar[PIPELINE_GIT_BASE_REPO_URL].isNullOrBlank()) { - varMap["ci.base_repo_url"] = buildVar[PIPELINE_GIT_BASE_REPO_URL]!! - } - if (!buildVar[PIPELINE_GIT_HEAD_REPO_URL].isNullOrBlank()) { - varMap["ci.head_repo_url"] = buildVar[PIPELINE_GIT_HEAD_REPO_URL]!! - } - if (!buildVar[PIPELINE_GIT_MR_URL].isNullOrBlank()) { - varMap["ci.mr_url"] = buildVar[PIPELINE_GIT_MR_URL]!! - } } private fun buildStepContext( @@ -190,7 +135,7 @@ class PipelineContextService@Autowired constructor( buildVar.filterKeys { it.startsWith("steps.${e.id ?: ""}.outputs.") }.forEach { (t, u) -> outputMap["jobs.${c.jobId ?: c.id ?: ""}.$t"] = u } - buildVar.filterKeys { it.startsWith("jobs.${c.id ?: ""}.os") }.forEach { (t, u) -> + buildVar.filterKeys { it.startsWith("jobs.${c.id ?: ""}.os") }.forEach { (_, u) -> outputMap["jobs.${c.jobId ?: c.id ?: ""}.os"] = u } return outputMap @@ -214,18 +159,6 @@ class PipelineContextService@Autowired constructor( } } - private fun getOs(c: Container) = when (c) { - is VMBuildContainer -> { - c.baseOS.name - } - is NormalContainer -> { - VMBaseOS.LINUX.name - } - else -> { - "" - } - } - private fun getJobStatus(c: Container): String { return if (c is VMBuildContainer && c.status == BuildStatus.FAILED.name) { if (c.jobControlOption?.continueWhenFailed == true) { diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt index 0c2be08acd3..54603a74f66 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt @@ -40,4 +40,8 @@ class ServiceVarResourceImpl @Autowired constructor( return if (varName.isNullOrBlank()) Result(buildVariableService.getAllVariable(buildId)) else Result(mapOf(varName!! to (buildVariableService.getVariable(buildId, varName) ?: ""))) } + + override fun getContextVar(buildId: String, varName: String?): Result> { + TODO("Not yet implemented") + } } From ba43cacd2528773cf971d0d0eb15e8550bea17bd Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 19:41:09 +0800 Subject: [PATCH 105/120] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E7=9A=84=E9=A2=84=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=20#5155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/element/atom/ManualReviewParamTest.kt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt b/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt index cb6afcce76e..f12db60cfcd 100644 --- a/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt +++ b/src/backend/ci/core/common/common-pipeline/src/test/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParamTest.kt @@ -1,12 +1,12 @@ package com.tencent.devops.common.pipeline.pojo.element.atom -import org.junit.Assert import org.junit.Test internal class ManualReviewParamTest { @Test fun parseReviewParams() { + // TODO 待补全单测对比 val key = "p1" val list = listOf("a", "b") val map = mapOf(key to list.toString()) @@ -15,12 +15,6 @@ internal class ManualReviewParamTest { value = listOf("aaa", "bbb"), valueType = ManualReviewParamType.MULTIPLE ) - try { - println(param.parseValueWithType(map)) - println(param.parseValueWithType(map)?.javaClass) - } catch (e: Exception) { - e.printStackTrace() - } - Assert.assertTrue(param.parseValueWithType(map)?.equals(list) ?: false) + println(param.parseValueWithType(map)) } } From 676f9adc2587aaca6d9bcc6b84f64d9398863489 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 20:09:50 +0800 Subject: [PATCH 106/120] =?UTF-8?q?perf:=20Windows=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=9C=BA=E7=9A=84batch=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98=20#4601=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC=E4=BF=9D=E6=8C=81=E4=B8=BA=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=AD=97=E7=AC=A6=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../element/agent/WindowsScriptElement.kt | 2 +- .../worker/common/task/script/ScriptTask.kt | 7 +++- .../worker/common/utils/BatScriptUtil.kt | 18 +++++---- .../worker/common/utils/CommandLineUtils.kt | 40 ++++++++++--------- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt index 9e521353428..26e2bd55480 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/agent/WindowsScriptElement.kt @@ -47,7 +47,7 @@ data class WindowsScriptElement( @ApiModelProperty("脚本类型", required = true) val scriptType: BuildScriptType, @ApiModelProperty("字符集类型", required = false) - val charSetType: CharSetType? = CharSetType.UTF_8 + val charSetType: CharSetType? = null ) : Element(name, id, status) { diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt index 4accef6ee0a..4f7ddb14b35 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt @@ -37,6 +37,7 @@ import com.tencent.devops.store.pojo.app.BuildEnv import com.tencent.devops.worker.common.api.ApiFactory import com.tencent.devops.worker.common.api.quality.QualityGatewaySDKApi import com.tencent.devops.common.api.exception.TaskExecuteException +import com.tencent.devops.common.pipeline.enums.CharSetType import com.tencent.devops.process.utils.PIPELINE_START_USER_ID import com.tencent.devops.worker.common.api.archive.pojo.TokenType import com.tencent.devops.worker.common.env.AgentEnv @@ -65,7 +66,9 @@ open class ScriptTask : ITask() { errorType = ErrorType.USER, errorCode = ErrorCode.USER_INPUT_INVAILD ) -// val charSetType = taskParams["charSetType"] ?: CharSetType.UTF_8.name + + // #4601 如果task.json没有指定字符集选项则保持为空 + val charSetType = taskParams["charSetType"] val continueNoneZero = taskParams["continueNoneZero"] ?: "false" // 如果脚本执行失败之后可以选择归档这个问题 @@ -105,7 +108,7 @@ open class ScriptTask : ITask() { buildEnvs = takeBuildEnvs(buildTask, buildVariables), continueNoneZero = continueNoneZero.toBoolean(), errorMessage = "Fail to run the plugin", - charSetType = null + charSetType = charSetType ) } catch (ignore: Throwable) { logger.warn("Fail to run the script task", ignore) diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt index dd2f9b52e6b..11cd0a30c72 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/BatScriptUtil.kt @@ -27,11 +27,13 @@ package com.tencent.devops.worker.common.utils +import com.tencent.devops.common.pipeline.enums.CharSetType import com.tencent.devops.worker.common.CommonEnv import com.tencent.devops.worker.common.WORKSPACE_ENV import com.tencent.devops.worker.common.task.script.ScriptEnvUtils import org.slf4j.LoggerFactory import java.io.File +import java.nio.charset.Charset object BatScriptUtil { private const val setEnv = ":setEnv\r\n" + @@ -147,14 +149,16 @@ object BatScriptUtil { newValue = File(dir, ScriptEnvUtils.getQualityGatewayEnvFile()).canonicalPath )) -// val charset = when (charSetType?.let { CharSetType.valueOf(it) }) { -// CharSetType.UTF_8 -> Charsets.UTF_8 -// CharSetType.GBK -> Charset.forName(CharSetType.GBK.name) -// else -> Charsets.UTF_8 -// } -// logger.info("The default charset is $charset") + // #4601 没有指定编码字符集时采用获取系统的默认字符集 + val charset = when (charSetType?.let { CharSetType.valueOf(it) }) { + CharSetType.UTF_8 -> Charsets.UTF_8 + CharSetType.GBK -> Charset.forName(CharSetType.GBK.name) + else -> Charset.defaultCharset() + } + + logger.info("The default charset is $charset") - file.writeText(command.toString()) + file.writeText(command.toString(), charset) logger.info("start to run windows script - ($command)") return file } diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt index 9dff7dd09b9..d6715676858 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt @@ -31,9 +31,11 @@ import com.tencent.devops.common.api.enums.OSType import com.tencent.devops.common.api.exception.TaskExecuteException import com.tencent.devops.common.api.pojo.ErrorCode import com.tencent.devops.common.api.pojo.ErrorType +import com.tencent.devops.common.pipeline.enums.CharSetType import com.tencent.devops.worker.common.env.AgentEnv.getOS import com.tencent.devops.worker.common.logger.LoggerService import com.tencent.devops.worker.common.task.script.ScriptEnvUtils +import java.io.ByteArrayOutputStream import org.apache.commons.exec.CommandLine import org.apache.commons.exec.LogOutputStream import org.apache.commons.exec.PumpStreamHandler @@ -71,21 +73,21 @@ object CommandLineUtils { null } -// val charset = when (charSetType?.let { CharSetType.valueOf(it) }) { -// CharSetType.UTF_8 -> "UTF-8" -// CharSetType.GBK -> "GBK" -// else -> "UTF-8" -// } + val charset = when (charSetType?.let { CharSetType.valueOf(it) }) { + CharSetType.UTF_8 -> "UTF-8" + CharSetType.GBK -> "GBK" + else -> "UTF-8" + } val outputStream = object : LogOutputStream() { -// override fun processBuffer() { -// val privateStringField = LogOutputStream::class.java.getDeclaredField("buffer") -// privateStringField.isAccessible = true -// val buffer = privateStringField.get(this) as ByteArrayOutputStream -// processLine(buffer.toString(charset)) -// buffer.reset() -// } + override fun processBuffer() { + val privateStringField = LogOutputStream::class.java.getDeclaredField("buffer") + privateStringField.isAccessible = true + val buffer = privateStringField.get(this) as ByteArrayOutputStream + processLine(buffer.toString(charset)) + buffer.reset() + } override fun processLine(line: String?, level: Int) { if (line == null) @@ -107,13 +109,13 @@ object CommandLineUtils { val errorStream = object : LogOutputStream() { -// override fun processBuffer() { -// val privateStringField = LogOutputStream::class.java.getDeclaredField("buffer") -// privateStringField.isAccessible = true -// val buffer = privateStringField.get(this) as ByteArrayOutputStream -// processLine(buffer.toString(charset)) -// buffer.reset() -// } + override fun processBuffer() { + val privateStringField = LogOutputStream::class.java.getDeclaredField("buffer") + privateStringField.isAccessible = true + val buffer = privateStringField.get(this) as ByteArrayOutputStream + processLine(buffer.toString(charset)) + buffer.reset() + } override fun processLine(line: String?, level: Int) { if (line == null) { From b0af733fa737d6a83730005a68735c366bb52281 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 21:00:16 +0800 Subject: [PATCH 107/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019=20=E5=A2=9E=E5=8A=A0VAR=E8=A1=A8=E8=BD=AC=E5=9B=9E?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E5=AF=B9=E8=B1=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/pipeline/pojo/element/atom/ManualReviewParam.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt index 1d4434828eb..955c6f73715 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt @@ -51,8 +51,8 @@ data class ManualReviewParam( /** * 变量值处理,如果是已有值则直接使用,如果是变量引用则做替换 */ - fun parseValueWithType(variables: Map): Any? { - return if (variables.containsKey(key) && !variables[key].isNullOrBlank()) { + fun parseValueWithType(variables: Map) { + value = if (variables.containsKey(key) && !variables[key].isNullOrBlank()) { when (valueType) { ManualReviewParamType.BOOLEAN -> variables[key].toBoolean() ManualReviewParamType.MULTIPLE -> try { From 66aa70d1bb9d31fa1949f67a62a7923ac7d94e59 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 21:43:06 +0800 Subject: [PATCH 108/120] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E7=9A=84=E9=A2=84=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=20#5155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/api/builds/BuildVarResource.kt | 16 ++++++++++++ .../process/api/service/ServiceVarResource.kt | 4 +-- .../process/service/BuildVariableService.kt | 5 ++-- .../process/service/PipelineContextService.kt | 13 +++++++++- .../api/builds/BuildVarResourceImpl.kt | 11 +++++++- .../api/service/ServiceVarResourceImpl.kt | 25 +++++++++++++++---- 6 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt index 6d3b335de33..0135bf95a41 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt @@ -39,6 +39,7 @@ import javax.ws.rs.HeaderParam import javax.ws.rs.Path import javax.ws.rs.Produces import javax.ws.rs.Consumes +import javax.ws.rs.QueryParam import javax.ws.rs.core.MediaType @Api(tags = ["BUILD_VARIABLE"], description = "构建-构建参数") @@ -60,4 +61,19 @@ interface BuildVarResource { @HeaderParam(AUTH_HEADER_DEVOPS_PIPELINE_ID) pipelineId: String ): Result> + + @ApiOperation("获取指定构建或指定构建下的上下文变量") + @Path("/context/get") + @GET + fun getContextVar( + @ApiParam(value = "构建ID", required = true) + @QueryParam("buildId") + buildId: String, + @ApiParam(value = "项目ID", required = true) + @HeaderParam(AUTH_HEADER_DEVOPS_PROJECT_ID) + projectId: String, + @ApiParam(value = "流水线ID", required = true) + @HeaderParam(AUTH_HEADER_DEVOPS_PIPELINE_ID) + pipelineId: String + ): Result> } diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt index e9daa1ec82c..c1c581d4db6 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt @@ -64,7 +64,7 @@ interface ServiceVarResource { @QueryParam("buildId") buildId: String, @ApiParam(value = "变量名称", required = false) - @QueryParam("varName") - varName: String? + @QueryParam("contextName") + contextName: String? ): Result> } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/BuildVariableService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/BuildVariableService.kt index 635032131a5..b8566670044 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/BuildVariableService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/BuildVariableService.kt @@ -43,7 +43,6 @@ import org.jooq.impl.DSL import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service -@Suppress("ALL") @Service class BuildVariableService @Autowired constructor( private val commonDslContext: DSLContext, @@ -167,9 +166,9 @@ class BuildVariableService @Autowired constructor( ) { val watch = Watcher(id = "batchSetVariable| $pipelineId| $buildId") watch.start("replaceOldByNewVar") - val varMaps = variables.map { + val varMaps = variables.associate { it.key to Pair(it.value.toString(), it.valueType ?: BuildFormPropertyType.STRING) - }.toMap().toMutableMap() + }.toMutableMap() PipelineVarUtil.replaceOldByNewVar(varMaps) val pipelineBuildParameters = mutableListOf() diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt index 79f5bab62c2..d7b7435481a 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt @@ -46,7 +46,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service @Service -class PipelineContextService@Autowired constructor( +class PipelineContextService @Autowired constructor( private val pipelineBuildDetailService: PipelineBuildDetailService ) { private val logger = LoggerFactory.getLogger(PipelineContextService::class.java) @@ -70,6 +70,17 @@ class PipelineContextService@Autowired constructor( return varMap } + fun getAllBuildContext(buildVar: Map): Map { + val allContext = buildVar.toMutableMap() + // 将流水线变量按预置映射关系做替换 + PipelineVarUtil.fillContextVarMap(allContext, buildVar) + return allContext + } + + fun getBuildContext(buildVar: Map, contextName: String): String? { + return PipelineVarUtil.fetchContextInBuildVars(contextName, buildVar) + } + private fun buildCiContext( varMap: MutableMap, buildVar: Map diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt index 8e0069744b7..f974cdb65dd 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt @@ -35,6 +35,7 @@ import com.tencent.devops.common.web.RestResource import com.tencent.devops.process.engine.service.PipelineRepositoryService import com.tencent.devops.process.permission.PipelinePermissionService import com.tencent.devops.process.service.BuildVariableService +import com.tencent.devops.process.service.PipelineContextService import org.apache.commons.lang3.StringUtils import org.springframework.beans.factory.annotation.Autowired @@ -43,7 +44,8 @@ import org.springframework.beans.factory.annotation.Autowired class BuildVarResourceImpl @Autowired constructor( private val buildVariableService: BuildVariableService, private val pipelinePermissionService: PipelinePermissionService, - private val pipelineRepositoryService: PipelineRepositoryService + private val pipelineRepositoryService: PipelineRepositoryService, + private val pipelineContextService: PipelineContextService ) : BuildVarResource { override fun getBuildVar(buildId: String, projectId: String, pipelineId: String): Result> { checkParam(buildId = buildId, projectId = projectId, pipelineId = pipelineId) @@ -51,6 +53,13 @@ class BuildVarResourceImpl @Autowired constructor( return Result(buildVariableService.getAllVariable(buildId)) } + override fun getContextVar(buildId: String, projectId: String, pipelineId: String): Result> { + checkParam(buildId = buildId, projectId = projectId, pipelineId = pipelineId) + checkPermission(projectId = projectId, pipelineId = pipelineId) + val buildVars = buildVariableService.getAllVariable(buildId) + return Result(pipelineContextService.getAllBuildContext(buildVars)) + } + fun checkPermission(projectId: String, pipelineId: String) { val userId = pipelineRepositoryService.getPipelineInfo(projectId, pipelineId)?.lastModifyUser ?: "" if (!pipelinePermissionService.checkPipelinePermission( diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt index 54603a74f66..f5d92fdb1d8 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt @@ -30,18 +30,33 @@ package com.tencent.devops.process.api.service import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource import com.tencent.devops.process.service.BuildVariableService +import com.tencent.devops.process.service.PipelineContextService import org.springframework.beans.factory.annotation.Autowired @RestResource class ServiceVarResourceImpl @Autowired constructor( - private val buildVariableService: BuildVariableService + private val buildVariableService: BuildVariableService, + private val pipelineContextService: PipelineContextService ) : ServiceVarResource { override fun getBuildVar(buildId: String, varName: String?): Result> { - return if (varName.isNullOrBlank()) Result(buildVariableService.getAllVariable(buildId)) - else Result(mapOf(varName!! to (buildVariableService.getVariable(buildId, varName) ?: ""))) + return if (varName.isNullOrBlank()) { + Result(buildVariableService.getAllVariable(buildId)) + } else { + Result(mapOf(varName to (buildVariableService.getVariable(buildId, varName) ?: ""))) + } } - override fun getContextVar(buildId: String, varName: String?): Result> { - TODO("Not yet implemented") + override fun getContextVar(buildId: String, contextName: String?): Result> { + val buildVars = buildVariableService.getAllVariable(buildId) + return if (contextName.isNullOrBlank()) { + Result(pipelineContextService.getAllBuildContext(buildVars)) + } else { + val context = pipelineContextService.getBuildContext(buildVars, contextName) + if (context.isNullOrEmpty()) { + Result(mapOf()) + } else { + Result(mapOf(contextName to context)) + } + } } } From cc4113277faa4a9945853d62feed3a72c8fa7df3 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 13 Sep 2021 22:30:40 +0800 Subject: [PATCH 109/120] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E7=9A=84=E9=A2=84=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=20#5155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/api/builds/BuildBuildResource.kt | 15 +++++++++++++++ .../devops/process/api/builds/BuildVarResource.kt | 9 ++++++--- .../devops/process/utils/PipelineVarUtil.kt | 9 ++++++++- .../process/service/PipelineContextService.kt | 4 ++++ .../process/api/builds/BuildBuildResourceImpl.kt | 9 +++++++-- .../process/api/builds/BuildVarResourceImpl.kt | 11 ++++++++--- .../process/api/service/ServiceVarResourceImpl.kt | 2 +- 7 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResource.kt index 31443a9abde..173cfb31bc7 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResource.kt @@ -239,4 +239,19 @@ interface BuildBuildResource { @ApiParam("", required = true) redisAtomsBuild: RedisAtomsBuild ): Result + + @ApiOperation("获取子流水线变量") + @GET + @Path("/detailUrl") + fun getBuildDetailUrl( + @ApiParam("projectId", required = true) + @HeaderParam(AUTH_HEADER_DEVOPS_PROJECT_ID) + projectId: String, + @ApiParam("pipelineId", required = true) + @HeaderParam(AUTH_HEADER_DEVOPS_PIPELINE_ID) + pipelineId: String, + @ApiParam(value = "构建ID", required = true) + @HeaderParam(AUTH_HEADER_DEVOPS_BUILD_ID) + buildId: String + ): Result } diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt index 0135bf95a41..7405675cdf1 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt @@ -65,7 +65,7 @@ interface BuildVarResource { @ApiOperation("获取指定构建或指定构建下的上下文变量") @Path("/context/get") @GET - fun getContextVar( + fun getContextVariableByName( @ApiParam(value = "构建ID", required = true) @QueryParam("buildId") buildId: String, @@ -74,6 +74,9 @@ interface BuildVarResource { projectId: String, @ApiParam(value = "流水线ID", required = true) @HeaderParam(AUTH_HEADER_DEVOPS_PIPELINE_ID) - pipelineId: String - ): Result> + pipelineId: String, + @ApiParam(value = "变量名称", required = true) + @QueryParam("contextName") + contextName: String + ): Result } diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt index 7b0d7cec9eb..b0667da20b5 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt @@ -153,12 +153,19 @@ object PipelineVarUtil { } /** - * 填充CI预置变量 + * 获取CI预置变量 */ fun fetchContextInBuildVars(contextKey: String, buildVar: Map): String? { return buildVar[contextVarMappingBuildVar[contextKey]] } + /** + * 获取CI预置变量名 + */ + fun fetchVarName(contextKey: String): String? { + return contextVarMappingBuildVar[contextKey] + } + /** * 填充旧变量名,兼容用户在流水线中旧的写法 */ diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt index d7b7435481a..1e28abe93a5 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt @@ -81,6 +81,10 @@ class PipelineContextService @Autowired constructor( return PipelineVarUtil.fetchContextInBuildVars(contextName, buildVar) } + fun getBuildVarName(contextName: String): String? { + return PipelineVarUtil.fetchVarName(contextName) + } + private fun buildCiContext( varMap: MutableMap, buildVar: Map diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResourceImpl.kt index cbbfce91f88..deeb8e3a3d0 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResourceImpl.kt @@ -32,6 +32,7 @@ import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.pipeline.enums.BuildStatus import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.common.web.RestResource +import com.tencent.devops.process.bean.PipelineUrlBean import com.tencent.devops.process.service.builds.PipelineBuildFacadeService import com.tencent.devops.process.engine.service.PipelineVMBuildService import com.tencent.devops.process.pojo.BuildHistory @@ -43,12 +44,12 @@ import com.tencent.devops.process.pojo.pipeline.ModelDetail import com.tencent.devops.process.service.SubPipelineStartUpService import org.springframework.beans.factory.annotation.Autowired -@Suppress("ALL") @RestResource class BuildBuildResourceImpl @Autowired constructor( private val vmBuildService: PipelineVMBuildService, private val pipelineBuildFacadeService: PipelineBuildFacadeService, - private val subPipelineStartUpService: SubPipelineStartUpService + private val subPipelineStartUpService: SubPipelineStartUpService, + private val pipelineUrlBean: PipelineUrlBean ) : BuildBuildResource { @Deprecated("replace by BuildJobResourceImpl") @@ -172,6 +173,10 @@ class BuildBuildResourceImpl @Autowired constructor( return Result(pipelineBuildFacadeService.updateRedisAtoms(buildId, projectId, redisAtomsBuild)) } + override fun getBuildDetailUrl(projectId: String, pipelineId: String, buildId: String): Result { + return Result(pipelineUrlBean.genBuildDetailUrl(projectId, pipelineId, buildId)) + } + companion object { private fun checkParam(buildId: String, vmSeqId: String, vmName: String) { if (buildId.isBlank()) { diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt index f974cdb65dd..01858b00d0a 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt @@ -53,11 +53,16 @@ class BuildVarResourceImpl @Autowired constructor( return Result(buildVariableService.getAllVariable(buildId)) } - override fun getContextVar(buildId: String, projectId: String, pipelineId: String): Result> { + override fun getContextVariableByName( + buildId: String, + projectId: String, + pipelineId: String, + contextName: String, + ): Result { checkParam(buildId = buildId, projectId = projectId, pipelineId = pipelineId) checkPermission(projectId = projectId, pipelineId = pipelineId) - val buildVars = buildVariableService.getAllVariable(buildId) - return Result(pipelineContextService.getAllBuildContext(buildVars)) + val varName = pipelineContextService.getBuildVarName(contextName) ?: return Result(null) + return Result(buildVariableService.getVariable(buildId, varName)) } fun checkPermission(projectId: String, pipelineId: String) { diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt index f5d92fdb1d8..0424b075d5b 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResourceImpl.kt @@ -53,7 +53,7 @@ class ServiceVarResourceImpl @Autowired constructor( } else { val context = pipelineContextService.getBuildContext(buildVars, contextName) if (context.isNullOrEmpty()) { - Result(mapOf()) + Result(emptyMap()) } else { Result(mapOf(contextName to context)) } From 7d6f233d019f13e9f4c7bfd2ca8943b683b30d9f Mon Sep 17 00:00:00 2001 From: irwinsun Date: Tue, 14 Sep 2021 09:50:51 +0800 Subject: [PATCH 110/120] =?UTF-8?q?feat:=20=E6=9C=8D=E5=8A=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0OP=E6=8E=A5=E5=8F=A3=20#5144=20=E9=87=8D=E7=BD=AESQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sql/5001_ci_project-init_dml_mysql.sql | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/support-files/sql/5001_ci_project-init_dml_mysql.sql b/support-files/sql/5001_ci_project-init_dml_mysql.sql index 86312b07599..7395c9faa17 100755 --- a/support-files/sql/5001_ci_project-init_dml_mysql.sql +++ b/support-files/sql/5001_ci_project-init_dml_mysql.sql @@ -2,17 +2,17 @@ USE devops_ci_project; SET NAMES utf8mb4; -- 服务初始化 -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (1, '代码库(Code)', 'Code', 2, '/codelib/', '/codelib/', 'amd', '', '/codelib/codelib.css', '/codelib/codelib.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:47', 'system', '2019-06-05 17:12:47', b'0', '', '', 99, 'codelib', ''); -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (2, '流水线(Pipeline)', 'Pipeline', 2, '/pipelines/', '/pipeline/', 'iframe', '/pipeline/', '', '', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'0', NULL, NULL, 97, 'pipeline', '^\/console\/pipeline\/[^\/]+\/list(\/)?(allPipeline|myPipeline|collect)?$,^\/console\/pipeline\/[^\/]+\/[^\/]+\/detail\/[^\/]+(\/executeDetail)?$,^\/console\/pipeline\/[^\/]+\/[^\/]+\/history$'); -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (3, '制品库(Artifactory)', 'Artifactory', 2, '/artifactory/', '/artifactory/', 'amd', '', '/artifactory/artifactory.css', '/artifactory/artifactory.js', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:48', 'system', '2019-06-05 17:12:48', b'1', '', '', 96, 'artifactory', ''); -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (4, '凭证管理(Ticket)', 'Ticket', 8, '/ticket/', '/ticket/', 'amd', '', '/ticket/ticket.css', '/ticket/ticket.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:26', 'system', '2019-06-05 17:13:26', b'0', '', '', 95, 'ticket', ''); -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (5, '环境管理(Env)', 'Env', 4, '/environment/', '/environment/', 'amd', '', '/environment/environment.css', '/environment/environment.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:27', 'system', '2019-06-05 17:13:27', b'0', '', '', 94, 'environment', ''); -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (6, '研发商店(Store)', 'Store', 8, '/store/', '/store/', 'amd', '', '/store/store.css', '/store/store.js', b'0', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:29', 'system', '2019-06-05 17:13:29', b'0', '', '', 93, 'store', ''); -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (7, '质量红线(Gate)', 'Gate', 3, '/quality/', '/quality/', 'amd', '', '/quality/quality.css', '/quality/quality.js', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:13:29', 'system', '2019-06-05 17:13:29', b'1', '', '', 92, 'quality', ''); -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (8, '代码检查(CodeCC)', 'CodeCC', 2, '/codecc/', '/codecc/', 'iframe', '/codecc/', '', '', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 89, 'codecc', ''); -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (9, '度量数据(Measure)', 'Measure', 2, '/measure/', '/measure/', 'iframe', '/measure/', '', '', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 91, 'measure', ''); -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (10, '敏捷开发(Teamwork)', 'Teamwork', 1, '/teamwork/', '/teamwork/', 'amd', '', '/teamwork/teamwork.css', '/teamwork/teamwork.js', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:48', 'system', '2019-06-05 17:12:48', b'1', '', '', 90, 'teamwork', ''); -REPLACE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (100, '编译加速(Turbo)', 'Turbo', 2, '/turbo/', '/turbo/', 'amd', '', '', '', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 89, 'turbo', ''); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (1, '代码库(Code)', 'Code', 2, '/codelib/', '/codelib/', 'amd', '', '/codelib/codelib.css', '/codelib/codelib.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:47', 'system', '2019-06-05 17:12:47', b'0', '', '', 99, 'codelib', ''); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (2, '流水线(Pipeline)', 'Pipeline', 2, '/pipelines/', '/pipeline/', 'iframe', '/pipeline/', '', '', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'0', NULL, NULL, 97, 'pipeline', '^\/console\/pipeline\/[^\/]+\/list(\/)?(allPipeline|myPipeline|collect)?$,^\/console\/pipeline\/[^\/]+\/[^\/]+\/detail\/[^\/]+(\/executeDetail)?$,^\/console\/pipeline\/[^\/]+\/[^\/]+\/history$'); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (3, '制品库(Artifactory)', 'Artifactory', 2, '/artifactory/', '/artifactory/', 'amd', '', '/artifactory/artifactory.css', '/artifactory/artifactory.js', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:48', 'system', '2019-06-05 17:12:48', b'1', '', '', 96, 'artifactory', ''); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (4, '凭证管理(Ticket)', 'Ticket', 8, '/ticket/', '/ticket/', 'amd', '', '/ticket/ticket.css', '/ticket/ticket.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:26', 'system', '2019-06-05 17:13:26', b'0', '', '', 95, 'ticket', ''); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (5, '环境管理(Env)', 'Env', 4, '/environment/', '/environment/', 'amd', '', '/environment/environment.css', '/environment/environment.js', b'1', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:27', 'system', '2019-06-05 17:13:27', b'0', '', '', 94, 'environment', ''); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (6, '研发商店(Store)', 'Store', 8, '/store/', '/store/', 'amd', '', '/store/store.css', '/store/store.js', b'0', b'1', 'path', 'ok', 'system', '2019-06-05 17:13:29', 'system', '2019-06-05 17:13:29', b'0', '', '', 93, 'store', ''); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (7, '质量红线(Gate)', 'Gate', 3, '/quality/', '/quality/', 'amd', '', '/quality/quality.css', '/quality/quality.js', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:13:29', 'system', '2019-06-05 17:13:29', b'1', '', '', 92, 'quality', ''); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (8, '代码检查(CodeCC)', 'CodeCC', 2, '/codecc/', '/codecc/', 'iframe', '/codecc/', '', '', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 89, 'codecc', ''); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (9, '度量数据(Measure)', 'Measure', 2, '/measure/', '/measure/', 'iframe', '/measure/', '', '', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 91, 'measure', ''); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (10, '敏捷开发(Teamwork)', 'Teamwork', 1, '/teamwork/', '/teamwork/', 'amd', '', '/teamwork/teamwork.css', '/teamwork/teamwork.js', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:48', 'system', '2019-06-05 17:12:48', b'1', '', '', 90, 'teamwork', ''); +INSERT IGNORE INTO `T_SERVICE` (`id`, `name`, `english_name`, `service_type_id`, `link`, `link_new`, `inject_type`, `iframe_url`, `css_url`, `js_url`, `show_project_list`, `show_nav`, `project_id_type`, `status`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `gray_css_url`, `gray_js_url`, `weight`, `logo_url`, `web_socket`) VALUES (100, '编译加速(Turbo)', 'Turbo', 2, '/turbo/', '/turbo/', 'amd', '', '', '', b'1', b'1', 'path', 'planning', 'system', '2019-06-05 17:12:47', NULL, '2019-06-05 17:12:47', b'1', NULL, NULL, 89, 'turbo', ''); -- 服务分类初始化 INSERT IGNORE INTO `T_SERVICE_TYPE` (`id`, `title`, `english_title`, `created_user`, `created_time`, `updated_user`, `updated_time`, `deleted`, `weight`) VALUES (1, '项目管理', 'Case', 'system', '2019-06-05 17:13:55', 'system', '2019-06-05 17:13:55', b'1', NULL); From 71325d23738d8702cdce214f43135184a594e1b0 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Tue, 14 Sep 2021 11:31:11 +0800 Subject: [PATCH 111/120] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E7=9A=84=E9=A2=84=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=20#5155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/process/utils/PipelineVarUtil.kt | 5 +++-- .../devops/process/api/builds/BuildVarResourceImpl.kt | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt index b0667da20b5..5914ebce419 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt @@ -31,6 +31,7 @@ import com.tencent.devops.common.pipeline.enums.BuildFormPropertyType import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_BASE_REF import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_BASE_REPO_URL import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_COMMIT_MESSAGE +import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_EVENT import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_EVENT_CONTENT import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_HEAD_REF import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_HEAD_REPO_URL @@ -197,14 +198,14 @@ object PipelineVarUtil { // 从新转旧: 新流水线产生的变量 兼容在旧流水线中已经使用到的旧变量 val oldVarName = newVarToOldVar(it.key) if (!oldVarName.isNullOrBlank()) { - allVars[oldVarName!!] = it.value // 旧变量写入,如果之前有了,则替换 + allVars[oldVarName] = it.value // 旧变量写入,如果之前有了,则替换 allVars[it.key] = it.value // 新变量仍然写入 } else { // 从旧转新: 兼容从旧入口写入的数据转到新的流水线运行 val newVarName = oldVarToNewVar(it.key) // 新变量已经存在,忽略旧变量转换 if (!newVarName.isNullOrBlank() && !vars.contains(newVarName)) { - allVars[newVarName!!] = it.value + allVars[newVarName] = it.value } // 已经存在从新变量转化过来的旧变量,则不覆盖,放弃 if (!allVars.containsKey(it.key)) { diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt index 01858b00d0a..24283377d1f 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt @@ -61,7 +61,8 @@ class BuildVarResourceImpl @Autowired constructor( ): Result { checkParam(buildId = buildId, projectId = projectId, pipelineId = pipelineId) checkPermission(projectId = projectId, pipelineId = pipelineId) - val varName = pipelineContextService.getBuildVarName(contextName) ?: return Result(null) + // 如果无法替换上下文预置变量则保持原变量名去查取 + val varName = pipelineContextService.getBuildVarName(contextName) ?: contextName return Result(buildVariableService.getVariable(buildId, varName)) } From 07ef3401b7f2328be0edef29f64ed41aa8181687 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Tue, 14 Sep 2021 11:44:22 +0800 Subject: [PATCH 112/120] =?UTF-8?q?perf:=20Windows=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=9C=BA=E7=9A=84batch=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98=20#4601=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC=E4=BF=9D=E6=8C=81=E4=B8=BA=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=AD=97=E7=AC=A6=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/worker/common/utils/CommandLineUtils.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt index d6715676858..088c799e4e1 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/utils/CommandLineUtils.kt @@ -41,6 +41,7 @@ import org.apache.commons.exec.LogOutputStream import org.apache.commons.exec.PumpStreamHandler import org.slf4j.LoggerFactory import java.io.File +import java.nio.charset.Charset import java.util.regex.Pattern object CommandLineUtils { @@ -76,7 +77,7 @@ object CommandLineUtils { val charset = when (charSetType?.let { CharSetType.valueOf(it) }) { CharSetType.UTF_8 -> "UTF-8" CharSetType.GBK -> "GBK" - else -> "UTF-8" + else -> Charset.defaultCharset().name() } val outputStream = object : LogOutputStream() { From 86b94afbe34d0e353a95d56b351450062dffe556 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Tue, 14 Sep 2021 11:47:24 +0800 Subject: [PATCH 113/120] =?UTF-8?q?perf:=20Windows=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=9C=BA=E7=9A=84batch=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98=20#4601=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC=E4=BF=9D=E6=8C=81=E4=B8=BA=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=AD=97=E7=AC=A6=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/worker/common/task/script/ScriptTask.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt index 52830bf1e34..3246bf7c7d4 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt @@ -34,11 +34,11 @@ import com.tencent.devops.common.pipeline.pojo.element.agent.LinuxScriptElement import com.tencent.devops.common.pipeline.pojo.element.agent.WindowsScriptElement import com.tencent.devops.process.pojo.BuildTask import com.tencent.devops.process.pojo.BuildVariables +import com.tencent.devops.process.utils.PIPELINE_START_USER_ID import com.tencent.devops.store.pojo.app.BuildEnv import com.tencent.devops.worker.common.api.ApiFactory -import com.tencent.devops.worker.common.api.quality.QualityGatewaySDKApi -import com.tencent.devops.process.utils.PIPELINE_START_USER_ID import com.tencent.devops.worker.common.api.archive.pojo.TokenType +import com.tencent.devops.worker.common.api.quality.QualityGatewaySDKApi import com.tencent.devops.worker.common.env.AgentEnv import com.tencent.devops.worker.common.logger.LoggerService import com.tencent.devops.worker.common.service.RepoServiceFactory @@ -46,9 +46,9 @@ import com.tencent.devops.worker.common.task.ITask import com.tencent.devops.worker.common.task.script.bat.WindowsScriptTask import com.tencent.devops.worker.common.utils.ArchiveUtils import com.tencent.devops.worker.common.utils.TaskUtil -import org.slf4j.LoggerFactory import java.io.File import java.net.URLDecoder +import org.slf4j.LoggerFactory /** * 构建脚本任务 @@ -147,7 +147,7 @@ open class ScriptTask : ITask() { open fun takeBuildEnvs( buildTask: BuildTask, - buildVariables: BuildVariables + buildVariables: BuildVariables, ): List = buildVariables.buildEnvs private fun setGatewayValue(workspace: File) { From 6059d257288a44918543191be8a441e214078647 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Tue, 14 Sep 2021 11:49:12 +0800 Subject: [PATCH 114/120] =?UTF-8?q?perf:=20Windows=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=9C=BA=E7=9A=84batch=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98=20#4601=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC=E4=BF=9D=E6=8C=81=E4=B8=BA=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=AD=97=E7=AC=A6=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/worker/common/task/script/ScriptTask.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt index 3246bf7c7d4..1642ecac60d 100644 --- a/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt +++ b/src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/task/script/ScriptTask.kt @@ -147,7 +147,7 @@ open class ScriptTask : ITask() { open fun takeBuildEnvs( buildTask: BuildTask, - buildVariables: BuildVariables, + buildVariables: BuildVariables ): List = buildVariables.buildEnvs private fun setGatewayValue(workspace: File) { From f99cdf6601b83ebbfe073aec5aaa1a99b8ed53d7 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Tue, 14 Sep 2021 12:26:19 +0800 Subject: [PATCH 115/120] =?UTF-8?q?feat:=20stage=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=BA=A2=E7=BA=BF=E7=9A=84=E5=87=86=E5=87=BA?= =?UTF-8?q?=20#5019=20=E8=B0=83=E6=95=B4=E9=83=A8=E5=88=86=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/element/atom/ManualReviewParam.kt | 7 +---- .../engine/service/PipelineStageService.kt | 9 +++--- .../stage/impl/CheckPauseReviewStageCmd.kt | 28 +++++++++---------- .../impl/UpdateStateForStageCmdFinally.kt | 24 ++++++++-------- 4 files changed, 31 insertions(+), 37 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt index 955c6f73715..5601674591b 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/atom/ManualReviewParam.kt @@ -55,12 +55,7 @@ data class ManualReviewParam( value = if (variables.containsKey(key) && !variables[key].isNullOrBlank()) { when (valueType) { ManualReviewParamType.BOOLEAN -> variables[key].toBoolean() - ManualReviewParamType.MULTIPLE -> try { - // TODO 将入库保存的字符串转回数组对象 - throw Exception("${variables[key]} mapping error.") - } catch (ignore: Throwable) { - variables[key] - } + // TODO 将入库保存的字符串转回数组对象 else -> variables[key] } } else { diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt index 1f85d1763bc..22bb6bdf397 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineStageService.kt @@ -409,11 +409,10 @@ class PipelineStageService @Autowired constructor( } /** - * @param event 流水线引擎Stage事件 - * @param stage 该Stage的当前配置属性 - * @param variables 上下文中的环境变量 - * @param inOrOut 准入为true,准出为false - * @return 是否通过红线检查 + * 流水线引擎Stage事件 [event] + * 该Stage的当前配置属性 [stage] + * 上下文中的环境变量 [variables] + * 控制当前检查是准入还是准出使用 [inOrOut] 准入为true,准出为false */ fun checkQualityPassed( event: PipelineBuildStageEvent, diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt index 1b3b1469142..c82b28ed92e 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/CheckPauseReviewStageCmd.kt @@ -69,20 +69,20 @@ class CheckPauseReviewStageCmd( } else if (commandContext.buildStatus.isReadyToRun()) { // #5019 只用第一次进入时做准入质量红线检查,如果是审核后的检查则跳过红线 - if (stage.checkIn?.ruleIds.isNullOrEmpty() || event.source == BS_MANUAL_START_STAGE) { - LOG.info("ENGINE|${event.buildId}|${event.source}|SKIP_QUALITY_CHECK_IN|${event.stageId}") - } else if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { - LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") - commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_PASS.name - pipelineStageService.checkQualityPassStage(event.userId, commandContext.stage) - } else { - // #4732 优先判断是否能通过质量红线检查 - LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_FAILED|${event.stageId}") - commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_FAIL.name - commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL - commandContext.latestSummary = "s(${stage.stageId}) failed with QUALITY_CHECK_IN" - commandContext.cmdFlowState = CmdFlowState.FINALLY - return + if (stage.checkIn?.ruleIds?.isNotEmpty() == true && event.source != BS_MANUAL_START_STAGE) { + if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, true)) { + LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") + commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_PASS.name + pipelineStageService.checkQualityPassStage(event.userId, commandContext.stage) + } else { + // #4732 优先判断是否能通过质量红线检查 + LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_FAILED|${event.stageId}") + commandContext.stage.checkIn?.status = BuildStatus.QUALITY_CHECK_FAIL.name + commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL + commandContext.latestSummary = "s(${stage.stageId}) failed with QUALITY_CHECK_IN" + commandContext.cmdFlowState = CmdFlowState.FINALLY + return + } } // 人工审核 diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt index 891b0a54133..c835983476d 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/stage/impl/UpdateStateForStageCmdFinally.kt @@ -131,18 +131,18 @@ class UpdateStateForStageCmdFinally( } // #5019 在结束阶段做stage准出判断 - if (stage.checkOut?.ruleIds.isNullOrEmpty()) { - LOG.info("ENGINE|${event.buildId}|${event.source}|SKIP_STAGE_QUALITY_CHECK_OUT|${event.stageId}") - } else if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { - LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") - commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_PASS.name - pipelineStageService.checkQualityPassStage(userId = event.userId, buildStage = commandContext.stage) - } else { - commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_FAIL.name - commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL - commandContext.latestSummary = "s(${stage.stageId}) failed with QUALITY_CHECK_OUT" - pipelineStageService.checkQualityFailStage(userId = event.userId, buildStage = commandContext.stage) - return finishBuild(commandContext = commandContext) + if (stage.checkOut?.ruleIds?.isNotEmpty() == true) { + if (pipelineStageService.checkQualityPassed(event, stage, commandContext.variables, false)) { + LOG.info("ENGINE|${event.buildId}|${event.source}|STAGE_QUALITY_CHECK_IN_PASSED|${event.stageId}") + commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_PASS.name + pipelineStageService.checkQualityPassStage(userId = event.userId, buildStage = commandContext.stage) + } else { + commandContext.stage.checkOut?.status = BuildStatus.QUALITY_CHECK_FAIL.name + commandContext.buildStatus = BuildStatus.QUALITY_CHECK_FAIL + commandContext.latestSummary = "s(${stage.stageId}) failed with QUALITY_CHECK_OUT" + pipelineStageService.checkQualityFailStage(userId = event.userId, buildStage = commandContext.stage) + return finishBuild(commandContext = commandContext) + } } if (nextStage != null) { From cc7723dc3995b13552d3b5f0b497c6cb3f45bdce Mon Sep 17 00:00:00 2001 From: royalhuang Date: Tue, 14 Sep 2021 12:31:32 +0800 Subject: [PATCH 116/120] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E7=9A=84=E9=A2=84=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=20#5155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt | 2 -- .../tencent/devops/process/api/builds/BuildVarResourceImpl.kt | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt index 5914ebce419..fc2880fc765 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt @@ -31,7 +31,6 @@ import com.tencent.devops.common.pipeline.enums.BuildFormPropertyType import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_BASE_REF import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_BASE_REPO_URL import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_COMMIT_MESSAGE -import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_EVENT import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_EVENT_CONTENT import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_HEAD_REF import com.tencent.devops.common.pipeline.utils.PIPELINE_GIT_HEAD_REPO_URL @@ -116,7 +115,6 @@ object PipelineVarUtil { "report.dynamic.root.url" to REPORT_DYNAMIC_ROOT_URL ) - /** * CI预置上下文转换映射关系 */ diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt index 24283377d1f..7e43ae8b29d 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResourceImpl.kt @@ -57,7 +57,7 @@ class BuildVarResourceImpl @Autowired constructor( buildId: String, projectId: String, pipelineId: String, - contextName: String, + contextName: String ): Result { checkParam(buildId = buildId, projectId = projectId, pipelineId = pipelineId) checkPermission(projectId = projectId, pipelineId = pipelineId) From 8b4078db0d9ee4686981ceba813f23ece8bb7f3c Mon Sep 17 00:00:00 2001 From: royalhuang Date: Tue, 14 Sep 2021 13:41:17 +0800 Subject: [PATCH 117/120] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E7=9A=84=E9=A2=84=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=20#5155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/process/service/PipelineContextService.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt index 1e28abe93a5..4dfc796f113 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/PipelineContextService.kt @@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service +@Suppress("ComplexMethod") @Service class PipelineContextService @Autowired constructor( private val pipelineBuildDetailService: PipelineBuildDetailService From 133797b93402a992b96c9fab78e7a7973407569e Mon Sep 17 00:00:00 2001 From: royalhuang Date: Tue, 14 Sep 2021 15:20:42 +0800 Subject: [PATCH 118/120] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E7=9A=84=E9=A2=84=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=20#5155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/process/api/builds/BuildVarResource.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt index 7405675cdf1..8b9771aa251 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt @@ -67,7 +67,7 @@ interface BuildVarResource { @GET fun getContextVariableByName( @ApiParam(value = "构建ID", required = true) - @QueryParam("buildId") + @HeaderParam(AUTH_HEADER_DEVOPS_BUILD_ID) buildId: String, @ApiParam(value = "项目ID", required = true) @HeaderParam(AUTH_HEADER_DEVOPS_PROJECT_ID) From 2c9c60f40a4457652068bd8a8b6706d2ab895c8e Mon Sep 17 00:00:00 2001 From: ddlin0719 Date: Tue, 14 Sep 2021 15:39:14 +0800 Subject: [PATCH 119/120] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9C=BA=E5=88=B6=E5=8F=AF=E9=85=8D=E7=BD=AE=20#5091?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/atom/plugin/MarketBuildUtils.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt index eb290b4634a..4ccc11613a9 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/atom/plugin/MarketBuildUtils.kt @@ -65,7 +65,9 @@ object MarketBuildUtils { val arr = atomCodeAndVersion.split("|") val atomCode = arr[0] val atomVersion = arr[1] - return client.get(ServiceAtomResource::class).getAtomVersionInfo(atomCode, atomVersion).data + val atom = client.get(ServiceAtomResource::class).getAtomVersionInfo(atomCode, atomVersion).data + logger.info("get atom version info for : $atomCode, $atomVersion, $atom") + return atom } }) @@ -80,7 +82,7 @@ object MarketBuildUtils { fun beforeDelete(inputMap: Map, atomCode: String, atomVersion: String, param: BeforeDeleteParam) { marketBuildExecutorService.execute { - logger.info("start to do before delete: $inputMap, $atomCode, $atomVersion") + logger.info("start to do before delete: $atomCode, $atomVersion, $param") val bkAtomHookUrl = inputMap.getOrDefault( BK_ATOM_HOOK_URL, getDefaultHookUrl(atomCode = atomCode, atomVersion = atomVersion, channelCode = param.channelCode) From b7b68946f104d9a75249256f177362721cc01b63 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Tue, 14 Sep 2021 15:59:39 +0800 Subject: [PATCH 120/120] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E7=9A=84=E9=A2=84=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=20#5155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/process/api/builds/BuildBuildResource.kt | 4 ++-- .../com/tencent/devops/process/api/builds/BuildVarResource.kt | 2 +- .../tencent/devops/process/api/service/ServiceVarResource.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResource.kt index 173cfb31bc7..d02a858dc58 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildBuildResource.kt @@ -240,9 +240,9 @@ interface BuildBuildResource { redisAtomsBuild: RedisAtomsBuild ): Result - @ApiOperation("获取子流水线变量") + @ApiOperation("获取当前构建的构建详情页") @GET - @Path("/detailUrl") + @Path("/detail_url") fun getBuildDetailUrl( @ApiParam("projectId", required = true) @HeaderParam(AUTH_HEADER_DEVOPS_PROJECT_ID) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt index 8b9771aa251..0b416e16d39 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/builds/BuildVarResource.kt @@ -63,7 +63,7 @@ interface BuildVarResource { ): Result> @ApiOperation("获取指定构建或指定构建下的上下文变量") - @Path("/context/get") + @Path("/get_build_context") @GET fun getContextVariableByName( @ApiParam(value = "构建ID", required = true) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt index c1c581d4db6..b4700f2b391 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceVarResource.kt @@ -57,7 +57,7 @@ interface ServiceVarResource { ): Result> @ApiOperation("获取指定构建或指定构建下的上下文变量") - @Path("/context/get") + @Path("/get_build_context") @GET fun getContextVar( @ApiParam(value = "构建ID", required = true)