From 6103b43a3cb0a592a6effe66b6176a935f154aba Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Wed, 25 Oct 2023 15:03:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20github=E8=A7=A6=E5=8F=91=E5=99=A8?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=A1=A5=E5=85=85=20#9372?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../code/github/GithubCommitCommentEvent.kt | 20 +++++++++---------- .../webhook/pojo/code/github/GithubEvent.kt | 4 ++-- .../pojo/code/github/GithubIssuesEvent.kt | 2 +- .../github/GithubIssueTriggerHandler.kt | 4 ++-- .../code/handler/tgit/TGitMrTriggerHandler.kt | 1 + 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubCommitCommentEvent.kt b/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubCommitCommentEvent.kt index 83ab9d350b8..a7bb58dd031 100644 --- a/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubCommitCommentEvent.kt +++ b/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubCommitCommentEvent.kt @@ -102,17 +102,17 @@ data class GithubReviewCommentEvent( data class GithubReviewComment( override val id: Long, - override val url: String, + override val url: String?, @JsonProperty("html_url") - override val htmlUrl: String, + 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, + override val createdAt: String?, @JsonProperty("updated_at") - override val updatedAt: String, + override val updatedAt: String?, @ApiModelProperty("Github PR Review Id") @JsonProperty("pull_request_review_id") val pullRequestReviewId: Long, @@ -163,7 +163,7 @@ abstract class GithubComment( override val url: String?, @JsonProperty("html_url") @ApiModelProperty("评论链接[网页链接]") - override val htmlUrl: String, + override val htmlUrl: String?, @JsonProperty("node_id") override val nodeId: String, @ApiModelProperty("评论内容") @@ -190,7 +190,7 @@ open class GithubCommitComment( override val id: Long, override val url: String?, @JsonProperty("html_url") - override val htmlUrl: String, + override val htmlUrl: String?, @JsonProperty("node_id") override val nodeId: String, override val body: String, @@ -216,17 +216,17 @@ open class GithubCommitComment( @ApiModel("Github Issue 评论") data class GithubIssueComment( override val id: Long, - override val url: String, + override val url: String?, @JsonProperty("html_url") - override val htmlUrl: String, + 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, + override val createdAt: String?, @JsonProperty("updated_at") - override val updatedAt: String, + override val updatedAt: String?, @JsonProperty("issue_url") @ApiModelProperty("评论链接[API链接]") val issueUrl: String diff --git a/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubEvent.kt b/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubEvent.kt index a15e0f2dbb1..94c31d3c031 100644 --- a/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubEvent.kt +++ b/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubEvent.kt @@ -182,7 +182,7 @@ data class GithubRepository( // @JsonProperty("contributors_url") // val contributorsUrl: String, // https://api.github.com/repos/yongyiduan/webhook-test/contributors @JsonProperty("created_at") - override val createdAt: String, // 1655798261 or 2022-06-21T08:45:42Z github这两种类型都会传,难受~ + override val createdAt: String?, // 1655798261 or 2022-06-21T08:45:42Z github这两种类型都会传,难受~ @JsonProperty("default_branch") val defaultBranch: String, // main // @JsonProperty("deployments_url") @@ -300,7 +300,7 @@ data class GithubRepository( // @JsonProperty("trees_url") // val treesUrl: String, // https://api.github.com/repos/yongyiduan/webhook-test/git/trees{/sha} @JsonProperty("updated_at") - override val updatedAt: String, // 2022-06-21T07:54:56Z + override val updatedAt: String?, // 2022-06-21T07:54:56Z @JsonProperty("url") override val url: String, // https://github.com/yongyiduan/webhook-test @JsonProperty("visibility") diff --git a/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubIssuesEvent.kt b/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubIssuesEvent.kt index 47c5f9264a8..7a45f8c34ef 100644 --- a/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubIssuesEvent.kt +++ b/src/backend/ci/core/common/common-webhook/api-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/pojo/code/github/GithubIssuesEvent.kt @@ -60,7 +60,7 @@ data class GithubIssue( override val url: String?, @JsonProperty("html_url") @ApiModelProperty("Issue/Pull Request链接[网页链接]") - override val htmlUrl: String, + override val htmlUrl: String?, @ApiModelProperty("Issue ID") override val id: Long, @JsonProperty("node_id") diff --git a/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubIssueTriggerHandler.kt b/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubIssueTriggerHandler.kt index 9263fecdcc2..4348b9717a3 100644 --- a/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubIssueTriggerHandler.kt +++ b/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubIssueTriggerHandler.kt @@ -132,10 +132,10 @@ class GithubIssueTriggerHandler : CodeWebhookTriggerHandler { startParams[BK_REPO_GIT_WEBHOOK_ISSUE_DESCRIPTION] = body ?: "" startParams[BK_REPO_GIT_WEBHOOK_ISSUE_STATE] = state startParams[BK_REPO_GIT_WEBHOOK_ISSUE_OWNER] = user.login - startParams[BK_REPO_GIT_WEBHOOK_ISSUE_URL] = htmlUrl + startParams[BK_REPO_GIT_WEBHOOK_ISSUE_URL] = htmlUrl ?: "" startParams[BK_REPO_GIT_WEBHOOK_ISSUE_MILESTONE_ID] = milestone?.id ?: "" startParams[BK_REPO_GIT_WEBHOOK_ISSUE_ACTION] = event.action - startParams[PIPELINE_GIT_EVENT_URL] = htmlUrl + startParams[PIPELINE_GIT_EVENT_URL] = htmlUrl ?: "" } return startParams } diff --git a/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/tgit/TGitMrTriggerHandler.kt b/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/tgit/TGitMrTriggerHandler.kt index 6889d56cf37..27bd066a950 100644 --- a/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/tgit/TGitMrTriggerHandler.kt +++ b/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/tgit/TGitMrTriggerHandler.kt @@ -301,6 +301,7 @@ class TGitMrTriggerHandler( startParams[PIPELINE_GIT_EVENT_URL] = event.object_attributes.url ?: "" // 有覆盖风险的上下文做二次确认 + startParams.putIfEmpty(GIT_MR_NUMBER, event.object_attributes.iid.toString()) startParams.putIfEmpty(PIPELINE_GIT_MR_ID, event.object_attributes.id.toString()) startParams.putIfEmpty(PIPELINE_GIT_MR_URL, event.object_attributes.url ?: "") startParams.putIfEmpty(PIPELINE_GIT_MR_IID, event.object_attributes.iid.toString())