import TeamcityClient from 'teamcity-client';
const api = new TeamcityClient({
host: 'teamcity.domain.com',
user: 'username', // optional
password: 'pwd' // optional
});
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
Download source
api.artifact.content(options, 'relative/path/to/source')
.then(blob => console.log(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 => console.log(blob))
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))
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))