Skip to content

Commit

Permalink
added command line utility docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed Oct 25, 2015
1 parent 3dd218b commit 3c8c330
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ gen_static:
mkdir -p static/docs_gen/api static/docs_gen/build
mkdir -p static/docs_gen/api static/docs_gen/plugin
mkdir -p static/docs_gen/api static/docs_gen/setup
mkdir -p static/docs_gen/api static/docs_gen/cli
go generate github.com/drone/drone/static

gen_template:
Expand Down
4 changes: 4 additions & 0 deletions docs/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* [Install](index.md)
* [Local Builds](builds.md)
* [Encrypt Secrets](secrets.md)
* [Add Machines](machines.md)
35 changes: 35 additions & 0 deletions docs/cli/builds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Local Builds

The `exec` command lets you run a build on your personal machine (ie your laptop). It does not involve the Drone server in any way. This is very useful for local testing and troubleshooting.

## Instructions

The `drone exec` command should be executed from the root of your repository, where the `.drone.yml` file is located:

```
cd octocat/hello-world
drone exec
```

This only executes a `build` step. It does not execute `clone`, `publish`, `deploy`, or `notify` steps, nor will it decrypt your `.drone.sec` file.

## Arguments

The `exec` command accepts the following arguments:

* `DOCKER_HOST` - docker deamon address. defaults to `unix:///var/run/docker.sock`
* `DOCKER_TLS_VERIFY` - docker daemon supports tlsverify
* `DOCKER_CERT_PATH` - docker certificate directory


## Boot2Docker

You may use the `drone exec` command with boot2docker as long as your code exists within your `$HOME` directory. This is because boot2docker mounts your home directory into the virtualbox instance giving the Docker daemon access to your local files.

## Known Issues

Attempting to cancel (`ctrl+C`) a running build will leave behind orphan containers. This is a known issue and we are planning a fix.

## Limitations

You cannot use `drone exec` with a remote Docker instance. Your local codebase is shared via a volume with the Docker daemon, which is not possible when communicating with a remote Docker host on a different machine.
50 changes: 50 additions & 0 deletions docs/cli/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Install

> This is an early preview of the command line utility. Contributors wanted.
Drone provides a simple command line utility that allows you interact with the Drone server from the command line. This section describes the setup and installation process.

## System Requirements

This tool requires Docker 1.6 or higher. If you are using Windows or Mac we recommend installing the [Docker Toolbox](https://www.docker.com/docker-toolbox).

## Linux

Download and install the x64 linux binary:

```
curl http://downloads.drone.io/drone-cli/drone_linux_amd64.tar.gz | tar zx
sudo install -t /usr/local/bin drone
```

## OSX

Download and install using Homebrew:

```
brew tap drone/drone
brew install drone
```

Or manually download and install the binary:

```
curl http://downloads.drone.io/drone-cli/drone_darwin_amd64.tar.gz | tar zx
sudo cp drone /usr/local/bin
```

## Setup

In order to communicate with the Drone server you must provide the server url:

```
export DRONE_SERVER=<http://>
```

In order to authorize communications you must also provide your access token:

```
export DRONE_SERVER=<token>
```

You can retrieve your access token from the user profile screen in Drone.
46 changes: 46 additions & 0 deletions docs/cli/machines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Machine Management

The `drone node create` command lets your register new remote servers with Drone. This command should be used in conjunction with [docker-machine](https://github.com/docker/machine). Note that you can alternatively register and manage servers in the UI.

## Environment Variables

The `drone node create` command expects the following environment variables:

* `DOCKER_HOST` - docker deamon address
* `DOCKER_TLS_VERIFY` - docker daemon supports tlsverify
* `DOCKER_CERT_PATH` - docker certificate directory

## Instructions

Create or configure a new server using `docker-machine`:

```
docker-machine create \
--digitalocean-size 2gb \
--driver digitalocean \
--digitalocean-access-token <token> \
my-drone-worker
```

This writes setup instructions to the console:

```
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://123.456.789.10:2376"
export DOCKER_CERT_PATH="/home/octocat/.docker/machine/machines/my-drone-worker"
export DOCKER_MACHINE_NAME="my-drone-worker"
# Run this command to configure your shell:
# eval "$(docker-machine env my-drone-worker)"
```

Run the following command (from the above output) to configure your shell:

```
eval "$(docker-machine env my-drone-worker)"
```

Register the newly created or configured machine with Drone. Once registered, Drone will immediately begin sending builds to the server.

```
drone node create
```
3 changes: 3 additions & 0 deletions docs/cli/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Overview

> Coming Soon
45 changes: 45 additions & 0 deletions docs/cli/secrets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Encrypt Secrets

The `secure` command lets your create a signed and encrypted `.drone.sec` file. The `.drone.sec` file is decrypted at runtime and will inject your secrets into your `.drone.yml` file.

## Usage

Create a plaintext `.drone.sec.yml` file that contains your secret variables:

```
environment:
- PASSWORD=foo
```

Encrypt and generate the `.drone.sec` file:

```
drone secure --repo octocat/hello-world
```

Commit the encrypted `.drone.sec` file to your repository.

Note the `drone secure` command will automatically calculate the shasum of your yaml file and store in the `.drone.sec` file. This prevent secrets from being injected into the build if the Yaml changes.


## Arguments

The `secure` command accepts the following arguments:

* `--in` secrets in plain text yaml. defaults to `.drone.sec.yml`
* `--out` encrypted secret file. defaults to `.drone.sec`
* `--yaml` location of your `.drone.yml` file. defaults to `.drone.yml`
* `--repo` name of your repository **required**


## Shared Secrets

You cannot re-use the same `.drone.sec` for multiple repositories. You can, however, use the same plaintext secret file for multiple repositories.

```
cd octocat/hello-world
drone secure --in $HOME/.drone.sec.yml --repo octocat/hello-world
cd octocat/Spoon-Knife
drone secure --in $HOME/.drone.sec.yml --repo octocat/Spoon-Knife
```
1 change: 1 addition & 0 deletions static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
//go:generate go run ../contrib/generate-docs.go -input ../docs/build/README.md -name Builds -template ../template/amber/docs.amber -output docs_gen/build/
//go:generate go run ../contrib/generate-docs.go -input ../docs/plugin/README.md -name Plugins -template ../template/amber/docs.amber -output docs_gen/plugin/
//go:generate go run ../contrib/generate-docs.go -input ../docs/setup/README.md -name Install -template ../template/amber/docs.amber -output docs_gen/setup/
//go:generate go run ../contrib/generate-docs.go -input ../docs/cli/README.md -name CLI -template ../template/amber/docs.amber -output docs_gen/cli/

//go:generate sassc --style compact styles/style.sass styles_gen/style.css
//go:generate go-bindata-assetfs -ignore "\\.go" -pkg static -o static_gen.go ./...
Expand Down
4 changes: 4 additions & 0 deletions template/amber/docs.amber
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ block header
a[class="nav-link"][href="../plugin/"]
.active ? Site.Name == "Plugins"
| Plugins
li.nav-item
a[class="nav-link"][href="../cli/"]
.active ? Site.Name == "CLI"
| CLI
li.nav-item
a.nav-link[href="../api/"] API Reference

Expand Down
2 changes: 2 additions & 0 deletions template/amber/swagger.amber
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ block header
a.nav-link[href="../build/"] Builds
li.nav-item
a.nav-link[href="../plugin/"] Plugins
li.nav-item
a.nav-link[href="../cli/"] CLI
li.nav-item
a.nav-link.active[href="#"] API Reference

Expand Down

0 comments on commit 3c8c330

Please sign in to comment.