npmci/dist/npmci.trigger.js

29 lines
3.0 KiB
JavaScript
Raw Normal View History

2016-06-01 04:49:59 +00:00
"use strict";
require("typings-global");
2016-07-18 14:56:53 +00:00
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\.\-\/]*)/;
2016-06-01 04:49:59 +00:00
exports.trigger = function () {
2016-07-18 14:56:53 +00:00
let done = plugins.q.defer();
2016-06-01 04:49:59 +00:00
plugins.beautylog.info("now running triggers");
2016-06-23 20:22:03 +00:00
plugins.smartparam.forEachMinimatch(process.env, "NPMCI_TRIGGER_*", evaluateTrigger);
2016-06-01 04:49:59 +00:00
done.resolve();
return done.promise;
};
2016-07-18 14:56:53 +00:00
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;
2016-06-23 20:22:03 +00:00
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 } });
};
2016-09-20 10:43:37 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kudHJpZ2dlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNpLnRyaWdnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF3QjtBQUN4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