Base class for defining the behavior between screwdriver and source control management systems
npm install screwdriver-scm-base
This is a promise based interface for interacting with a source control management system
The configure
function takes in an object and resets the configuration values
Required parameters:
Parameter | Type | Description |
---|---|---|
scmUrl | String | Scm Url to format |
A formatted scm url to be used as a unique key. This function is synchronous.
Required parameters:
Parameter | Type | Description |
---|---|---|
config | Object | Configuration Object |
config.scmUrl | String | The scmUrl to get permissions on |
config.token | String | The github token to check permissions on |
Permissions for a given token on a repository in the form of:
{
admin: true,
push: true,
pull: true
}
- Resolve with a permissions object for the repository
- Reject if not able to get permissions
Required parameters:
Parameter | Type | Description |
---|---|---|
config | Object | Configuration Object |
config.scmUrl | String | The scmUrl to get permissions on |
config.token | String | The github token to check permissions on |
The commit sha for a given branch on a repository.
- Resolve with a commit sha string for the given
scmUrl
- Reject if not able to get a sha
The parameters required are:
Parameter | Type | Required | Description |
---|---|---|---|
config | Object | true | Configuration Object |
config.scmUrl | String | true | The scmUrl to get permissions on |
config.token | String | true | The github token to check permissions on |
config.sha | String | true | The github sha to update a status for |
config.buildStatus | String | true | The screwdriver build status to translate into github commit status |
config.url | String | false | The target url for setting up details |
Update the commit status for a given repository and sha.
- Resolve when the commit status was updated
- Reject if the commit status fails to update
The parameters required are:
Parameter | Type | Required | Description |
---|---|---|---|
config | Object | true | Configuration Object |
config.scmUrl | String | true | The scmUrl to get permissions on |
config.token | String | true | The github token to check permissions on |
config.path | String | true | The path to the file on github to read |
config.ref | String | false | The reference to the github repo, could be a branch or sha |
The contents of the file at path
in the repository
- Resolve with the contents of
path
- Reject if the
path
cannot be downloaded, decoded, or is not a file
To make use of the validation functions, the functions to override are:
formatScmUrl
_getPermissions
_getCommitSha
_updateCommitStatus
_getFile
stats
class MyScm extends ScmBase {
// Implement the interface
_getFile(config) {
// do stuff here to lookup scmUrl
return Promise.resolve('these are contents that are gotten')
}
}
const scm = new MyScm({});
scm.getFile({
scmUrl: '[email protected]:repo/foo.git#master',
path: 'screwdriver.yaml',
token: 'abcdefg'
}).then(data => {
// do something...
});
npm test
Code licensed under the BSD 3-Clause license. See LICENSE file for terms.