2016-06-01 04:49:59 +00:00
|
|
|
"use strict";
|
2017-03-11 00:10:37 +00:00
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2017-05-19 10:09:33 +00:00
|
|
|
const plugins = require("./mod.plugins");
|
2016-07-18 14:56:53 +00:00
|
|
|
let triggerValueRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|?([a-zA-Z0-9\.\-\/]*)/;
|
2017-03-11 00:10:37 +00:00
|
|
|
exports.trigger = () => __awaiter(this, void 0, void 0, function* () {
|
2016-11-24 22:21:40 +00:00
|
|
|
plugins.beautylog.info('now running triggers');
|
|
|
|
plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TRIGGER_*', evaluateTrigger);
|
2017-03-11 00:10:37 +00:00
|
|
|
});
|
|
|
|
let evaluateTrigger = (triggerEnvVarArg) => __awaiter(this, void 0, void 0, function* () {
|
2016-07-18 14:56:53 +00:00
|
|
|
let triggerRegexResultArray = triggerValueRegex.exec(triggerEnvVarArg);
|
|
|
|
let regexDomain = triggerRegexResultArray[1];
|
|
|
|
let regexProjectId = triggerRegexResultArray[2];
|
|
|
|
let regexProjectTriggerToken = triggerRegexResultArray[3];
|
|
|
|
let regexRefName = triggerRegexResultArray[4];
|
|
|
|
let regexTriggerName;
|
2016-11-24 22:21:40 +00:00
|
|
|
if (triggerRegexResultArray.length === 6) {
|
2016-06-23 20:22:03 +00:00
|
|
|
regexTriggerName = triggerRegexResultArray[5];
|
|
|
|
}
|
|
|
|
else {
|
2016-11-24 22:21:40 +00:00
|
|
|
regexTriggerName = 'Unnamed Trigger';
|
2016-06-23 20:22:03 +00:00
|
|
|
}
|
2016-11-24 22:21:40 +00:00
|
|
|
plugins.beautylog.info('Found Trigger!');
|
|
|
|
plugins.beautylog.log('triggering build for ref ' + regexRefName + ' of ' + regexTriggerName);
|
2018-04-04 20:25:13 +00:00
|
|
|
plugins.request.post('https://gitlab.com/api/v3/projects/' + regexProjectId + '/trigger/builds', {
|
|
|
|
form: { token: regexProjectTriggerToken, ref: regexRefName }
|
2017-05-19 10:09:33 +00:00
|
|
|
});
|
2017-03-11 00:10:37 +00:00
|
|
|
});
|
2018-04-04 20:25:13 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9tb2RfdHJpZ2dlci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEseUNBQXlDO0FBR3pDLElBQUksaUJBQWlCLEdBQUcsZ0dBQWdHLENBQUM7QUFFOUcsUUFBQSxPQUFPLEdBQUcsR0FBUyxFQUFFO0lBQzlCLE9BQU8sQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLHNCQUFzQixDQUFDLENBQUM7SUFDL0MsT0FBTyxDQUFDLFVBQVUsQ0FBQyxnQkFBZ0IsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLGlCQUFpQixFQUFFLGVBQWUsQ0FBQyxDQUFDO0FBQ3ZGLENBQUMsQ0FBQSxDQUFDO0FBRUYsSUFBSSxlQUFlLEdBQUcsQ0FBTSxnQkFBZ0IsRUFBQyxFQUFFO0lBQzdDLElBQUksdUJBQXVCLEdBQUcsaUJBQWlCLENBQUM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