t-comm
Version:
专业、稳定、纯粹的工具库
49 lines (42 loc) • 1.19 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var axios = require('axios');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
/**
* 启动流水线
*
* @param {object} config 配置信息
* @param {string} config.buildId 流水线构建Id
* @param {object} config.data 携带的数据
* @returns Promise
*
* @example
*
* ```ts
* startPipeline({
* buildId,
* data: {}
* }).then(() => {
*
* })
* ```
*/
function startPipeline(_ref) {
var buildId = _ref.buildId,
_ref$data = _ref.data,
data = _ref$data === void 0 ? {} : _ref$data;
return new Promise(function (resolve, reject) {
if (!buildId) {
reject(new Error('缺少buildId'));
return;
}
var pipelineUrl = "http://devops.oa.com/ms/process/api/external/pipelines/".concat(buildId, "/build");
axios__default["default"].post(pipelineUrl, Object.assign({}, data)).then(function (res) {
resolve(res.data);
})["catch"](function (err) {
reject(err);
});
});
}
exports.startPipeline = startPipeline;