diff --git a/README.md b/README.md index 7015e21..277a723 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ Config file is a JSON file with configuration object. The keys there have the fo | Name | Mandatory | Type | Default | Meaning | | ---- |:---------:|:----:|:-------:| ------- | | token | * | string | | Your CircleCI API token that will be used when talking to CircleCI. Make sure you can access your project with this token. | -| organisation | * | string | | The name of your github organisation (or user) under which the monitored project lives on CircleCI. | +| hosting | * | string | | "github" or "bitbucket"; where you repo is hosted. | +| organisation | * | string | | The name of your github / bitbucket organisation (or user) under which the monitored project lives on CircleCI. | | project | * | string | | The name of the project you'd like to watch and install locally. | | branch | * | string| | The project repository branch to monitor. | | artifacts | * | array of strings | | List of artifact names that will be downloaded for successful build. Actually, it is list of artifact name *prefixes* so that you can have "test" string in the `artifacts` array and it would match "test-1.2.3.tgz" artifact on CircleCI. | diff --git a/code/cci-pingu.js b/code/cci-pingu.js index de9c3ce..3177143 100644 --- a/code/cci-pingu.js +++ b/code/cci-pingu.js @@ -2,13 +2,14 @@ import logger from './lib/logger'; import cmdline from './lib/cmdline'; import cfgFile from './lib/cfg-file'; import task from './lib/task'; +import version from './lib/version'; logger.install(); const options = cmdline.options; if (options.silent) { logger.level('error'); } if (options.debug) { logger.level('log'); } -console.info('CCI-PINGU started.'); +console.info(`CCI-PINGU started (version:${version})`); console.log('Command line options:\n' + JSON.stringify(options, null, 4)); const sigHandler = () => { diff --git a/code/lib/cfg-file.js b/code/lib/cfg-file.js index 24958be..0dfebc5 100644 --- a/code/lib/cfg-file.js +++ b/code/lib/cfg-file.js @@ -40,7 +40,7 @@ const module = { } } // validate - const mandatory = ['token', 'organisation', 'project', 'branch', 'artifacts', 'script']; + const mandatory = ['token', 'hosting', 'organisation', 'project', 'branch', 'artifacts', 'script']; mandatory.forEach((field) => { if (!(field in obj)) { if (module._verbose) { diff --git a/code/lib/cfg-file.spec.js b/code/lib/cfg-file.spec.js index fb35297..b0561ef 100644 --- a/code/lib/cfg-file.spec.js +++ b/code/lib/cfg-file.spec.js @@ -36,6 +36,7 @@ describe('Config file module', () => { const data = cfgFile.setFilename('unit-test-data/minimal.json').read(); assert.equal(typeof data, 'object'); assert.equal(data.token, 'token'); + assert.equal(data.hosting, 'hosting'); assert.equal(data.organisation, 'organisation'); assert.equal(data.project, 'project'); assert.equal(data.branch, 'branch'); @@ -55,6 +56,7 @@ describe('Config file module', () => { const data = cfgFile.setFilename('unit-test-data/full.json').read(); assert.equal(typeof data, 'object'); assert.equal(data.token, 'token'); + assert.equal(data.hosting, 'hosting'); assert.equal(data.organisation, 'organisation'); assert.equal(data.project, 'project'); assert.equal(data.branch, 'branch'); diff --git a/code/lib/task.js b/code/lib/task.js index 7d4b404..f0272b1 100644 --- a/code/lib/task.js +++ b/code/lib/task.js @@ -203,8 +203,8 @@ const cciBuildInfoHandler = (err, res) => { scheduleNext(); } else { console.info('Build ' + config._last + ' is not installed yet.'); - const apiPath = ['/api/v1/project', config.organisation, config.project, - config._last, 'artifacts']. join('/'); + const apiPath = ['/api/v1.1/project', config.hosting, config.organisation, + config.project, config._last, 'artifacts']. join('/'); console.log('Getting info about build ' + config._last + ' artifacts.'); request .get('https://circleci.com' + apiPath) @@ -220,7 +220,7 @@ module.run = (_options = null) => { EXIT_CODE = 1; // update to 0 on final success if (_options) { options = _options; } config = options.cfgFile.read(); - config._name = [config.organisation, config.project, config.branch].join('/'); + config._name = [config.hosting, config.organisation, config.project, config.branch].join('/'); console.info('CCI task started.'); if (options.install) { cciBuildInfoHandler(null, { @@ -229,7 +229,7 @@ module.run = (_options = null) => { }); return; } - const apiPath = ['/api/v1/project', config.organisation, config.project, 'tree', config.branch].join('/'); + const apiPath = ['/api/v1.1/project', config.hosting, config.organisation, config.project, 'tree', config.branch].join('/'); console.log('Getting info about last successful build of ' + config._name + '.'); request .get('https://circleci.com' + apiPath) diff --git a/package.json b/package.json index 8f14fdf..2844bac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cci-pingu", - "version": "1.2.3", + "version": "1.3.0", "description": "Periodically check for new builds (artifacts) on CircleCI and install them in turn.", "license": "MIT", "author": "Roman Kaspar ", diff --git a/unit-test-data/full.json b/unit-test-data/full.json index b8dd5be..203b8fa 100644 --- a/unit-test-data/full.json +++ b/unit-test-data/full.json @@ -1,5 +1,6 @@ { "token": "token", + "hosting": "hosting", "organisation": "organisation", "project": "project", "branch": "branch", diff --git a/unit-test-data/minimal.json b/unit-test-data/minimal.json index 3f8f0c8..d962d5a 100644 --- a/unit-test-data/minimal.json +++ b/unit-test-data/minimal.json @@ -1,5 +1,6 @@ { "token": "token", + "hosting": "hosting", "organisation": "organisation", "project": "project", "branch": "branch",