improve triggr detection
This commit is contained in:
@ -133,7 +133,7 @@ export class Dockerfile {
|
||||
this.releaseTag = dockerTag(NpmciEnv.dockerRegistry,this.repo,this.version);
|
||||
this.containerName = "dockerfile-" + this.version;
|
||||
if(options.filePath && options.read){
|
||||
this.content = plugins.smartfile.local.toStringSync(plugins.path.resolve(options.filePath));
|
||||
this.content = plugins.smartfile.fs.toStringSync(plugins.path.resolve(options.filePath));
|
||||
};
|
||||
this.baseImage = dockerBaseImage(this.content);
|
||||
this.localBaseImageDependent = false;
|
||||
@ -170,7 +170,7 @@ export class Dockerfile {
|
||||
};
|
||||
test(){
|
||||
let testFile:string = plugins.path.join(paths.NpmciTestDir,"test_" + this.version + ".sh");
|
||||
let testFileExists:boolean = plugins.smartfile.checks.fileExistsSync(testFile);
|
||||
let testFileExists:boolean = plugins.smartfile.fs.fileExistsSync(testFile);
|
||||
if(testFileExists){
|
||||
bashBare("docker run --name npmci_test_container " + this.buildTag + " mkdir /npmci_test");
|
||||
bashBare("docker cp " + testFile + " npmci_test_container:/npmci_test/test.sh");
|
||||
|
@ -33,7 +33,7 @@ export let configStore = () => {
|
||||
let configLoad = () => {
|
||||
// internal config to transfer information in between npmci shell calls
|
||||
try {
|
||||
config = plugins.smartfile.local.toObjectSync(paths.NpmciPackageConfig,"json");
|
||||
config = plugins.smartfile.fs.toObjectSync(paths.NpmciPackageConfig,"json");
|
||||
}
|
||||
catch(err){
|
||||
config = {};
|
||||
@ -44,7 +44,7 @@ let configLoad = () => {
|
||||
// project config
|
||||
try {
|
||||
if(!config.project){
|
||||
config.project = plugins.smartfile.local.toObjectSync(paths.NpmciProjectDir,"npmci.json");
|
||||
config.project = plugins.smartfile.fs.toObjectSync(paths.NpmciProjectDir,"npmci.json");
|
||||
plugins.beautylog.ok("project config found!");
|
||||
};
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ export import projectinfo = require("projectinfo");
|
||||
export let q = require("q");
|
||||
export let request = require("request");
|
||||
export let shelljs = require("shelljs");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartparam = require("smartparam");
|
||||
export import smartssh = require("smartssh");
|
||||
export import smartstring = require("smartstring");
|
||||
export import smartfile = require("smartfile");
|
||||
export let through2 = require("through2");
|
11
ts/npmci.ssh.ts
Normal file
11
ts/npmci.ssh.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import "typings-global";
|
||||
import * as plugins from "./npmci.plugins";
|
||||
|
||||
export let ssh = () => {
|
||||
let sshInstance = new plugins.smartssh.SshInstance();
|
||||
plugins.smartparam.forEachMinimatch(process.env,"NPMCI_SSHKEY_*",evaluateSshkey);
|
||||
};
|
||||
|
||||
export let evaluateSshkey = () => {
|
||||
|
||||
};
|
@ -3,33 +3,30 @@ import * as plugins from "./npmci.plugins";
|
||||
import {prepare} from "./npmci.prepare";
|
||||
import {bash} from "./npmci.bash";
|
||||
|
||||
//Variables
|
||||
let triggerEnvPrefix = "NPMCI_TRIGGER_";
|
||||
|
||||
export let trigger = function(){
|
||||
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 = 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\.]*)\|?([a-zA-Z0-9\.\-\/]*)/;
|
||||
for(let i = 0; i < 100; i++){
|
||||
let iteratorString = i.toString();
|
||||
let triggerName = triggerEnvPrefix + iteratorString
|
||||
if(process.env[triggerName]){
|
||||
let triggerRegexResultArray = triggerRegex.exec(process.env[triggerName]);
|
||||
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 " + triggerName);
|
||||
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}});
|
||||
}
|
||||
}
|
||||
plugins.smartparam.forEachMinimatch(process.env, "NPMCI_TRIGGER_*", evaluateTrigger);
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
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;
|
||||
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 } });
|
||||
}
|
Reference in New Issue
Block a user