npmci/dist/npmci.trigger.js

29 lines
4.8 KiB
JavaScript
Raw 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
2016-06-02 16:09:07 +00:00
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 16:39:11 +00:00
var triggerName = triggerEnvPrefix + iteratorString;
if (process.env[triggerName]) {
var triggerRegexResultArray = triggerRegex.exec(process.env[triggerName]);
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 16:39:11 +00:00
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLnRyaWdnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBSTNDLFdBQVc7QUFDWCxJQUFJLGdCQUFnQixHQUFHLGdCQUF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