-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Jenkins CI source #61
Conversation
Resolves #56
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗣
} | ||
|
||
get isCI(): boolean { | ||
return ensureEnvKeysExist(this.env, ["JENKINS_URL"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -26,14 +26,12 @@ export interface CISource { | |||
|
|||
/** What unique id can be found for the code review platform's PR */ | |||
+pullRequestID: string, | |||
|
|||
/** What is the project name */ | |||
+name: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dupe, removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one
@@ -39,7 +39,7 @@ describe(".isPR", () => { | |||
env[key] = null | |||
|
|||
test(`does not validate when ${key} is missing`, () => { | |||
const travis = new Travis({}) | |||
const travis = new Travis(env) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Travis CI source test wasn't validating the env
where env[key]
was null. Updated this test to do so (which I think it intends to do).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -11,7 +11,7 @@ import type { Env } from "./ci_source" | |||
*/ | |||
export function ensureEnvKeysExist(env: Env, keys: string[]): boolean { | |||
const hasKeys = keys.map((key: string): boolean => { | |||
return env.hasOwnProperty(key) && env[key].length > 0 | |||
return env.hasOwnProperty(key) && env[key] != null && env[key].length > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Travis (and now Jenkins) CI source tests set an env[key]
to null in the tests (our way of saying the key exists but there is no value for that key). This function was attempting to access .length
on null, which throws a TypeError
, so I believe this null/undefined check is useful here in case the env
object has a supplied property but its value is falsy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rockin - looks good
@@ -39,7 +39,7 @@ describe(".isPR", () => { | |||
env[key] = null | |||
|
|||
test(`does not validate when ${key} is missing`, () => { | |||
const travis = new Travis({}) | |||
const travis = new Travis(env) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -26,14 +26,12 @@ export interface CISource { | |||
|
|||
/** What unique id can be found for the code review platform's PR */ | |||
+pullRequestID: string, | |||
|
|||
/** What is the project name */ | |||
+name: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one
@@ -11,7 +11,7 @@ import type { Env } from "./ci_source" | |||
*/ | |||
export function ensureEnvKeysExist(env: Env, keys: string[]): boolean { | |||
const hasKeys = keys.map((key: string): boolean => { | |||
return env.hasOwnProperty(key) && env[key].length > 0 | |||
return env.hasOwnProperty(key) && env[key] != null && env[key].length > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep 👍
Will merge on 🍏 |
Resolves #56