Skip to content

Commit 710c504

Browse files
sudanickmerwin
authored andcommitted
Add Codefresh support
1 parent 8c4ba99 commit 710c504

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

Diff for: lib/getOptions.js

+10
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ const getBaseOptions = cb => {
131131
git_branch = process.env.BUILD_SOURCEBRANCHNAME;
132132
}
133133

134+
if (process.env.CF_BRANCH) {
135+
options.service_name = 'Codefresh';
136+
options.service_job_id = process.env.CF_BUILD_ID;
137+
options.service_pull_request = process.env.CF_PULL_REQUEST_ID;
138+
git_commit = process.env.CF_REVISION;
139+
git_branch = process.env.CF_BRANCH;
140+
git_committer_name = process.env.CF_COMMIT_AUTHOR;
141+
git_message = process.env.CF_COMMIT_MESSAGE;
142+
}
143+
134144
options.run_at = process.env.COVERALLS_RUN_AT || JSON.stringify(new Date()).slice(1, -1);
135145
if (process.env.COVERALLS_SERVICE_NAME) {
136146
options.service_name = process.env.COVERALLS_SERVICE_NAME;

Diff for: test/getOptions.js

+34
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ describe('getOptions', () => {
170170
it('should set service_name and service_job_id if it\'s running via Azure Pipelines', done => {
171171
testAzurePipelines(getOptions, done);
172172
});
173+
it('should set service_name and service_job_id if it\'s running via CodeFresh', done => {
174+
testCodefresh(getOptions, done);
175+
});
173176
it('should override set options with user options', done => {
174177
const userOptions = { service_name: 'OVERRIDDEN_SERVICE_NAME' };
175178
process.env.COVERALLS_SERVICE_NAME = 'SERVICE_NAME';
@@ -665,6 +668,37 @@ const testAzurePipelines = (sut, done) => {
665668
});
666669
};
667670

671+
const testCodefresh = (sut, done) => {
672+
process.env.CF_BRANCH = 'hotfix';
673+
process.env.CF_REVISION = 'e3e3e3e3e3e3e3e3e';
674+
process.env.CF_BUILD_ID = '1234';
675+
process.env.CF_COMMIT_AUTHOR = 'john doe';
676+
process.env.CF_COMMIT_MESSAGE = 'msgmsgmsg';
677+
process.env.CF_PULL_REQUEST_ID = '3';
678+
679+
const git = {
680+
head: {
681+
id: 'e3e3e3e3e3e3e3e3e',
682+
author_name: 'Unknown Author',
683+
author_email: '',
684+
committer_name: 'john doe',
685+
committer_email: '',
686+
message: 'msgmsgmsg'
687+
},
688+
branch: 'hotfix',
689+
remotes: []
690+
};
691+
692+
sut((err, options) => {
693+
should.not.exist(err);
694+
options.service_name.should.equal('Codefresh');
695+
options.service_job_id.should.equal('1234');
696+
options.service_pull_request.should.equal('3');
697+
options.git.should.eql(git);
698+
done();
699+
});
700+
};
701+
668702
function ensureLocalGitContext(options) {
669703
const baseDir = process.cwd();
670704
let dir = baseDir;

0 commit comments

Comments
 (0)