Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/circleci-request.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down
3 changes: 3 additions & 0 deletions src/circleci.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
27 changes: 27 additions & 0 deletions tests/integration/start-build-tag-spec.coffee
Original file line number Diff line number Diff line change
@@ -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)