Skip to content
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

Merged
merged 2 commits into from
Dec 27, 2016
Merged

Add Jenkins CI source #61

merged 2 commits into from
Dec 27, 2016

Conversation

macklinu
Copy link
Member

Resolves #56

Copy link
Member Author

@macklinu macklinu left a 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"])
Copy link
Member Author

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dupe, removed.

Copy link
Member

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)
Copy link
Member Author

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).

Copy link
Member

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
Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep 👍

Copy link
Member

@orta orta left a 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)
Copy link
Member

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep 👍

@orta
Copy link
Member

orta commented Dec 27, 2016

Will merge on 🍏

@orta orta merged commit 32d8641 into master Dec 27, 2016
@orta orta deleted the 56-jenkins-ci-source branch December 27, 2016 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants