update
This commit is contained in:
52
src/build/index.ts
Normal file
52
src/build/index.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
||||
|
||||
type Options = CNBCoreOptions<{
|
||||
group?: string;
|
||||
}>
|
||||
export class Build extends CNBCore {
|
||||
group: string;
|
||||
constructor(options: Options) {
|
||||
super({ token: options.token, cookie: options.cookie });
|
||||
this.group = options.group || '';
|
||||
}
|
||||
startBuild(repo: string, data: StartBuildData): Promise<any> {
|
||||
const group = this.group || '';
|
||||
const url = `/${group}/${repo}/-/build/start`;
|
||||
let postData: StartBuildData = {
|
||||
...data,
|
||||
branch: data.branch || 'main',
|
||||
};
|
||||
return this.post({ url, data: postData });
|
||||
}
|
||||
}
|
||||
|
||||
type StartBuildData = {
|
||||
/**
|
||||
* 触发分支,默认为主分支
|
||||
*/
|
||||
branch?: string;
|
||||
/**
|
||||
* 指定配置文件内容,yaml 格式
|
||||
*/
|
||||
config?: string;
|
||||
/**
|
||||
* 环境变量,对象格式
|
||||
*/
|
||||
env?: Record<string, string>;
|
||||
/**
|
||||
* 事件名,必须是 api_trigger 或以 api_trigger_ 开头,默认为 api_trigger
|
||||
*/
|
||||
event?: string;
|
||||
/**
|
||||
* commit id ,优先级比 tag 高,默认为分支最新提交记录
|
||||
*/
|
||||
sha?: string;
|
||||
/**
|
||||
* 是否等待构建正式触发,为false时会立刻返回 sn 和 buildLogUrl
|
||||
*/
|
||||
sync?: string;
|
||||
/**
|
||||
* 触发 tag,优先级比 branch 高
|
||||
*/
|
||||
tag?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user