npmci/dist/npmci.trigger.js

26 lines
4.5 KiB
JavaScript
Raw Normal View History

2016-06-01 04:49:59 +00:00
"use strict";
require("typings-global");
var plugins = require("./npmci.plugins");
exports.trigger = function () {
var done = plugins.q.defer();
plugins.beautylog.info("now running triggers");
var triggerRegex = /^([a-zA-Z0-9\.]*)\/([a-zA-Z0-9\.]*)\/([a-zA-Z0-9\.]*)\/([a-zA-Z0-9\.]*)/;
2016-06-01 04:49:59 +00:00
for (var i = 0; i < 100; i++) {
var iteratorString = i.toString();
if (process.env["TRIGGER" + iteratorString]) {
var triggerRegexResultArray = triggerRegex.exec(process.env["TRIGGER" + iteratorString]);
2016-06-01 06:56:06 +00:00
var regexDomain = triggerRegexResultArray[1];
var regexProjectId = triggerRegexResultArray[2];
var regexProjectTriggerToken = triggerRegexResultArray[3];
var regexRefName = triggerRegexResultArray[4];
plugins.beautylog.log("triggering build for ref " + regexRefName);
2016-06-01 04:49:59 +00:00
plugins.beautylog.log("Found TRIGGER" + iteratorString);
plugins.request.post("https://gitlab.com/api/v3/projects/" + regexProjectId + "/trigger/builds", { form: { token: regexProjectTriggerToken, ref: regexRefName } });
2016-06-01 04:49:59 +00:00
}
}
done.resolve();
return done.promise;
};
2016-06-01 06:56:06 +00:00
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLnRyaWdnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBSWhDLGVBQU8sR0FBRztJQUNqQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLE9BQU8sQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLHNCQUFzQixDQUFDLENBQUM7SUFDL0MsSUFBSSxZQU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