-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from AntonovAv/dev/teamcity-resource
Teamcity Resource - fix teamcity fake api close #3
- Loading branch information
Showing
6 changed files
with
188 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"/guestAuth/app/rest/": "/", | ||
"/buildTypes": "/buildTypes", | ||
"/buildTypes/id::buildTypeId/builds": "/builds?id=:buildTypeId" | ||
"/buildTypes/id::buildTypeId/builds": "/:buildTypeId" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const axios = require('axios') | ||
const R = require('ramda') | ||
|
||
const BUILD_TYPES_URL = '/guestAuth/app/rest/buildTypes' | ||
|
||
/** | ||
* Retrieve build type ids grouped by project ids | ||
* | ||
* @param host teamcity host | ||
*/ | ||
module.exports.getBuildTypes = (host) => { | ||
return new Promise((resolve, reject) => { | ||
axios | ||
.get(host + BUILD_TYPES_URL, { | ||
headers: { | ||
'Accept': 'application/json' | ||
} | ||
}) | ||
.then(({data}) => { | ||
const result = R.map((buildType) => { | ||
const {id, projectId} = buildType | ||
return { | ||
id, | ||
projectId, | ||
} | ||
}, data.buildType) | ||
resolve(result) | ||
}) | ||
.catch((error) => { | ||
reject(error) | ||
}) | ||
}) | ||
} | ||
|
||
/** | ||
* Retrieve buildType builds statuses | ||
* | ||
* @param host teamcity host | ||
* @param buildTypeId target id of build type | ||
* @param count needed number of builds | ||
*/ | ||
module.exports.getBuildStatus = (host, buildTypeId, count = 2) => { | ||
return new Promise((resolve, reject) => { | ||
axios | ||
.get(host + BUILD_TYPES_URL + `/id:${buildTypeId}/builds?locator=count:${count},running:any`, { | ||
headers: { | ||
'Accept': 'application/json' | ||
} | ||
}) | ||
.then(({data}) => { | ||
const {count, build} = data | ||
if (count === 0) { | ||
resolve([]) | ||
} else { | ||
resolve(R.map((build) => { | ||
const {buildTypeId, status, state} = build | ||
return { | ||
id: buildTypeId, | ||
state, | ||
status | ||
} | ||
}, build)) | ||
} | ||
}) | ||
.catch((error) => { | ||
reject(error) | ||
}) | ||
}) | ||
} |