Skip to content
Permalink
Browse files
Add Codefresh support
  • Loading branch information
suda authored and nickmerwin committed Mar 19, 2020
1 parent 8c4ba99 commit 710c50448f79d7145f524948ddd7a5e9f548fa42
Showing 2 changed files with 44 additions and 0 deletions.
@@ -131,6 +131,16 @@ const getBaseOptions = cb => {
git_branch = process.env.BUILD_SOURCEBRANCHNAME;
}

if (process.env.CF_BRANCH) {
options.service_name = 'Codefresh';
options.service_job_id = process.env.CF_BUILD_ID;
options.service_pull_request = process.env.CF_PULL_REQUEST_ID;
git_commit = process.env.CF_REVISION;
git_branch = process.env.CF_BRANCH;
git_committer_name = process.env.CF_COMMIT_AUTHOR;
git_message = process.env.CF_COMMIT_MESSAGE;
}

options.run_at = process.env.COVERALLS_RUN_AT || JSON.stringify(new Date()).slice(1, -1);
if (process.env.COVERALLS_SERVICE_NAME) {
options.service_name = process.env.COVERALLS_SERVICE_NAME;
@@ -170,6 +170,9 @@ describe('getOptions', () => {
it('should set service_name and service_job_id if it\'s running via Azure Pipelines', done => {
testAzurePipelines(getOptions, done);
});
it('should set service_name and service_job_id if it\'s running via CodeFresh', done => {
testCodefresh(getOptions, done);
});
it('should override set options with user options', done => {
const userOptions = { service_name: 'OVERRIDDEN_SERVICE_NAME' };
process.env.COVERALLS_SERVICE_NAME = 'SERVICE_NAME';
@@ -665,6 +668,37 @@ const testAzurePipelines = (sut, done) => {
});
};

const testCodefresh = (sut, done) => {
process.env.CF_BRANCH = 'hotfix';
process.env.CF_REVISION = 'e3e3e3e3e3e3e3e3e';
process.env.CF_BUILD_ID = '1234';
process.env.CF_COMMIT_AUTHOR = 'john doe';
process.env.CF_COMMIT_MESSAGE = 'msgmsgmsg';
process.env.CF_PULL_REQUEST_ID = '3';

const git = {
head: {
id: 'e3e3e3e3e3e3e3e3e',
author_name: 'Unknown Author',
author_email: '',
committer_name: 'john doe',
committer_email: '',
message: 'msgmsgmsg'
},
branch: 'hotfix',
remotes: []
};

sut((err, options) => {
should.not.exist(err);
options.service_name.should.equal('Codefresh');
options.service_job_id.should.equal('1234');
options.service_pull_request.should.equal('3');
options.git.should.eql(git);
done();
});
};

function ensureLocalGitContext(options) {
const baseDir = process.cwd();
let dir = baseDir;

0 comments on commit 710c504

Please sign in to comment.