Skip to content

Commit 99bacfb

Browse files
committed
Added random CI_PIPELINE_ID env var
Fixed gitbash exe path bug.
1 parent b756f14 commit 99bacfb

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ const logger: winston.Logger = winston.createLogger({
3232
],
3333
});
3434

35+
const makeid = (length: number): string => {
36+
let result = "";
37+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
38+
const charactersLength = characters.length;
39+
for (let i = 0; i < length; i = i + 1) {
40+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
41+
}
42+
43+
return result;
44+
};
45+
process.env.CI_PIPELINE_ID = makeid(10);
46+
3547
const argv = yargs.argv;
3648
const cwd = argv.cwd || process.cwd();
3749

src/job.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import * as c from "ansi-colors";
22
import * as deepExtend from "deep-extend";
3+
import * as glob from "glob";
34
import * as prettyHrtime from "pretty-hrtime";
45
import * as shelljs from "shelljs";
56

6-
const shell = process.env.EXEPATH ? `${process.env.EXEPATH}/bash.exe` : "/bin/bash";
7+
let shell = "/bin/bash";
8+
if (process.env.EXEPATH) {
9+
const bashExes = glob.sync(`${process.env.EXEPATH}/**/bash.exe`);
10+
if (bashExes.length === 0) {
11+
console.error(`${c.red("Could not find any bash executables")}`);
12+
process.exit(1);
13+
}
14+
shell = bashExes[0];
15+
}
716

817
export class Job {
918
public readonly name: string;

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
],
66
"jsRules": {},
77
"rules": {
8+
"no-magic-numbers": false,
89
"strict-boolean-expressions": false,
910
"newline-per-chained-call": false,
1011
"no-any": false,

0 commit comments

Comments
 (0)