t-comm
Version:
专业、稳定、纯粹的工具库
74 lines (71 loc) • 3.01 kB
JavaScript
import { b as __awaiter, c as __generator } from '../tslib.es6-096fffdd.js';
import axios from 'axios';
import { getDevopsAccessToken } from './token.mjs';
function getReviewingReviewers(res) {
var _a, _b;
if (res === void 0) {
res = {};
}
var stages = ((_a = res === null || res === void 0 ? void 0 : res.model) === null || _a === void 0 ? void 0 : _a.stages) || [];
for (var _i = 0, stages_1 = stages; _i < stages_1.length; _i++) {
var stage = stages_1[_i];
var containers = (stage === null || stage === void 0 ? void 0 : stage.containers) || [];
for (var _c = 0, containers_1 = containers; _c < containers_1.length; _c++) {
var container = containers_1[_c];
var elements = (container === null || container === void 0 ? void 0 : container.elements) || [];
for (var _d = 0, elements_1 = elements; _d < elements_1.length; _d++) {
var element = elements_1[_d];
if (((_b = element === null || element === void 0 ? void 0 : element.reviewUsers) === null || _b === void 0 ? void 0 : _b.length) && (element === null || element === void 0 ? void 0 : element.status) === 'REVIEWING') {
return element.reviewUsers;
}
}
}
}
return [];
}
function getPipelineBuildDetail(_a) {
var _b;
var projectId = _a.projectId,
pipelineId = _a.pipelineId,
buildId = _a.buildId,
_c = _a.archiveFlag,
archiveFlag = _c === void 0 ? false : _c,
_d = _a.executeCount,
executeCount = _d === void 0 ? '' : _d,
secretInfo = _a.secretInfo,
host = _a.host;
return __awaiter(this, void 0, void 0, function () {
var appCode, appSecret, devopsUid, accessToken, resp;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
appCode = secretInfo.appCode, appSecret = secretInfo.appSecret, devopsUid = secretInfo.devopsUid;
return [4 /*yield*/, getDevopsAccessToken({
secretInfo: secretInfo,
host: host
})];
case 1:
accessToken = _e.sent();
return [4 /*yield*/, axios({
url: "".concat(host, "/prod/v4/apigw-app/projects/").concat(projectId, "/build_detail?buildId=").concat(buildId, "&pipelineId=").concat(pipelineId, "&archiveFlag=").concat(archiveFlag, "&executeCount=").concat(executeCount),
method: 'GET',
headers: {
'X-DEVOPS-UID': devopsUid,
'Content-Type': 'application/json',
'X-Bkapi-Authorization': JSON.stringify({
bk_app_code: appCode,
bk_app_secret: appSecret,
access_token: accessToken
})
}
})["catch"](function (err) {
console.log('[getPipelineBuildDetail] err: ', err);
})];
case 2:
resp = _e.sent();
return [2 /*return*/, ((_b = resp.data) === null || _b === void 0 ? void 0 : _b.data) || {}];
}
});
});
}
export { getPipelineBuildDetail, getReviewingReviewers };