npmci/dist/npmci.trigger.js
2016-06-02 18:09:07 +02:00

28 lines
4.7 KiB
JavaScript

"use strict";
require("typings-global");
var plugins = require("./npmci.plugins");
//Variables
var triggerEnvPrefix = "NPMCI_TRIGGER_";
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\.]*)/;
for (var i = 0; i < 100; i++) {
var iteratorString = i.toString();
if (process.env[triggerEnvPrefix + iteratorString]) {
var triggerRegexResultArray = triggerRegex.exec(process.env["TRIGGER" + iteratorString]);
var regexDomain = triggerRegexResultArray[1];
var regexProjectId = triggerRegexResultArray[2];
var regexProjectTriggerToken = triggerRegexResultArray[3];
var regexRefName = triggerRegexResultArray[4];
plugins.beautylog.log("triggering build for ref " + regexRefName);
plugins.beautylog.log("Found TRIGGER" + iteratorString);
plugins.request.post("https://gitlab.com/api/v3/projects/" + regexProjectId + "/trigger/builds", { form: { token: regexProjectTriggerToken, ref: regexRefName } });
}
}
done.resolve();
return done.promise;
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLnRyaWdnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBSTNDLFdBQVc7QUFDWCxJQUFJLGdCQUFnQixHQUFHLGdCQUFnQixDQUFDO0FBRTdCLGVBQU8sR0FBRztJQUNqQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLE9BQU8sQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLHNCQUFzQixDQUFDLENBQUM7SUFDL0MsSUFBSSxZQUFZLEd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