feat(net-tool): 添加 GitLab Web 钩子功能以支持钩子的获取和添加
All checks were successful
/ release (push) Successful in 27s
All checks were successful
/ release (push) Successful in 27s
This commit is contained in:
parent
07353b00aa
commit
63b78fe797
29
packages/net-tool/src/gitlabServer/hook.ts
Normal file
29
packages/net-tool/src/gitlabServer/hook.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { ProjectHookSchema } from "@gitbeaker/rest"
|
||||||
|
|
||||||
|
import GitlabBaseService from "./base"
|
||||||
|
|
||||||
|
class Hook extends GitlabBaseService {
|
||||||
|
/**
|
||||||
|
* 为特定项目检索 GitLab Web 钩子。
|
||||||
|
* @returns {Promise<ProjectHookSchema[]>}
|
||||||
|
*/
|
||||||
|
async getList() {
|
||||||
|
const URL = `/projects/${this.project_id}/hooks`
|
||||||
|
return this.errorWarp<ProjectHookSchema[]>(() => this.get(URL), [])
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加 GitLab Web 钩子。
|
||||||
|
* @param {Partial<ProjectHookSchema>} hook 钩子配置
|
||||||
|
* @returns {Promise<ProjectHookSchema | null>}
|
||||||
|
*/
|
||||||
|
async add(hook: Partial<ProjectHookSchema>) {
|
||||||
|
const URL = `/projects/${this.project_id}/hooks`
|
||||||
|
return this.errorWarp<ProjectHookSchema | null>(
|
||||||
|
() => this.post(URL, hook),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Hook
|
@ -1,6 +1,7 @@
|
|||||||
import Badge from "./badge"
|
import Badge from "./badge"
|
||||||
import Commit from "./commit"
|
import Commit from "./commit"
|
||||||
import Discussions from "./discussions"
|
import Discussions from "./discussions"
|
||||||
|
import Hook from "./hook"
|
||||||
import MergeRequests from "./mergeRequests"
|
import MergeRequests from "./mergeRequests"
|
||||||
import Notes from "./notes"
|
import Notes from "./notes"
|
||||||
import Pipelines from "./pipelines"
|
import Pipelines from "./pipelines"
|
||||||
@ -16,6 +17,7 @@ class GitlabService {
|
|||||||
pipelines: Pipelines
|
pipelines: Pipelines
|
||||||
project: Project
|
project: Project
|
||||||
repository: Repository
|
repository: Repository
|
||||||
|
hook: Hook
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个 GitLab 服务对象。
|
* 创建一个 GitLab 服务对象。
|
||||||
@ -40,6 +42,7 @@ class GitlabService {
|
|||||||
this.pipelines = new Pipelines(baseUrl, authKey, requestId)
|
this.pipelines = new Pipelines(baseUrl, authKey, requestId)
|
||||||
this.project = new Project(baseUrl, authKey, requestId)
|
this.project = new Project(baseUrl, authKey, requestId)
|
||||||
this.repository = new Repository(baseUrl, authKey, requestId)
|
this.repository = new Repository(baseUrl, authKey, requestId)
|
||||||
|
this.hook = new Hook(baseUrl, authKey, requestId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,6 +58,7 @@ class GitlabService {
|
|||||||
this.pipelines.project_id = project_id
|
this.pipelines.project_id = project_id
|
||||||
this.project.project_id = project_id
|
this.project.project_id = project_id
|
||||||
this.repository.project_id = project_id
|
this.repository.project_id = project_id
|
||||||
|
this.hook.project_id = project_id
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,6 +74,7 @@ class GitlabService {
|
|||||||
this.pipelines.merge_request_iid = merge_request_iid
|
this.pipelines.merge_request_iid = merge_request_iid
|
||||||
this.project.merge_request_iid = merge_request_iid
|
this.project.merge_request_iid = merge_request_iid
|
||||||
this.repository.merge_request_iid = merge_request_iid
|
this.repository.merge_request_iid = merge_request_iid
|
||||||
|
this.hook.merge_request_iid = merge_request_iid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user