-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add sd-cmd documentation (#158)
* fix: Fix TOC for FAQ * fix: Update workflow with requires keyword * feat: Add commands documentation
- Loading branch information
Showing
5 changed files
with
123 additions
and
23 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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
layout: main | ||
title: Commands | ||
category: User Guide | ||
menu: menu | ||
toc: | ||
- title: Commands | ||
url: "#commands" | ||
- title: Using a command | ||
url: "#using-a-command" | ||
- title: Creating a command | ||
url: "#creating-a-command" | ||
- title: Finding commands | ||
url: "#finding-commands" | ||
- title: More links | ||
url: "#more-links" | ||
--- | ||
# Commands | ||
|
||
Screwdriver commands are executables which can either be a group of [commands](https://en.wikipedia.org/wiki/Command_(computing)) in a script or a binary that people can use to replace a step definition in a [screwdriver.yaml](./configuration). | ||
|
||
## Using a command | ||
|
||
To use a command, define a `screwdriver.yaml` that uses the `sd-cmd` cli with the format: | ||
|
||
``` | ||
$ sd-cmd exec <namespace>/<name>@<version> <arguments> | ||
``` | ||
|
||
__Input:__ | ||
|
||
- `namespace/name` - the fully-qualified command name | ||
- `version` - a semver-compatible format or tag | ||
- `arguments` - passed directly to the underlying format | ||
|
||
__Output:__ | ||
|
||
All debug logs about the command lookup and execution are stored in `$SD_ARTIFACTS_DIR/.sd/commands/namespace/name/version/timestamp.log` | ||
|
||
Example: | ||
```yaml | ||
jobs: | ||
main: | ||
requires: [~pr, ~commit] | ||
steps: | ||
- exec: sd-cmd exec foo/bar@1 -baz sample | ||
``` | ||
Screwdriver will download that binary or script from the Store, make it executable, and run it with the `-baz sample` arguments directly: | ||
``` | ||
$ /opt/sd/commands/foo/bar/1.0.1/foobar.sh -baz sample | ||
``` | ||
## Creating a command | ||
Publishing and running commands must be done from a Screwdriver pipeline. | ||
### Writing a command yaml | ||
To create a command, create a repo with a `sd-command.yaml` file. The file should contain a namespace, name, version, description, maintainer email, format, and a binary config with a path to file. | ||
Example `sd-command.yaml`: | ||
```yaml | ||
namespace: foo # Namespace for the command | ||
name: bar # Command name | ||
version: 1.0 # Major and Minor version number (patch is automatic) | ||
description: | | ||
Lorem ipsum dolor sit amet. | ||
maintainer: [email protected] # Maintainer of the command | ||
format: binary # Format the command is in (binary) | ||
binary: | ||
file: ./foobar.sh # Path to script or binary file | ||
``` | ||
|
||
### Writing a screwdriver.yaml for your command repo | ||
|
||
To validate your command, run the `command-validate` script from the [screwdriver-command-validator](https://github.com/screwdriver-cd/command-validator) npm module. This means the build image must have NodeJS and NPM properly installed to use it. | ||
|
||
To publish your command, run the `sd-cmd publish` command in a separate job. `-f` stands for file. | ||
|
||
Example `screwdriver.yaml`: | ||
```yaml | ||
shared: | ||
image: node:6 | ||
jobs: | ||
main: | ||
requires: [~pr, ~commit] | ||
steps: | ||
- install: npm install screwdriver-command-validator | ||
- validate: ./node_modules/.bin/command-validate -f sd-command.yaml | ||
publish: | ||
requires: [main] | ||
steps: | ||
- publish: sd-cmd publish -f sd-command.yaml | ||
``` | ||
## Finding commands | ||
To figure out which commands already exist, you can make a `GET` call to the `/commands` endpoint. See the [API documentation](./api) for more information. | ||
|
||
## More links | ||
- [Design specifications](https://github.com/screwdriver-cd/screwdriver/blob/master/design/commands.md)* | ||
|
||
_*May be out of date._ |
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ Screwdriver takes the template configuration and plugs it in, so that the `screw | |
jobs: | ||
main: | ||
image: node:6 | ||
requires: [~pr, ~commit] | ||
steps: | ||
- install: npm install | ||
- test: npm test | ||
|
@@ -50,6 +51,7 @@ Example: | |
```yaml | ||
jobs: | ||
main: | ||
requires: [~pr, ~commit] | ||
template: [email protected] | ||
steps: | ||
- preinstall: echo pre-install | ||
|
@@ -65,6 +67,7 @@ Example: | |
```yaml | ||
jobs: | ||
main: | ||
requires: [~pr, ~commit] | ||
template: [email protected] | ||
steps: | ||
- install: echo skip installing | ||
|
@@ -112,14 +115,15 @@ Example `screwdriver.yaml`: | |
shared: | ||
image: node:6 | ||
jobs: | ||
# the main job is run in pull requests as well | ||
main: | ||
requires: [~pr, ~commit] | ||
steps: | ||
- install: npm install screwdriver-template-main | ||
- validate: ./node_modules/.bin/template-validate | ||
environment: | ||
SD_TEMPLATE_PATH: ./path/to/template.yaml | ||
publish: | ||
requires: [main] | ||
steps: | ||
- install: npm install screwdriver-template-main | ||
- publish: ./node_modules/.bin/template-publish | ||
|