npmci/dist/npmci.trigger.js

28 lines
2.9 KiB
JavaScript
Raw Normal View History

2016-06-01 04:49:59 +00:00
"use strict";
2016-07-18 14:56:53 +00:00
const plugins = require("./npmci.plugins");
let triggerValueRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|?([a-zA-Z0-9\.\-\/]*)/;
2016-06-01 04:49:59 +00:00
exports.trigger = function () {
2016-07-18 14:56:53 +00:00
let done = plugins.q.defer();
2016-11-24 22:21:40 +00:00
plugins.beautylog.info('now running triggers');
plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TRIGGER_*', evaluateTrigger);
2016-06-01 04:49:59 +00:00
done.resolve();
return done.promise;
};
2016-07-18 14:56:53 +00:00
let evaluateTrigger = (triggerEnvVarArg) => {
let triggerRegexResultArray = triggerValueRegex.exec(triggerEnvVarArg);
let regexDomain = triggerRegexResultArray[1];
let regexProjectId = triggerRegexResultArray[2];
let regexProjectTriggerToken = triggerRegexResultArray[3];
let regexRefName = triggerRegexResultArray[4];
let regexTriggerName;
2016-11-24 22:21:40 +00:00
if (triggerRegexResultArray.length === 6) {
2016-06-23 20:22:03 +00:00
regexTriggerName = triggerRegexResultArray[5];
}
else {
2016-11-24 22:21:40 +00:00
regexTriggerName = 'Unnamed Trigger';
2016-06-23 20:22:03 +00:00
}
2016-11-24 22:21:40 +00:00
plugins.beautylog.info('Found Trigger!');
plugins.beautylog.log('triggering build for ref ' + regexRefName + ' of ' + regexTriggerName);
plugins.request.post('https://gitlab.com/api/v3/projects/' + regexProjectId + '/trigger/builds', { form: { token: regexProjectTriggerToken, ref: regexRefName } });
2016-06-23 20:22:03 +00:00
};
2016-11-24 23:07:20 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kudHJpZ2dlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNp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