Skip to content

Commit

Permalink
Merge pull request #9481 from hejieehe/feat_9372
Browse files Browse the repository at this point in the history
feat: github触发器事件补充 #9372
  • Loading branch information
bkci-bot authored Oct 25, 2023
2 parents 9241405 + 6103b43 commit 5774e37
Show file tree
Hide file tree
Showing 22 changed files with 1,400 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ data class CodeGithubWebHookTriggerElement(
@ApiModelProperty("新版的github原子的类型")
val repositoryType: RepositoryType? = null,
@ApiModelProperty("新版的github代码库名")
val repositoryName: String? = null
val repositoryName: String? = null,
@ApiModelProperty("code review 状态", required = false)
val includeCrState: List<String>? = null,
@ApiModelProperty("code note comment", required = false)
val includeNoteComment: String? = null,
@ApiModelProperty("code note 类型", required = false)
val includeNoteTypes: List<String>? = null,
@ApiModelProperty("issue事件action")
val includeIssueAction: List<String>? = null
) : WebHookTriggerElement(name, id, status) {
companion object {
const val classType = "codeGithubWebHookTrigger"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const val BK_REPO_GIT_WEBHOOK_EXCLUDE_BRANCHS = "BK_CI_REPO_GIT_WEBHOOK_EXCLUDE_
const val BK_REPO_GIT_WEBHOOK_INCLUDE_PATHS = "BK_CI_REPO_GIT_WEBHOOK_INCLUDE_PATHS"
const val BK_REPO_GIT_WEBHOOK_EXCLUDE_PATHS = "BK_CI_REPO_GIT_WEBHOOK_EXCLUDE_PATHS"
const val BK_REPO_GIT_WEBHOOK_EXCLUDE_USERS = "BK_CI_REPO_GIT_WEBHOOK_EXCLUDE_USERS"
const val BK_REPO_GIT_WEBHOOK_INCLUDE_USERS = "BK_CI_REPO_GIT_WEBHOOK_INCLUDE_USERS"
const val BK_REPO_GIT_WEBHOOK_BRANCH = "BK_CI_REPO_GIT_WEBHOOK_BRANCH"
const val BK_REPO_GIT_MANUAL_UNLOCK = "BK_CI_REPO_GIT_MANUAL_UNLOCK"
const val BK_REPO_GIT_WEBHOOK_ENABLE_CHECK = "BK_REPO_GIT_WEBHOOK_ENABLE_CHECK"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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.webhook.pojo.code.github

import com.fasterxml.jackson.annotation.JsonProperty
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

@ApiModel("Github 基础信息")
open class GithubBaseInfo(
@ApiModelProperty("ID")
open val id: Long,
@ApiModelProperty("链接[API链接]")
open val url: String? = "",
@JsonProperty("html_url")
@ApiModelProperty("链接[网页链接]")
open val htmlUrl: String? = "",
@JsonProperty("node_id")
open val nodeId: String,
@JsonProperty("created_at")
open val createdAt: String? = "", // 2022-06-21T08:45:41Z
@JsonProperty("updated_at")
open val updatedAt: String? = ""
) {
companion object {
// github主页地址
const val GITHUB_HOME_PAGE_URL = "https://github.com"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
/*
* 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.webhook.pojo.code.github

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

/**
* Github 评论分四种:
* 1. PR Review 评论
* 1.1 基于PR直接评论
* 1.2 基于PR Review的会话进行评论
* 2. Issues 评论
* 3. Commit 评论
*/
@JsonIgnoreProperties(ignoreUnknown = true)
abstract class GithubCommentEvent(
open val action: String,
open val repository: GithubRepository,
open val comment: GithubComment,
override val sender: GithubUser
) : GithubEvent(sender) {
open fun getCommentType(): String = ""
}

@JsonIgnoreProperties(ignoreUnknown = true)
data class GithubCommitCommentEvent(
override val action: String,
override val repository: GithubRepository,
override val comment: GithubCommitComment,
override val sender: GithubUser
) : GithubCommentEvent(
action = action,
repository = repository,
comment = comment,
sender = sender
) {
companion object {
const val classType = "commit_comment"

// 评论类型:基于Commit进行评论
const val commentType = "Commit"
}

override fun getCommentType() = commentType
}

@ApiModel("Github Review 评论事件")
data class GithubReviewCommentEvent(
override val action: String,
@JsonProperty("pull_request")
@ApiModelProperty("Issues相关信息")
val pullRequest: GithubPullRequest,
@ApiModelProperty("Github仓库相关信息")
override val repository: GithubRepository,
@ApiModelProperty("操作人信息")
override val sender: GithubUser,
@ApiModelProperty("Review会话信息")
override val comment: GithubReviewComment
) : GithubCommentEvent(
action = action,
repository = repository,
comment = comment,
sender = sender
) {
companion object {
const val classType = "pull_request_review_comment"

// 评论类型:基于Pull Request Review进行评论
const val commentType = "Review"
}

override fun getCommentType() = commentType
}

data class GithubReviewComment(
override val id: Long,
override val url: String?,
@JsonProperty("html_url")
override val htmlUrl: String?,
@JsonProperty("node_id")
override val nodeId: String,
override val body: String,
override val user: GithubUser,
@JsonProperty("created_at")
override val createdAt: String?,
@JsonProperty("updated_at")
override val updatedAt: String?,
@ApiModelProperty("Github PR Review Id")
@JsonProperty("pull_request_review_id")
val pullRequestReviewId: Long,
@ApiModelProperty("Github PR Review会话对应的文件")
val path: String
) : GithubComment(
id = id,
url = url,
htmlUrl = htmlUrl,
nodeId = nodeId,
body = body,
user = user,
createdAt = createdAt,
updatedAt = updatedAt
)

@JsonIgnoreProperties(ignoreUnknown = true)
data class GithubIssueCommentEvent(
override val action: String,
override val repository: GithubRepository,
override val comment: GithubIssueComment,
override val sender: GithubUser,
val issue: GithubIssue
) : GithubCommentEvent(
action = action,
repository = repository,
comment = comment,
sender = sender
) {
companion object {
const val classType = "issue_comment"
}

override fun getCommentType() = if (issue.pullRequest != null) {
// 对齐Code_Git直接在PR上评论则[noteableType=Review]
"Review"
} else {
"Issue"
}
}

@Suppress("LongParameterList")
@ApiModel("Github 评论信息父类")
abstract class GithubComment(
@ApiModelProperty("评论ID")
override val id: Long,
@ApiModelProperty("评论链接[API链接]")
override val url: String?,
@JsonProperty("html_url")
@ApiModelProperty("评论链接[网页链接]")
override val htmlUrl: String?,
@JsonProperty("node_id")
override val nodeId: String,
@ApiModelProperty("评论内容")
open val body: String,
@ApiModelProperty("评论的用户")
open val user: GithubUser,
@JsonProperty("created_at")
@ApiModelProperty("创建时间")
override val createdAt: String?, // 2022-06-21T08:45:41Z
@JsonProperty("updated_at")
@ApiModelProperty("修改时间")
override val updatedAt: String? // 2022-06-21T08:45:41Z
) : GithubBaseInfo(
id = id,
url = url,
htmlUrl = htmlUrl,
nodeId = nodeId,
updatedAt = updatedAt,
createdAt = createdAt
)

@SuppressWarnings("LongParameterList")
open class GithubCommitComment(
override val id: Long,
override val url: String?,
@JsonProperty("html_url")
override val htmlUrl: String?,
@JsonProperty("node_id")
override val nodeId: String,
override val body: String,
override val user: GithubUser,
@JsonProperty("created_at")
override val createdAt: String?,
@JsonProperty("updated_at")
override val updatedAt: String?,
@JsonProperty("commit_id")
@ApiModelProperty("commit sha")
val commitId: String
) : GithubComment(
id = id,
url = url,
htmlUrl = htmlUrl,
nodeId = nodeId,
body = body,
user = user,
createdAt = createdAt,
updatedAt = updatedAt
)

@ApiModel("Github Issue 评论")
data class GithubIssueComment(
override val id: Long,
override val url: String?,
@JsonProperty("html_url")
override val htmlUrl: String?,
@JsonProperty("node_id")
override val nodeId: String,
override val body: String,
override val user: GithubUser,
@JsonProperty("created_at")
override val createdAt: String?,
@JsonProperty("updated_at")
override val updatedAt: String?,
@JsonProperty("issue_url")
@ApiModelProperty("评论链接[API链接]")
val issueUrl: String
) : GithubComment(
id = id,
url = url,
htmlUrl = htmlUrl,
nodeId = nodeId,
body = body,
user = user,
createdAt = createdAt,
updatedAt = updatedAt
)
Loading

0 comments on commit 5774e37

Please sign in to comment.