npmci/ts/npmci.trigger.ts

25 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2016-06-01 04:30:21 +00:00
import "typings-global";
import * as plugins from "./npmci.plugins";
import {prepare} from "./npmci.prepare";
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\.]*)/;
2016-06-01 04:30:21 +00:00
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);
2016-06-01 04:30:21 +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:30:21 +00:00
}
}
done.resolve();
return done.promise;
}