runas-plugin-scm-git
Version:
Runas plugin for SCM operations (Git implementation)
128 lines (86 loc) • 3.48 kB
Markdown
SCM operations for runas (Git implementation)
### Hook (stages: config)
Any step can configure this plugin to perform a number of SCM operations.
#### 1. Install plugin
**Add package dependency:**
npm install --save runas-plugin-scm-git
**Add plugin on steps/$stepName/config.json plugins:**
```
{
"plugins: [
[...]
"scm"
]
}
```
#### 2. Add git requirement to the step
```
{
"requirements": {
[...]
"git": {}
}
}
```
#### 3. Configure plugin in config.json
Example:
```
{
"scm": {
"operation": "checkout",
"repos": [{
"repo": "ssh://git@globalrepos.com/ctool/runas-plugin-scm-git.git",
"folder": "projects/tools"
}],
"jobs": 10
}
}
```
- **operation** Any of the operations supported by the plugin (see below)
- **repos** A list of repos in which the operation will be performed. Each repo must be an object containing the fields required by the **operation** (see below)
- **jobs** Number of jobs executed in parallel
### Addons
### this.scmClone
Executes ```git clone ${options.repo}```. If present, sets current working directory to ```${options.folder}```. If not, works in the cwd.
| Param | Description |
| --- | --- |
| options | object containing the fields **repo** and **folder** |
| returns | a Promise with the complete child_process object result of the execution |
### this.scmPull
Executes ```git pull --rebase```. If present, sets current working directory to ```${options.folder}```. If not, works in the cwd.
| Param | Description |
| --- | --- |
| options | object containing the field **folder** |
| returns | a Promise with the complete child_process object result of the execution |
### this.scmCheckout
Checks whether the ```${options.repo}``` exists in ```${options.folder}``` or not, and executes either a ```scmPull``` (if exists) or a ```scmClone``` (if not).
| Param | Description |
| --- | --- |
| options | object containing the fields **repo** and **folder** |
| returns | a Promise with the complete child_process object result of the execution |
### this.scmUpdate
Alias for ```scmPull```.
### this.scmAdd
Executes ```git add --all``` in the folder ```${options.folder}``` (if not present, in the cwd).
| Param | Description |
| --- | --- |
| options | object containing the field **folder** |
| returns | a Promise with the complete child_process object result of the execution |
### this.scmCommit
Executes ```git commit -m ${options.message}``` in the folder ```${options.folder}``` (if not present, in the cwd).
| Param | Description |
| --- | --- |
| options | object containing the fields **message** and **folder** |
| returns | a Promise with the complete child_process object result of the execution |
### this.scmPush
Executes ```git push -u origin ${options.branch} .``` in the folder ```${options.folder}``` (if not present, in the cwd). If ```${options.branch}``` is not present, it will use the value **master**.
| Param | Description |
| --- | --- |
| options | object containing the fields **branch** and **folder** |
| returns | a Promise with the complete child_process object result of the execution |
### this.scmFetch
Executes ```git fetch -p``` in the folder ```${options.folder}``` (if not present, in the cwd).
| Param | Description |
| --- | --- |
| options | object containing the fields **branch** and **folder** |
| returns | a Promise with the complete child_process object result of the execution |