npmci/dist/npmci.trigger.js

28 lines
4.7 KiB
JavaScript
Raw Permalink Normal View History

2016-06-01 04:49:59 +00:00
"use strict";
require("typings-global");
var plugins = require("./npmci.plugins");
2016-06-02 11:08:15 +00:00
//Variables
var triggerEnvPrefix = "NPMCI_TRIGGER";
2016-06-01 04:49:59 +00:00
exports.trigger = function () {
var done = plugins.q.defer();
plugins.beautylog.info("now running triggers");
2016-06-02 11:08:15 +00:00
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();
2016-06-02 11:08:15 +00:00
if (process.env[triggerEnvPrefix + 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-02 11:08:15 +00:00
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLnRyaWdnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBSTNDLFdBQVc7QUFDWCxJQUFJLGdCQUFnQixHQUFHLGVBQWUsQ0FBQztBQUU1QixlQU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