引入
ts
import {
sendOverTimePipelineMessage,
startDevopsPipeline,
getPipelineList,
getAllPipelineList
} from 't-comm';
// 不支持 tree-shaking 的项目
import {
sendOverTimePipelineMessage,
startDevopsPipeline,
getPipelineList,
getAllPipelineList
} from 't-comm/lib/devops/index';
// 只支持 ESM 的项目
import {
sendOverTimePipelineMessage,
startDevopsPipeline,
getPipelineList,
getAllPipelineList
} from 't-comm/es/devops/index';sendOverTimePipelineMessage(params)
描述:获取超时的流水线列表,并发送机器人消息
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| params | object | 参数 |
| params.params | object | 获取流水线列表参数 |
| params.pipelineHost | string | 流水线 host 地址 |
| params.webhookUrl | string | 回调地址 |
| params.chatId | string | 会话id |
示例
ts
await sendOverTimePipelineMessage({
params: {
projectId: 'my-project',
host: 'https://devops.woa.com',
secretInfo: { appCode, appSecret, devopsUid },
},
pipelineHost: 'https://devops.woa.com',
webhookUrl: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx',
chatId: ['chat-id-1'],
mentionList: ['novlan1'],
});startDevopsPipeline(params)
描述:启动流水线
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| params | object | 配置信息 |
| params.projectId | string | 项目ID |
| params.pipelineId | string | 流水线ID |
| params.secretInfo | object | 密钥信息 |
| params.host | string | 请求域名 |
| params.data | object | 请求数据 |
示例
ts
await startDevopsPipeline({
projectId: 'my-project',
pipelineId: 'p-xxxx',
host: 'https://devops.woa.com',
secretInfo: {
appCode: 'xxx',
appSecret: 'xxx',
devopsUid: 'novlan1',
},
data: { buildNo: 1 },
});getPipelineList(params)
描述:获取流水线列表
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| params | object | 配置信息 |
| params.projectId | string | 项目ID |
| params.secretInfo | object | 密钥信息 |
| params.host | string | 请求域名 |
| params.page | number | 第几页 |
| params.pageSize | number | 每页数据量 |
返回: 流水线列表
示例
ts
const res = await getPipelineList({
projectId: 'my-project',
host: 'https://devops.woa.com',
secretInfo: { appCode, appSecret, devopsUid },
page: 1,
pageSize: 20,
});
console.log(res.records);getAllPipelineList(params, list)
描述:获取全部流水线列表
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| params | object | 配置信息 |
| params.projectId | string | 项目ID |
| params.secretInfo | object | 密钥信息 |
| params.host | string | 请求域名 |
| params.page | number | 第几页 |
| params.pageSize | number | 每页数据量 |
| list | Array | 结果列表,可不传,用于迭代 |
返回: 流水线列表
示例
ts
const all = await getAllPipelineList({
projectId: 'my-project',
host: 'https://devops.woa.com',
secretInfo: { appCode, appSecret, devopsUid },
});
console.log(all.length);