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 Codefresh support #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

 

Supports travis, circle, wercker, drone and codeship.
Supports travis, circle, wercker, drone, codeship and codefresh.

Kinda supports custom CI as well. [Specs here](https://github.com/siddharthkp/ci-env/blob/master/index.js#L68-L79)

Expand Down
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ if (process.env.TRAVIS) {
pull_request_number = ''

ci = 'codeship'
} else if (process.env.CF_BUILD_URL) {
// https://codefresh.io/docs/docs/codefresh-yaml/variables/

repo = process.env.CF_REPO_OWNER + '/' + process.env.CF_REPO_NAME

sha = process.env.CF_REVISION
event = 'push'
commit_message = process.env.CF_COMMIT_MESSAGE
pull_request_number = process.env.CF_PULL_REQUEST_NUMBER
branch = process.env.CF_BRANCH
buildUrl = process.env.CF_BUILD_URL
ci = 'codefresh'
} else if (process.env.CI) {
// Generic variables for docker images, custom CI builds, etc.

Expand Down
13 changes: 9 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if (ci) {
else if (process.env.WERCKER) t.is(ci, 'wercker')
else if (process.env.DRONE) t.is(ci, 'drone')
else if (process.env.CI_NAME === 'codeship') t.is(ci, 'codeship')
else if (process.env.CF_BUILD_URL) t.is(ci, 'codefresh')
})

test('repo is correctly set', t => t.is(repo, 'siddharthkp/ci-env'))
Expand All @@ -21,7 +22,8 @@ if (ci) {
process.env.TRAVIS_COMMIT ||
process.env.CIRCLE_SHA1 ||
process.env.WERCKER_GIT_COMMIT ||
process.env.DRONE_COMMIT
process.env.DRONE_COMMIT ||
process.env.CF_REVISION

t.is(sha, real_sha)
})
Expand All @@ -31,8 +33,9 @@ if (ci) {
process.env.TRAVIS_COMMIT_MESSAGE ||
process.env.CI_COMMIT_MESSAGE ||
process.env.CI_MESSAGE ||
process.env.CF_COMMIT_MESSAGE ||
''
// Only travis and codeship set commit message
// Only travis, codefresh and codeship set commit message
t.is(commit_message, real_commit_message)
})

Expand All @@ -45,6 +48,7 @@ if (ci) {
process.env.TRAVIS_PULL_REQUEST ||
process.env.DRONE_PULL_REQUEST ||
circlePullRequestNumber ||
process.env.CF_PULL_REQUEST_NUMBER ||
'' // wercker does not expose pull request number

t.is(pull_request_number, real_pull_request_number)
Expand All @@ -53,6 +57,7 @@ if (ci) {
test('buildUrl is set', t => {
let real_buildUrl
if (process.env.TRAVIS) real_buildUrl = `https://travis-ci.org/${repo}/builds/${process.env.TRAVIS_JOB_ID}`
if (process.env.CF_BUILD_URL) real_buildUrl = process.env.CF_BUILD_URL
t.is(buildUrl, real_buildUrl)
})

Expand All @@ -70,8 +75,8 @@ if (ci) {
process.env.CIRCLE_BRANCH ||
process.env.WERCKER_GIT_BRANCH ||
process.env.DRONE_BRANCH ||
process.env.CI_BRANCH // codeship

process.env.CI_BRANCH || // codeship
process.env.CF_BRANCH
t.is(branch, real_branch)
}
})
Expand Down