Skip to content

Commit

Permalink
bitbucket support, CCI api v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Kaspar committed Aug 12, 2016
1 parent 4e94c2d commit c5c2c97
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
3 changes: 2 additions & 1 deletion code/cci-pingu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cfg-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions code/lib/cfg-file.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down
8 changes: 4 additions & 4 deletions code/lib/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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, {
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down
1 change: 1 addition & 0 deletions unit-test-data/full.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"token": "token",
"hosting": "hosting",
"organisation": "organisation",
"project": "project",
"branch": "branch",
Expand Down
1 change: 1 addition & 0 deletions unit-test-data/minimal.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"token": "token",
"hosting": "hosting",
"organisation": "organisation",
"project": "project",
"branch": "branch",
Expand Down

0 comments on commit c5c2c97

Please sign in to comment.