now using regex to have a simpler env var format

This commit is contained in:
Philipp Kunz 2016-06-01 08:13:48 +02:00
parent 7b8fc67d7f
commit e239c8f350
2 changed files with 17 additions and 3 deletions

11
dist/npmci.trigger.js vendored
View File

@ -4,15 +4,22 @@ 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\.]*)/;
for (var i = 0; i < 100; i++) {
var iteratorString = i.toString();
if (process.env["TRIGGER" + iteratorString]) {
var triggerRegexResultArray = triggerRegex.exec(process.env["TRIGGER" + iteratorString]);
var regexDomain = triggerRegexResultArray[0];
var regexProjectId = triggerRegexResultArray[1];
var regexProjectTriggerToken = triggerRegexResultArray[2];
var regexRefName = triggerRegexResultArray[3];
plugins.beautylog.log("triggering build for ref " + regexRefName);
plugins.beautylog.log("Found TRIGGER" + iteratorString);
plugins.request.post(process.env["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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLnRyaWdnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBSWhDLGVBQU8sR0FBRztJQUNqQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLE9BQU8sQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLHNCQUFzQixDQUFDLENBQUM7SUFDL0MsR0FBRyxDQUFBLENBQUMsSUF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0VHJpZ2dlclRva2VuID0gdHJpZ2dlclJlZ2V4UmVzdWx0QXJyYXlbMl07XHJcbiAgICAgICAgICAgIGxldCByZWdleFJlZk5hbWUgPSB0cmlnZ2VyUmVnZXhSZXN1bHRBcnJheVszXTtcclxuICAgICAgICAgICAgcGx1Z2lucy5iZWF1dHlsb2cubG9nKFwidHJpZ2dlcmluZyBidWlsZCBmb3IgcmVmIFwiICsgcmVnZXhSZWZOYW1lKTtcclxuICAgICAgICAgICAgcGx1Z2lucy5iZWF1dHlsb2cubG9nKFwiRm91bmQgVFJJR0dFUlwiICsgaXRlcmF0b3JTdHJpbmcpO1xyXG4gICAgICAgICAgICBwbHVnaW5zLnJlcXVlc3QucG9zdChcImh0dHBzOi8vZ2l0bGFiLmNvbS9hcGkvdjMvcHJvamVjdHMvXCIgKyByZWdleFByb2plY3RJZCArIFwiL3RyaWdnZXIvYnVpbGRzXCIsIHtmb3JtOnt0b2tlbjpyZWdleFByb2plY3RUcmlnZ2VyVG9rZW4scmVmOnJlZ2V4UmVmTmFtZX19KTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbiAgICBkb25lLnJlc29sdmUoKTtcclxuICAgIHJldHVybiBkb25lLnByb21pc2U7XHJcbn0iXX0=

View File

@ -6,11 +6,18 @@ import {bash} from "./npmci.bash";
export let trigger = function(){
let done = plugins.q.defer();
plugins.beautylog.info("now running triggers");
let triggerRegex = /^([a-zA-Z0-9\.]*)\/([a-zA-Z0-9\.]*)\/([a-zA-Z0-9\.]*)\/([a-zA-Z0-9\.]*)/;
for(let i = 0; i < 100; i++){
let iteratorString = i.toString();
if(process.env["TRIGGER" + iteratorString]){
let triggerRegexResultArray = triggerRegex.exec(process.env["TRIGGER" + iteratorString]);
let regexDomain = triggerRegexResultArray[0];
let regexProjectId = triggerRegexResultArray[1];
let regexProjectTriggerToken = triggerRegexResultArray[2];
let regexRefName = triggerRegexResultArray[3];
plugins.beautylog.log("triggering build for ref " + regexRefName);
plugins.beautylog.log("Found TRIGGER" + iteratorString);
plugins.request.post(process.env["TRIGGER" + iteratorString]);
plugins.request.post("https://gitlab.com/api/v3/projects/" + regexProjectId + "/trigger/builds", {form:{token:regexProjectTriggerToken,ref:regexRefName}});
}
}
done.resolve();