Go modular

This commit is contained in:
PhilKunz External
2017-05-18 20:40:09 +00:00
committed by Phil Kunz
parent 6edd51c6e6
commit b6a85319b0
64 changed files with 454 additions and 316 deletions

27
ts/mod_trigger/index.ts Normal file
View File

@ -0,0 +1,27 @@
import * as plugins from './npmci.plugins'
import { prepare } from './npmci.prepare'
import { bash } from './npmci.bash'
let triggerValueRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|?([a-zA-Z0-9\.\-\/]*)/
export let trigger = async () => {
plugins.beautylog.info('now running triggers')
plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TRIGGER_*', evaluateTrigger)
}
let evaluateTrigger = async (triggerEnvVarArg) => {
let triggerRegexResultArray = triggerValueRegex.exec(triggerEnvVarArg)
let regexDomain = triggerRegexResultArray[1]
let regexProjectId = triggerRegexResultArray[2]
let regexProjectTriggerToken = triggerRegexResultArray[3]
let regexRefName = triggerRegexResultArray[4]
let regexTriggerName
if (triggerRegexResultArray.length === 6) {
regexTriggerName = triggerRegexResultArray[5]
} else {
regexTriggerName = 'Unnamed Trigger'
}
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 } })
}

View File