diff --git a/README.md b/README.md index e94f097..9e369bb 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,33 @@ ci.startBuild({ }); ``` +### startBuildTag + +Triggers a new build with no branch, returns a summary of the build. + +#### Example Usage + +```javascript +ci.startBuildTag({ + username: "jpstevens", + project: "circleci", + body: + parallel: null + revision: null + tag: "v0.1.0" + build_parameters: + NODE_ENV: "production" +}).then(function(build){ + console.log(build); +}); +``` + +#### Options +- **username** [required] - The username for the project +- **project** [required] - The project (repo) name +- **options** [optional] - Additional parameters you can pass in + + ### cancelBuild Cancels the build, returns a summary of the build. diff --git a/src/circleci-request.coffee b/src/circleci-request.coffee index 3c2da8a..d44a795 100644 --- a/src/circleci-request.coffee +++ b/src/circleci-request.coffee @@ -39,6 +39,8 @@ class CircleCIRequest config.json = true if data and data.body config.body = data.body + if data and data.tag + config.body.tag = data.tag config buildQueryObject: (availableOptions, data) -> diff --git a/src/circleci.coffee b/src/circleci.coffee index a2acfa7..b2d3caa 100644 --- a/src/circleci.coffee +++ b/src/circleci.coffee @@ -30,6 +30,9 @@ class CircleCI startBuild: (opts) -> @request.process @routes['startBuild'], opts + startBuildTag: (opts) -> + @request.process @routes['startBuildTag'], opts + cancelBuild: (opts) -> @request.process @routes['cancelBuild'], opts diff --git a/src/routes.json b/src/routes.json index 07caadf..e3d9a48 100644 --- a/src/routes.json +++ b/src/routes.json @@ -41,6 +41,10 @@ "path": "\/project\/:username\/:project\/tree\/:branch", "method": "POST" }, + "startBuildTag": { + "path": "\/project\/:username\/:project", + "method": "POST" + }, "cancelBuild": { "path": "\/project\/:username\/:project\/:build_num\/cancel", "method": "POST" diff --git a/tests/integration/start-build-tag-spec.coffee b/tests/integration/start-build-tag-spec.coffee new file mode 100644 index 0000000..57970ed --- /dev/null +++ b/tests/integration/start-build-tag-spec.coffee @@ -0,0 +1,27 @@ +require 'coffee-script/register' +expect = require('chai').expect +sinon = require('sinon') +CircleCI = require "../../src/circleci" +APIHelper = require "../helpers/api-helper" + +describe "startBuild", -> + + before -> + @circleci = new CircleCI { auth: process.env.CIRCLE_TOKEN } + @config = + username: process.env.CIRCLE_USER + project: process.env.CIRCLE_PROJECT + body: + tag: 'v0.1.0' + parallel: null + revision: null + build_parameters: + NODE_ENV: "production" + FOO: "bar" + + it "starts the build", (done) -> + @circleci.startBuildTag(@config).then (res) -> + expect(res).to.be.ok + APIHelper.cancelBuild res.build_num, -> done() + .catch (err) -> + done(err)