diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js index 416b3b4b..bcbb9933 100644 --- a/lib/convertLcovToCoveralls.js +++ b/lib/convertLcovToCoveralls.js @@ -92,6 +92,10 @@ const convertLcovToCoveralls = (input, options, cb) => { postJson.service_job_id = options.service_job_id; } + if (options.service_job_number) { + postJson.service_job_number = options.service_job_number; + } + if (options.service_pull_request) { postJson.service_pull_request = options.service_pull_request; } diff --git a/lib/getOptions.js b/lib/getOptions.js index 2f9c9fb3..3ac55794 100644 --- a/lib/getOptions.js +++ b/lib/getOptions.js @@ -24,6 +24,7 @@ const getBaseOptions = cb => { if (process.env.TRAVIS) { options.service_name = 'travis-ci'; + options.service_number = process.env.TRAVIS_BUILD_NUMBER; options.service_job_id = process.env.TRAVIS_JOB_ID; options.service_pull_request = process.env.TRAVIS_PULL_REQUEST; git_commit = 'HEAD'; @@ -53,7 +54,8 @@ const getBaseOptions = cb => { if (process.env.CIRCLECI) { options.service_name = 'circleci'; - options.service_job_id = process.env.CIRCLE_BUILD_NUM; + options.service_number = process.env.CIRCLE_WORKFLOW_ID; + options.service_job_number = process.env.CIRCLE_BUILD_NUM; if (process.env.CI_PULL_REQUEST) { const pr = process.env.CI_PULL_REQUEST.split('/pull/'); @@ -147,6 +149,10 @@ const getBaseOptions = cb => { options.service_number = process.env.COVERALLS_SERVICE_NUMBER; } + if (process.env.COVERALLS_SERVICE_JOB_NUMBER) { + options.service_job_number = process.env.COVERALLS_SERVICE_JOB_NUMBER; + } + if (process.env.COVERALLS_SERVICE_JOB_ID) { options.service_job_id = process.env.COVERALLS_SERVICE_JOB_ID; } diff --git a/test/convertLcovToCoveralls.js b/test/convertLcovToCoveralls.js index eca48a96..2adaa835 100644 --- a/test/convertLcovToCoveralls.js +++ b/test/convertLcovToCoveralls.js @@ -31,6 +31,7 @@ describe('convertLcovToCoveralls', () => { process.env.COVERALLS_SERVICE_NAME = 'SERVICE_NAME'; process.env.COVERALLS_SERVICE_NUMBER = 'SERVICE_NUMBER'; process.env.COVERALLS_SERVICE_JOB_ID = 'SERVICE_JOB_ID'; + process.env.COVERALLS_SERVICE_JOB_NUMBER = 'SERVICE_JOB_NUMBER'; process.env.COVERALLS_REPO_TOKEN = 'REPO_TOKEN'; process.env.CI_PULL_REQUEST = 'https://github.com/fake/fake/pulls/123'; process.env.COVERALLS_PARALLEL = 'true'; @@ -48,6 +49,7 @@ describe('convertLcovToCoveralls', () => { output.service_name.should.equal('SERVICE_NAME'); output.service_number.should.equal('SERVICE_NUMBER'); output.service_job_id.should.equal('SERVICE_JOB_ID'); + output.service_job_number.should.equal('SERVICE_JOB_NUMBER'); output.service_pull_request.should.equal('123'); output.parallel.should.equal(true); output.flag_name.should.equal('FLAG_NAME'); diff --git a/test/getOptions.js b/test/getOptions.js index 8ed95c6c..5bf0312f 100644 --- a/test/getOptions.js +++ b/test/getOptions.js @@ -357,12 +357,14 @@ const testServicePullRequest = (sut, done) => { const testTravisCi = (sut, done) => { process.env.TRAVIS = 'TRUE'; - process.env.TRAVIS_JOB_ID = '1234'; + process.env.TRAVIS_BUILD_NUMBER = '1'; + process.env.TRAVIS_JOB_ID = '12'; process.env.TRAVIS_PULL_REQUEST = '123'; sut((err, options) => { should.not.exist(err); options.service_name.should.equal('travis-ci'); - options.service_job_id.should.equal('1234'); + options.service_number.should.equal('1'); + options.service_job_id.should.equal('12'); options.service_pull_request.should.equal('123'); done(); }); @@ -373,12 +375,12 @@ const testTravisPro = (sut, done) => { const service_name = 'travis-pro'; fs.writeFileSync(file, `service_name: ${service_name}`); process.env.TRAVIS = 'TRUE'; - process.env.TRAVIS_JOB_ID = '1234'; + process.env.TRAVIS_BUILD_NUMBER = '1234'; process.env.TRAVIS_COMMIT = 'a12s2d3df4f435g45g45g67h5g6'; sut((err, options) => { should.not.exist(err); options.service_name.should.equal(service_name); - options.service_job_id.should.equal('1234'); + options.service_number.should.equal('1234'); options.git.head.id.should.equal('HEAD'); fs.unlinkSync(file); done(); @@ -416,7 +418,8 @@ const testJenkins = (sut, done) => { const testCircleCi = (sut, done) => { process.env.CIRCLECI = true; process.env.CIRCLE_BRANCH = 'master'; - process.env.CIRCLE_BUILD_NUM = '1234'; + process.env.CIRCLE_WORKFLOW_ID = '1'; + process.env.CIRCLE_BUILD_NUM = '2'; process.env.CIRCLE_SHA1 = 'e3e3e3e3e3e3e3e3e'; process.env.CI_PULL_REQUEST = 'http://github.com/node-coveralls/pull/3'; @@ -436,7 +439,8 @@ const testCircleCi = (sut, done) => { sut((err, options) => { should.not.exist(err); options.service_name.should.equal('circleci'); - options.service_job_id.should.equal('1234'); + options.service_number.should.equal('1'); + options.service_job_number.should.equal('2'); options.service_pull_request.should.equal('3'); options.git.should.eql(git); done();