35 lines
3.5 KiB
JavaScript
35 lines
3.5 KiB
JavaScript
"use strict";
|
|
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 });
|
|
const plugins = require("./mod.plugins");
|
|
let triggerValueRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|?([a-zA-Z0-9\.\-\/]*)/;
|
|
exports.trigger = () => __awaiter(this, void 0, void 0, function* () {
|
|
plugins.beautylog.info('now running triggers');
|
|
plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TRIGGER_*', evaluateTrigger);
|
|
});
|
|
let evaluateTrigger = (triggerEnvVarArg) => __awaiter(this, void 0, void 0, function* () {
|
|
let triggerRegexResultArray = triggerValueRegex.exec(triggerEnvVarArg);
|
|
let regexDomain = triggerRegexResultArray[1];
|
|
let regexProjectId = triggerRegexResultArray[2];
|
|
let regexProjectTriggerToken = triggerRegexResultArray[3];
|
|
let regexRefName = triggerRegexResultArray[4];
|
|
let regexTriggerName;
|
|
if (triggerRegexResultArray.length === 6) {
|
|
regexTriggerName = triggerRegexResultArray[5];
|
|
}
|
|
else {
|
|
regexTriggerName = 'Unnamed Trigger';
|
|
}
|
|
plugins.beautylog.info('Found Trigger!');
|
|
plugins.beautylog.log('triggering build for ref ' + regexRefName + ' of ' + regexTriggerName);
|
|
plugins.request.post('https://gitlab.com/api/v3/projects/' + regexProjectId + '/trigger/builds', { form: { token: regexProjectTriggerToken, ref: regexRefName }
|
|
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