Code Monkey home page Code Monkey logo

teamcity-client's Introduction

Build Status

Teamcity Node.js client

const TeamcityClient = require('teamcity-client');

const api = new TeamcityClient({
    host: 'teamcity.domain.com',
    user: 'username', // optional
    password: 'pwd' // optional
});

builds

Get detail info about build

const options = {
    tags: ['production', 'tested'],
    user: 'username'
};

// get last build by criteria
api.build.detail(options)
   .then(buildInfo => console.log(buildInfo))
   .catch(err => console.error(err));

// get build by id
api.build.detail({id: 'my-build-id'})
   .then(buildInfo => console.log(buildInfo))
   .catch(err => console.error(err));

// get build by number
api.build.detail({number: '537'})
   .then(buildInfo => console.log(buildInfo))
   .catch(err => console.error(err));

Get list of builds by criteria

api.build.list({buildType: {id: 'project-id'}})
   .then(buildList => console.log(buildList))

api.build.list({buildType: {id: 'project-id'}, tags: ['production']})
   .then(buildList => console.log(buildList))

You can use all build locator params to get build

artifacts

Download source

const fs = require('q-io/fs');

api.artifact.content(options, 'relative/path/to/source')
   .then(blob => fs.write('data.zip', blob))

Get metadata

api.artifact.meta(options, 'source.json')
   .then(data => console.log(data));

Response example

{
  "name": "source.json",
  "size": 25360,
  "modificationTime": "20151202T183212+0300",
  "href": "/guestAuth/app/rest/builds/id:10/artifacts/metadata/source.json",
  "content": {
    "href": "/guestAuth/app/rest/builds/id:10/artifacts/content/source.json"
  }
}

Get children list

api.artifact.children(options, 'relative/path')
   .then(data => console.log(JSON.stringify(data, null, 2)))

Response example

{
  "count": 1,
  "file": [
    {
      "name": "pathA",
      "modificationTime": "2T183246+0300",
      "href": "/guestAuth/app/rest/builds/id:4869415/artifacts/metadata/relative/path/pathA",
      "children": {
        "href": "/guestAuth/app/rest/builds/id:4869415/artifacts/children/relative/path/pathA"
      }
    },
  ]
}

Download archived sources

Download zip with all js-files in directory relative/path

api.artifact.archived(options, 'relative/path', '**/*.js')
   .then(blob => fs.write('data.zip', blob))

tags

Get tags

api.tags.get(locator)
   .then(data => console.log(data))

Add tags

api.tags.add(locator, ['tag1', 'tag2'])
   .then(data => console.log(data))

api.tags.add(locator, 'new_tag')
   .then(data => console.log(data))

Replace tags

api.tags.replace(locator, ['tag1', 'tag2'])
   .then(data => console.log(data))

api.tags.add(locator, 'new_tag')
   .then(data => console.log(data))

changes

Get changes list

api.changes.list(buildId)
   .then(data => console.log(data))

Get changes list with details

api.changes.list(buildId, {withDetails: true})
   .then(data => console.log(data))

Get particular change details

api.changes.detail(changeId)
   .then(data => console.log(data))

teamcity-client's People

Contributors

acvetkov avatar aik-jahoda avatar akaguny avatar ayan4m1 avatar barcai avatar dutow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

teamcity-client's Issues

Basic authorization stopped working in TeamCity 10

After upgrading to TeamCity 10 every call resulted in 401 unauthorized.
Finally tracked the issue to the basic authorization header you're sending - it's missing the "Basic " prefix.
Changing authHeader property to return {Authorization: "Basic " + this.auth} instead of {Authorization: this.auth} resolved the issue

Remove unneeded dependencies

from package.json:

  "dependencies": {
    "bluebird": "^3.0.6", // never used!
    "debug": "^2.2.0", // never used!
    "lodash": "^3.10.1",
    "q": "^1.4.1", // never used!
    "q-io": "^1.13.1"
  },

I suggest to remove it.

Support for fields querystring parameter

I want to retrieve detailed information about running builds (e.g. estimated time) which isn't returned by default from the TeamCity's REST API.
Using the fields querystring parameter it is possible to configure the returned fields in the response. An example API call will be:
http://localhost:8111/app/rest/builds/?locator=running:true&fields=count,build(id,status,state,running-info)

Please add support for passing the fields to return in the response.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.