Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 17
- name: Set up Node JS
uses: actions/setup-node@v2
with:
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/publish-snapshot-jdk17.yml

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Trigger building on push event, and publishing snapshot package if in base repository
name: Build and Publish snapshot package
on:
workflow_dispatch:
push:
branches:
- master
Expand All @@ -13,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 17
- name: Set up Node JS
uses: actions/setup-node@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jobs:
- uses: actions/checkout@v2
with:
ref: v${{ needs.release.outputs.RELEASE_VERSION }}
- name: Set up JDK 8
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 17
- name: Set up Node JS
uses: actions/setup-node@v2
with:
Expand All @@ -68,4 +68,4 @@ jobs:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
run: ./gradlew publish
run: ./gradlew publish
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@

## 核心依赖

| 依赖 | 版本 |
| ------------ | ------------- |
| JDK | 1.8+ |
| Kotlin | 1.6.21 |
| Gradle | 6.8.3 |
| Spring Boot | 2.4.5 |
| Spring Cloud | 2020.0.2 |
| 依赖 | 版本 |
| ------------ |----------|
| JDK | 17 |
| Kotlin | 1.8.22 |
| Gradle | 7.6.3 |
| Spring Boot | 3.0.11 |
| Spring Cloud | 2022.0.4 |

## 示例

Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ allprojects {

repositories {
mavenCentral()
jcenter()
gradlePluginPortal()
}

Expand Down
7 changes: 4 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ plugins {

repositories {
mavenCentral()
jcenter()
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
incremental = false
}
}
12 changes: 6 additions & 6 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
object Versions {
const val Jib: String = "3.2.0"
const val Java = "1.8"
const val Kotlin = "1.6.21"
const val SpringBoot = "2.6.13"
const val SpringCloud = "2021.0.5"
const val DependencyManagement = "1.0.15.RELEASE"
const val Java = "17"
const val Kotlin = "1.8.22"
const val SpringBoot = "3.3.2"
const val SpringCloud = "2023.0.3"
const val DependencyManagement = "1.1.6"
const val GradleNexusPublish = "1.3.0"
const val KtLint = "0.41.0"
const val KtLint = "0.50.0"
const val DevopsReleasePlugin = "0.0.9"
}
7 changes: 7 additions & 0 deletions devops-boot-project/devops-boot-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ subprojects {
}

tasks {
compileJava {
sourceCompatibility = Versions.Java
targetCompatibility = Versions.Java
}
compileKotlin {
kotlinOptions.freeCompilerArgs = listOf("-Xjsr305=strict", "-java-parameters")
kotlinOptions.jvmTarget = Versions.Java
Expand All @@ -41,5 +45,8 @@ subprojects {
test {
useJUnitPlatform()
}
withType(org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask::class.java).configureEach {
kotlinOptions.jvmTarget = Versions.Java
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description = "DevOps Boot Api"

dependencies {
api("io.swagger:swagger-annotations")
api("io.swagger:swagger-models")
api("io.swagger.core.v3:swagger-annotations")
api("io.swagger.core.v3:swagger-models")
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.tencent.devops.api.pojo

import com.fasterxml.jackson.annotation.JsonIgnore
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty
import io.swagger.v3.oas.annotations.media.Schema

@ApiModel("数据返回包装模型")
@Schema(description = "数据返回包装模型")
data class Response<out T>(
@ApiModelProperty("返回码")
@Schema(description = "返回码")
val code: Int,
@ApiModelProperty("提示信息")
@Schema(description = "提示信息")
val message: String? = null,
@ApiModelProperty("数据")
@Schema(description = "数据")
val data: T? = null
) {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.streams.toList
import java.util.stream.Collectors

/**
* 插件扫描器默认实现
Expand All @@ -22,7 +22,7 @@ class DefaultPluginScanner(
logger.error("Failed to load plugin, Path[$pluginDir] is not a directory.")
return emptyList()
}
return Files.walk(pluginDir).filter { it.toString().endsWith(".jar") }.toList()
return Files.walk(pluginDir).filter { it.toString().endsWith(".jar") }.collect(Collectors.toList())
}

override fun scan(id: String): Path? {
Expand All @@ -35,7 +35,7 @@ class DefaultPluginScanner(
val filename = it.toString()
val name = filename.substringAfter("-").substringBeforeLast("-")
name == id
}.toList().firstOrNull()
}.collect(Collectors.toList()).firstOrNull()
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import com.tencent.devops.plugin.api.EXTENSION_LOCATION
import com.tencent.devops.plugin.api.ExtensionType
import com.tencent.devops.plugin.api.PluginInfo
import com.tencent.devops.plugin.api.PluginMetadata
import org.springframework.boot.loader.LaunchedURLClassLoader
import org.springframework.boot.loader.archive.Archive
import org.springframework.boot.loader.archive.JarFileArchive
import org.springframework.boot.loader.launch.LaunchedClassLoader
import org.springframework.boot.loader.launch.Archive
import java.io.IOException
import java.net.URL
import java.nio.file.Files
import java.nio.file.Path
import java.security.MessageDigest
import java.util.LinkedList
import java.util.Properties
import java.util.function.Predicate
import java.util.jar.JarFile

/**
Expand Down Expand Up @@ -115,13 +115,13 @@ class PluginLoader(
}

private fun createClassloader(pluginPath: Path): ClassLoader {
val jarArchive = JarFileArchive(pluginPath.toFile())
val archives = jarArchive.getNestedArchives(searchFilter, nestedFilter)
val urls = mutableListOf<URL>(jarArchive.url)
val jarArchive = Archive.create(pluginPath.toFile())
val archives = jarArchive.getClassPathUrls(includeFilter, directorySearchFilter)
val urls = mutableListOf<URL>()
archives.forEach {
urls.add(it.url)
urls.add(it)
}
return LaunchedURLClassLoader(false, jarArchive, urls.toTypedArray(), javaClass.classLoader)
return LaunchedClassLoader(false, jarArchive, urls.toTypedArray(), javaClass.classLoader)
}

companion object {
Expand All @@ -131,9 +131,11 @@ class PluginLoader(
private const val PLUGIN_SCOPE = "Plugin-Scope"
private const val PLUGIN_AUTHOR = "Plugin-Author"
private const val PLUGIN_DESCRIPTION = "Plugin-Description"
val searchFilter = Archive.EntryFilter { entry -> entry.name.startsWith("lib/") }
val nestedFilter = Archive.EntryFilter { entry ->
!entry.isDirectory && entry.name.startsWith("lib/")
val directorySearchFilter = Predicate<Archive.Entry>() { entry ->
entry.name().startsWith("lib/")
}
val includeFilter = Predicate<Archive.Entry>() { entry ->
!entry.isDirectory && entry.name().startsWith("lib/")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ package com.tencent.devops.stream.binder.pulsar.util
import com.tencent.devops.stream.binder.pulsar.constant.DLQ
import com.tencent.devops.stream.binder.pulsar.constant.PATH_SPLIT
import com.tencent.devops.stream.binder.pulsar.constant.RETRY
import jakarta.validation.constraints.NotBlank
import org.apache.pulsar.client.api.DeadLetterPolicy
import java.io.UnsupportedEncodingException
import java.util.StringJoiner
import javax.validation.constraints.NotBlank

object PulsarUtils {

Expand All @@ -58,12 +58,12 @@ object PulsarUtils {

private fun validateByte(b: Byte): Boolean {
return (
b >= 'a'.toByte() && b <= 'z'.toByte() ||
b >= 'A'.toByte() && b <= 'Z'.toByte() ||
b >= '0'.toByte() && b <= '9'.toByte() ||
b == '.'.toByte() || b == '-'.toByte() ||
b == '_'.toByte()
)
b >= 'a'.code.toByte() && b <= 'z'.code.toByte() ||
b >= 'A'.code.toByte() && b <= 'Z'.code.toByte() ||
b >= '0'.code.toByte() && b <= '9'.code.toByte() ||
b == '.'.code.toByte() || b == '-'.code.toByte() ||
b == '_'.code.toByte()
)
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tencent.devops.schedule.api

import com.tencent.devops.schedule.constants.SCHEDULE_RPC_AUTH_HEADER
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse
import org.slf4j.LoggerFactory
import org.springframework.http.HttpStatus
import org.springframework.web.servlet.HandlerInterceptor
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

class RpcAuthWebInterceptor(
private val accessToken: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package com.tencent.devops.schedule.config
import com.tencent.devops.api.pojo.Response
import com.tencent.devops.schedule.constants.SCHEDULE_API_AUTH_HEADER
import com.tencent.devops.schedule.utils.JwtUtils
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse
import org.slf4j.LoggerFactory
import org.springframework.http.HttpMethod
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType.APPLICATION_JSON_VALUE
import org.springframework.web.servlet.HandlerInterceptor
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

/**
* 调度中心认证拦截器
Expand All @@ -21,7 +21,7 @@ class ScheduleServerAuthInterceptor(
private val signingKey = JwtUtils.createSigningKey(authProperties.secretKey)

override fun preHandle(request: HttpServletRequest, response: HttpServletResponse, handler: Any): Boolean {
if (request.method == HttpMethod.OPTIONS.name) {
if (request.method == HttpMethod.OPTIONS.name()) {
return true
}
val jwtToken = request.getHeader(SCHEDULE_API_AUTH_HEADER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ open class DefaultWorkerManager(
require(address.isNotBlank())
require(group.isNotBlank())
val status = WorkerStatusEnum.ofCode(param.status)
when(status) {
when (status) {
WorkerStatusEnum.RUNNING -> {
workerProvider.upsertWorker(group, address)
}

WorkerStatusEnum.STOP -> {
workerProvider.deleteWorker(group, address)
}

else -> {
throw RuntimeException("worker status is illegal")
}
}
logger.debug("worker[$group-$address] heartbeat, status[$status]")
}
Expand All @@ -93,7 +98,6 @@ open class DefaultWorkerManager(
}



companion object {
private val logger = LoggerFactory.getLogger(DefaultWorkerManager::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ open class JobTodoMonitor(
logger.warn("${job.id} is misfire, ignore")
// do nothing
}

else -> {
throw RuntimeException("misfire strategy is illegal")
}
}
publisher.publishEvent(JobMisfireEvent(job.id.orEmpty()))
}
Expand Down
Loading