npmci/dist/npmci.trigger.js
2016-07-18 16:56:53 +02:00

29 lines
3.0 KiB
JavaScript

"use strict";
require("typings-global");
const plugins = require("./npmci.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 = function () {
let done = plugins.q.defer();
plugins.beautylog.info("now running triggers");
plugins.smartparam.forEachMinimatch(process.env, "NPMCI_TRIGGER_*", evaluateTrigger);
done.resolve();
return done.promise;
};
let evaluateTrigger = (triggerEnvVarArg) => {
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 } });
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kudHJpZ2dlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNpLnRyaWdnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixNQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBSzNDLElBQUksaUJBQWlCLEdBQUcsZ0dBQWdHLENBQUM7QUFFOUcsZUFBTyxHQUFHO0lBQ2pCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FB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