diff --git a/.drone.sh b/.drone.sh
index f837953..c9f8f73 100755
--- a/.drone.sh
+++ b/.drone.sh
@@ -6,17 +6,19 @@ set -x
export CGO_ENABLED=0
# compile for all architectures
-GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/linux/amd64/drone github.com/drone/drone-cli/drone
-GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/linux/arm64/drone github.com/drone/drone-cli/drone
-GOOS=linux GOARCH=arm go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/linux/arm/drone github.com/drone/drone-cli/drone
-GOOS=windows GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/windows/amd64/drone github.com/drone/drone-cli/drone
-GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/darwin/amd64/drone github.com/drone/drone-cli/drone
+GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/linux/amd64/drone ./drone
+GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/linux/arm64/drone ./drone
+GOOS=linux GOARCH=ppc64le go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/linux/ppc64le/drone ./drone
+GOOS=linux GOARCH=arm go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/linux/arm/drone ./drone
+GOOS=windows GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/windows/amd64/drone.exe ./drone
+GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o release/darwin/amd64/drone ./drone
# tar binary files prior to upload
tar -cvzf release/drone_linux_amd64.tar.gz -C release/linux/amd64 drone
tar -cvzf release/drone_linux_arm64.tar.gz -C release/linux/arm64 drone
+tar -cvzf release/drone_linux_ppc64le.tar.gz -C release/linux/ppc64le drone
tar -cvzf release/drone_linux_arm.tar.gz -C release/linux/arm drone
-tar -cvzf release/drone_windows_amd64.tar.gz -C release/windows/amd64 drone
+tar -cvzf release/drone_windows_amd64.tar.gz -C release/windows/amd64 drone.exe
tar -cvzf release/drone_darwin_amd64.tar.gz -C release/darwin/amd64 drone
# generate shas for tar files
diff --git a/.drone.yml b/.drone.yml
index 14afd6c..b66df09 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -1,57 +1,88 @@
-workspace:
- base: /go
- path: src/github.com/drone/drone-cli
+kind: pipeline
+type: docker
+name: default
-pipeline:
- build:
- image: golang:1.9
- commands: sh .drone.sh
+steps:
+- name: build
+ image: golang:1.13
+ commands:
+ - sh .drone.sh
- publish_latest:
- image: plugins/docker
+- name: publish_latest
+ image: plugins/docker
+ settings:
repo: drone/cli
- secrets: [docker_username, docker_password]
+ username:
+ from_secret: docker_username
+ password:
+ from_secret: docker_password
auto_tag: true
- when:
- event: [push, tag]
+ when:
+ event: [push, tag]
- publish_alpine:
- image: plugins/docker
+- name: publish_alpine
+ image: plugins/docker
+ settings:
repo: drone/cli
- secrets: [docker_username, docker_password]
+ username:
+ from_secret: docker_username
+ password:
+ from_secret: docker_password
auto_tag: true
auto_tag_suffix: alpine
dockerfile: Dockerfile.alpine
- when:
- event: [push, tag]
+ when:
+ event: [push, tag]
- publish_linux_arm:
- image: plugins/docker
+- name: publish_linux_arm
+ image: plugins/docker
+ settings:
repo: drone/cli
- secrets: [docker_username, docker_password]
+ username:
+ from_secret: docker_username
+ password:
+ from_secret: docker_password
auto_tag: true
auto_tag_suffix: linux-arm
dockerfile: Dockerfile.linux.arm
- when:
- event: [push, tag]
+ when:
+ event: [push, tag]
- publish_linux_arm64:
- image: plugins/docker
+- name: publish_linux_arm64
+ image: plugins/docker
+ settings:
repo: drone/cli
- secrets: [docker_username, docker_password]
+ username:
+ from_secret: docker_username
+ password:
+ from_secret: docker_password
auto_tag: true
auto_tag_suffix: linux-arm64
dockerfile: Dockerfile.linux.arm64
- when:
- event: [push, tag]
+ when:
+ event: [push, tag]
- release:
- image: plugins/github-release
+- name: publish_linux_ppc64le
+ image: plugins/docker
+ settings:
+ repo: drone/cli
+ username:
+ from_secret: docker_username
+ password:
+ from_secret: docker_password
+ auto_tag: true
+ auto_tag_suffix: linux-ppc64le
+ dockerfile: Dockerfile.linux.ppc64le
+ when:
+ event: [push, tag]
+
+- name: release
+ image: plugins/github-release
+ settings:
files:
- release/drone_*.tar.gz
- release/drone_checksums.txt
- secrets:
- - source: github_token
- target: github_release_api_key
- when:
- event: tag
+ api_key:
+ from_secret: github_token
+ when:
+ event: tag
diff --git a/.gitignore b/.gitignore
index 4591e76..9252a88 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
+drone/drone
release
.env
diff --git a/Dockerfile.linux.ppc64le b/Dockerfile.linux.ppc64le
new file mode 100644
index 0000000..783b51c
--- /dev/null
+++ b/Dockerfile.linux.ppc64le
@@ -0,0 +1,6 @@
+FROM drone/ca-certs
+
+COPY release/linux/ppc64le/drone /bin/
+
+ENTRYPOINT ["/bin/drone"]
+
diff --git a/Gopkg.lock b/Gopkg.lock
deleted file mode 100644
index 766a48c..0000000
--- a/Gopkg.lock
+++ /dev/null
@@ -1,250 +0,0 @@
-# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
-
-
-[[projects]]
- name = "github.com/Microsoft/go-winio"
- packages = ["."]
- revision = "7da180ee92d8bd8bb8c37fc560e673e6557c392f"
- version = "v0.4.7"
-
-[[projects]]
- name = "github.com/Sirupsen/logrus"
- packages = ["."]
- revision = "d682213848ed68c0a260ca37d6dd5ace8423f5ba"
- version = "v1.0.4"
-
-[[projects]]
- branch = "master"
- name = "github.com/cncd/pipeline"
- packages = [
- "pipeline",
- "pipeline/backend",
- "pipeline/backend/docker",
- "pipeline/frontend",
- "pipeline/frontend/yaml",
- "pipeline/frontend/yaml/compiler",
- "pipeline/frontend/yaml/linter",
- "pipeline/frontend/yaml/types",
- "pipeline/interrupt",
- "pipeline/multipart"
- ]
- revision = "3a09486affc9215ba52f55b1f6e10182458d1aba"
-
-[[projects]]
- name = "github.com/docker/distribution"
- packages = ["reference"]
- revision = "7dba427612198a11b161a27f9d40bb2dca1ccd20"
-
-[[projects]]
- name = "github.com/docker/docker"
- packages = [
- "api/types",
- "api/types/blkiodev",
- "api/types/container",
- "api/types/events",
- "api/types/filters",
- "api/types/mount",
- "api/types/network",
- "api/types/reference",
- "api/types/registry",
- "api/types/strslice",
- "api/types/swarm",
- "api/types/time",
- "api/types/versions",
- "api/types/volume",
- "client",
- "pkg/ioutils",
- "pkg/longpath",
- "pkg/random",
- "pkg/stdcopy",
- "pkg/stringid",
- "pkg/tlsconfig",
- "reference"
- ]
- revision = "f645ffca04abf2dd6c89ac9057a1eb7d2b0ac338"
-
-[[projects]]
- name = "github.com/docker/go-connections"
- packages = [
- "nat",
- "sockets",
- "tlsconfig"
- ]
- revision = "eb315e36415380e7c2fdee175262560ff42359da"
-
-[[projects]]
- name = "github.com/docker/go-units"
- packages = ["."]
- revision = "f2145db703495b2e525c59662db69a7344b00bb8"
-
-[[projects]]
- name = "github.com/docker/libcompose"
- packages = ["yaml"]
- revision = "1c4bd4542afb20db0b51afd71d9ebceaf206e2dd"
-
-[[projects]]
- name = "github.com/drone/drone-go"
- packages = ["drone"]
- revision = "7f20e6c113d3ffa2af80401c4eba7d510c8fd875"
-
-[[projects]]
- branch = "master"
- name = "github.com/drone/envsubst"
- packages = [
- ".",
- "parse"
- ]
- revision = "f4d1a8ef8670afc9eea1fb95ee09a979fd2763a3"
-
-[[projects]]
- name = "github.com/fatih/color"
- packages = ["."]
- revision = "507f6050b8568533fb3f5504de8e5205fa62a114"
- version = "v1.6.0"
-
-[[projects]]
- branch = "master"
- name = "github.com/flynn/go-shlex"
- packages = ["."]
- revision = "3f9db97f856818214da2e1057f8ad84803971cff"
-
-[[projects]]
- name = "github.com/ghodss/yaml"
- packages = ["."]
- revision = "0ca9ea5df5451ffdf184b4428c902747c2c11cd7"
- version = "v1.0.0"
-
-[[projects]]
- name = "github.com/golang/protobuf"
- packages = ["proto"]
- revision = "925541529c1fa6821df4e44ce2723319eb2be768"
- version = "v1.0.0"
-
-[[projects]]
- branch = "master"
- name = "github.com/google/go-jsonnet"
- packages = [
- ".",
- "ast",
- "parser"
- ]
- revision = "0274286eef945e5e24be6ebfc13a9deefdd312ee"
- source = "https://github.com/drone/go-jsonnet.git"
-
-[[projects]]
- branch = "master"
- name = "github.com/jackspirou/syscerts"
- packages = ["."]
- revision = "b68f5469dff16e102bd6a2d5b3e79341c938d736"
-
-[[projects]]
- name = "github.com/joho/godotenv"
- packages = [
- ".",
- "autoload"
- ]
- revision = "a79fa1e548e2c689c241d10173efd51e5d689d5b"
- version = "v1.2.0"
-
-[[projects]]
- name = "github.com/mattn/go-colorable"
- packages = ["."]
- revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
- version = "v0.0.9"
-
-[[projects]]
- name = "github.com/mattn/go-isatty"
- packages = ["."]
- revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
- version = "v0.0.3"
-
-[[projects]]
- name = "github.com/opencontainers/go-digest"
- packages = ["."]
- revision = "279bed98673dd5bef374d3b6e4b09e2af76183bf"
- version = "v1.0.0-rc1"
-
-[[projects]]
- branch = "master"
- name = "github.com/pkg/browser"
- packages = ["."]
- revision = "c90ca0c84f15f81c982e32665bffd8d7aac8f097"
-
-[[projects]]
- name = "github.com/pkg/errors"
- packages = ["."]
- revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
- version = "v0.8.0"
-
-[[projects]]
- name = "github.com/urfave/cli"
- packages = ["."]
- revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1"
- version = "v1.20.0"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/crypto"
- packages = ["ssh/terminal"]
- revision = "650f4a345ab4e5b245a3034b110ebc7299e68186"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/net"
- packages = [
- "context",
- "context/ctxhttp",
- "proxy"
- ]
- revision = "f5dfe339be1d06f81b22525fe34671ee7d2c8904"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/oauth2"
- packages = [
- ".",
- "internal"
- ]
- revision = "543e37812f10c46c622c9575afd7ad22f22a12ba"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/sync"
- packages = ["errgroup"]
- revision = "fd80eb99c8f653c847d294a001bdf2a3a6f768f5"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/sys"
- packages = [
- "unix",
- "windows"
- ]
- revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd"
-
-[[projects]]
- name = "google.golang.org/appengine"
- packages = [
- "internal",
- "internal/base",
- "internal/datastore",
- "internal/log",
- "internal/remote_api",
- "internal/urlfetch",
- "urlfetch"
- ]
- revision = "150dc57a1b433e64154302bdc40b6bb8aefa313a"
- version = "v1.0.0"
-
-[[projects]]
- branch = "v2"
- name = "gopkg.in/yaml.v2"
- packages = ["."]
- revision = "d670f9405373e636a5a2765eea47fac0c9bc91a4"
-
-[solve-meta]
- analyzer-name = "dep"
- analyzer-version = 1
- inputs-digest = "3c2492a2f392e0e4d42f2247aca5631e020aed1e2dea238bb56e27739866927a"
- solver-name = "gps-cdcl"
- solver-version = 1
diff --git a/Gopkg.toml b/Gopkg.toml
deleted file mode 100644
index a8d9f67..0000000
--- a/Gopkg.toml
+++ /dev/null
@@ -1,74 +0,0 @@
-# required = ["github.com/user/thing/cmd/thing"]
-# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
-
-[[constraint]]
- name = "github.com/cncd/pipeline"
- branch = "master"
-
-[[constraint]]
- name = "github.com/drone/drone-go"
- revision = "7f20e6c113d3ffa2af80401c4eba7d510c8fd875"
-
-[[constraint]]
- branch = "master"
- name = "github.com/drone/envsubst"
-
-[[constraint]]
- branch = "master"
- name = "github.com/jackspirou/syscerts"
-
-[[constraint]]
- name = "github.com/joho/godotenv"
- version = "1.2.0"
-
-[[constraint]]
- branch = "master"
- name = "github.com/pkg/browser"
-
-[[constraint]]
- name = "github.com/urfave/cli"
- version = "1.20.0"
-
-[[constraint]]
- branch = "master"
- name = "golang.org/x/net"
-
-[[constraint]]
- branch = "master"
- name = "golang.org/x/oauth2"
-
-[[constraint]]
- branch = "master"
- name = "github.com/google/go-jsonnet"
- source = "https://github.com/drone/go-jsonnet.git"
-
-#
-# Some project dependencies hale from the dark ages
-# of Go dependnecy management and require that we point
-# to specific revisions.
-#
-
-[[override]]
- name = "github.com/docker/docker"
- revision = "f645ffca04abf2dd6c89ac9057a1eb7d2b0ac338"
-
-[[override]]
- name = "github.com/docker/distribution"
- revision = "7dba427612198a11b161a27f9d40bb2dca1ccd20"
-
-[[override]]
- name = "github.com/docker/go-connections"
- revision = "eb315e36415380e7c2fdee175262560ff42359da"
-
-[[override]]
- name = "github.com/docker/go-units"
- revision = "f2145db703495b2e525c59662db69a7344b00bb8"
-
-[[override]]
- name = "github.com/docker/libcompose"
- revision = "1c4bd4542afb20db0b51afd71d9ebceaf206e2dd"
-
-[prune]
- go-tests = true
- unused-packages = true
- non-go = true
diff --git a/README.md b/README.md
index 46cb156..d98da53 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,12 @@
-Command line client for the Drone continuous integration server. Please see the official documentation at http://docs.drone.io/cli-installation/
+# drone-cli
+
+Command line client for the Drone continuous integration server.
+
+Documentation:
+https://docs.drone.io/cli
+
+Technical Support:
+https://discourse.drone.io
+
+Bug Tracker:
+https://discourse.drone.io/c/bugs
diff --git a/drone/autoscale/autoscale_version.go b/drone/autoscale/autoscale_version.go
index e806609..96bfe8b 100644
--- a/drone/autoscale/autoscale_version.go
+++ b/drone/autoscale/autoscale_version.go
@@ -4,9 +4,9 @@ import (
"os"
"text/template"
- "github.com/urfave/cli"
-
"github.com/drone/drone-cli/drone/internal"
+ "github.com/drone/funcmap"
+ "github.com/urfave/cli"
)
var autoscaleVersionCmd = cli.Command{
@@ -15,10 +15,9 @@ var autoscaleVersionCmd = cli.Command{
Action: autoscaleVersion,
Flags: []cli.Flag{
cli.StringFlag{
- Name: "format",
- Usage: "format output",
- Value: tmplAutoscaleVersion,
- Hidden: true,
+ Name: "format",
+ Usage: "format output",
+ Value: tmplAutoscaleVersion,
},
},
}
@@ -34,7 +33,7 @@ func autoscaleVersion(c *cli.Context) error {
return err
}
- tmpl, err := template.New("_").Parse(c.String("format") + "\n")
+ tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format") + "\n")
if err != nil {
return err
}
diff --git a/drone/build/build.go b/drone/build/build.go
index 287f0ea..92d40c1 100644
--- a/drone/build/build.go
+++ b/drone/build/build.go
@@ -9,14 +9,14 @@ var Command = cli.Command{
Subcommands: []cli.Command{
buildListCmd,
buildLastCmd,
- buildLogsCmd,
buildInfoCmd,
+ buildCreateCmd,
buildStopCmd,
buildStartCmd,
buildApproveCmd,
buildDeclineCmd,
+ buildPromoteCmd,
+ buildRollbackCmd,
buildQueueCmd,
- buildKillCmd,
- buildPsCmd,
},
}
diff --git a/drone/build/build_approve.go b/drone/build/build_approve.go
index 0b87568..eac1987 100644
--- a/drone/build/build_approve.go
+++ b/drone/build/build_approve.go
@@ -10,8 +10,8 @@ import (
var buildApproveCmd = cli.Command{
Name: "approve",
- Usage: "approve a build",
- ArgsUsage: " ",
+ Usage: "approve a build stage",
+ ArgsUsage: " ",
Action: buildApprove,
}
@@ -25,13 +25,17 @@ func buildApprove(c *cli.Context) (err error) {
if err != nil {
return err
}
+ stage, err := strconv.Atoi(c.Args().Get(2))
+ if err != nil {
+ return err
+ }
client, err := internal.NewClient(c)
if err != nil {
return err
}
- _, err = client.BuildApprove(owner, name, number)
+ err = client.Approve(owner, name, number, stage)
if err != nil {
return err
}
diff --git a/drone/build/build_create.go b/drone/build/build_create.go
new file mode 100644
index 0000000..6066e31
--- /dev/null
+++ b/drone/build/build_create.go
@@ -0,0 +1,56 @@
+package build
+
+import (
+ "os"
+ "text/template"
+
+ "github.com/drone/drone-cli/drone/internal"
+ "github.com/drone/funcmap"
+ "github.com/urfave/cli"
+)
+
+var buildCreateCmd = cli.Command{
+ Name: "create",
+ Usage: "create a build",
+ ArgsUsage: "",
+ Action: buildCreate,
+ Flags: []cli.Flag{
+ cli.StringFlag{
+ Name: "commit",
+ Usage: "source commit",
+ },
+ cli.StringFlag{
+ Name: "branch",
+ Usage: "source branch",
+ },
+ cli.StringFlag{
+ Name: "format",
+ Usage: "format output",
+ Value: tmplBuildInfo,
+ },
+ },
+}
+
+func buildCreate(c *cli.Context) (err error) {
+ repo := c.Args().First()
+ owner, name, err := internal.ParseRepo(repo)
+ if err != nil {
+ return err
+ }
+
+ client, err := internal.NewClient(c)
+ if err != nil {
+ return err
+ }
+
+ build, err := client.BuildCreate(owner, name, c.String("commit"), c.String("branch"))
+ if err != nil {
+ return err
+ }
+
+ tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format"))
+ if err != nil {
+ return err
+ }
+ return tmpl.Execute(os.Stdout, build)
+}
diff --git a/drone/build/build_decline.go b/drone/build/build_decline.go
index a82db6e..38b389d 100644
--- a/drone/build/build_decline.go
+++ b/drone/build/build_decline.go
@@ -10,8 +10,8 @@ import (
var buildDeclineCmd = cli.Command{
Name: "decline",
- Usage: "decline a build",
- ArgsUsage: " ",
+ Usage: "decline a build stage",
+ ArgsUsage: " ",
Action: buildDecline,
}
@@ -25,13 +25,17 @@ func buildDecline(c *cli.Context) (err error) {
if err != nil {
return err
}
+ stage, err := strconv.Atoi(c.Args().Get(2))
+ if err != nil {
+ return err
+ }
client, err := internal.NewClient(c)
if err != nil {
return err
}
- _, err = client.BuildDecline(owner, name, number)
+ err = client.Decline(owner, name, number, stage)
if err != nil {
return err
}
diff --git a/drone/build/build_info.go b/drone/build/build_info.go
index f21c370..0f76933 100644
--- a/drone/build/build_info.go
+++ b/drone/build/build_info.go
@@ -6,6 +6,7 @@ import (
"text/template"
"github.com/drone/drone-cli/drone/internal"
+ "github.com/drone/funcmap"
"github.com/urfave/cli"
)
@@ -43,7 +44,7 @@ func buildInfo(c *cli.Context) error {
if err != nil {
return err
}
- number = build.Number
+ number = int(build.Number)
} else {
number, err = strconv.Atoi(buildArg)
if err != nil {
@@ -56,7 +57,7 @@ func buildInfo(c *cli.Context) error {
return err
}
- tmpl, err := template.New("_").Parse(c.String("format"))
+ tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format"))
if err != nil {
return err
}
@@ -67,9 +68,9 @@ func buildInfo(c *cli.Context) error {
var tmplBuildInfo = `Number: {{ .Number }}
Status: {{ .Status }}
Event: {{ .Event }}
-Commit: {{ .Commit }}
-Branch: {{ .Branch }}
+Commit: {{ .After }}
+Branch: {{ .Target }}
Ref: {{ .Ref }}
+Author: {{ .Author }} {{ if .AuthorEmail }}<{{.AuthorEmail}}>{{ end }}
Message: {{ .Message }}
-Author: {{ .Author }}
`
diff --git a/drone/build/build_kill.go b/drone/build/build_kill.go
deleted file mode 100644
index 68b9162..0000000
--- a/drone/build/build_kill.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package build
-
-import (
- "fmt"
- "strconv"
-
- "github.com/drone/drone-cli/drone/internal"
- "github.com/urfave/cli"
-)
-
-var buildKillCmd = cli.Command{
- Name: "kill",
- Usage: "force kill a build",
- ArgsUsage: " ",
- Action: buildKill,
- Hidden: true,
-}
-
-func buildKill(c *cli.Context) (err error) {
- repo := c.Args().First()
- owner, name, err := internal.ParseRepo(repo)
- if err != nil {
- return err
- }
- number, err := strconv.Atoi(c.Args().Get(1))
- if err != nil {
- return err
- }
-
- client, err := internal.NewClient(c)
- if err != nil {
- return err
- }
-
- err = client.BuildKill(owner, name, number)
- if err != nil {
- return err
- }
-
- fmt.Printf("Force killing build %s/%s#%d\n", owner, name, number)
- return nil
-}
diff --git a/drone/build/build_last.go b/drone/build/build_last.go
index 6d9b3f5..c380dff 100644
--- a/drone/build/build_last.go
+++ b/drone/build/build_last.go
@@ -5,6 +5,7 @@ import (
"text/template"
"github.com/drone/drone-cli/drone/internal"
+ "github.com/drone/funcmap"
"github.com/urfave/cli"
)
@@ -44,7 +45,7 @@ func buildLast(c *cli.Context) error {
return err
}
- tmpl, err := template.New("_").Parse(c.String("format"))
+ tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format"))
if err != nil {
return err
}
diff --git a/drone/build/build_list.go b/drone/build/build_list.go
index 77052bb..48ed5d1 100644
--- a/drone/build/build_list.go
+++ b/drone/build/build_list.go
@@ -5,6 +5,8 @@ import (
"text/template"
"github.com/drone/drone-cli/drone/internal"
+ "github.com/drone/drone-go/drone"
+ "github.com/drone/funcmap"
"github.com/urfave/cli"
)
@@ -36,6 +38,11 @@ var buildListCmd = cli.Command{
Usage: "limit the list size",
Value: 25,
},
+ cli.IntFlag{
+ Name: "page",
+ Usage: "page number",
+ Value: 1,
+ },
},
}
@@ -51,12 +58,12 @@ func buildList(c *cli.Context) error {
return err
}
- builds, err := client.BuildList(owner, name)
+ builds, err := client.BuildList(owner, name, drone.ListOptions{Page: c.Int("page")})
if err != nil {
return err
}
- tmpl, err := template.New("_").Parse(c.String("format") + "\n")
+ tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format") + "\n")
if err != nil {
return err
}
@@ -71,7 +78,7 @@ func buildList(c *cli.Context) error {
if count >= limit {
break
}
- if branch != "" && build.Branch != branch {
+ if branch != "" && build.Target != branch {
continue
}
if event != "" && build.Event != event {
@@ -90,9 +97,9 @@ func buildList(c *cli.Context) error {
var tmplBuildList = "\x1b[33mBuild #{{ .Number }} \x1b[0m" + `
Status: {{ .Status }}
Event: {{ .Event }}
-Commit: {{ .Commit }}
-Branch: {{ .Branch }}
+Commit: {{ .After }}
+Branch: {{ .Target }}
Ref: {{ .Ref }}
-Author: {{ .Author }} {{ if .Email }}<{{.Email}}>{{ end }}
+Author: {{ .Author }} {{ if .AuthorEmail }}<{{.AuthorEmail}}>{{ end }}
Message: {{ .Message }}
`
diff --git a/drone/build/build_logs.go b/drone/build/build_logs.go
deleted file mode 100644
index c07ee14..0000000
--- a/drone/build/build_logs.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package build
-
-import (
- "fmt"
-
- "github.com/urfave/cli"
-)
-
-var buildLogsCmd = cli.Command{
- Name: "logs",
- Usage: "show build logs",
- ArgsUsage: " [build] [job]",
- Action: buildLogs,
-}
-
-func buildLogs(c *cli.Context) error {
- return fmt.Errorf("Command temporarily disabled. See https://github.com/drone/drone/issues/2005")
-}
diff --git a/drone/build/build_promote.go b/drone/build/build_promote.go
new file mode 100644
index 0000000..51b187f
--- /dev/null
+++ b/drone/build/build_promote.go
@@ -0,0 +1,59 @@
+package build
+
+import (
+ "os"
+ "strconv"
+ "text/template"
+
+ "github.com/drone/drone-cli/drone/internal"
+ "github.com/drone/funcmap"
+ "github.com/urfave/cli"
+)
+
+var buildPromoteCmd = cli.Command{
+ Name: "promote",
+ Usage: "promote a build",
+ ArgsUsage: " ",
+ Action: buildPromote,
+ Flags: []cli.Flag{
+ cli.StringSliceFlag{
+ Name: "param, p",
+ Usage: "custom parameters to be injected into the job environment. Format: KEY=value",
+ },
+ cli.StringFlag{
+ Name: "format",
+ Usage: "format output",
+ Value: tmplBuildInfo,
+ },
+ },
+}
+
+func buildPromote(c *cli.Context) (err error) {
+ repo := c.Args().First()
+ owner, name, err := internal.ParseRepo(repo)
+ if err != nil {
+ return err
+ }
+ number, err := strconv.Atoi(c.Args().Get(1))
+ if err != nil {
+ return err
+ }
+ target := c.Args().Get(2)
+ params := internal.ParseKeyPair(c.StringSlice("param"))
+
+ client, err := internal.NewClient(c)
+ if err != nil {
+ return err
+ }
+
+ build, err := client.Promote(owner, name, number, target, params)
+ if err != nil {
+ return err
+ }
+
+ tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format"))
+ if err != nil {
+ return err
+ }
+ return tmpl.Execute(os.Stdout, build)
+}
diff --git a/drone/build/build_ps.go b/drone/build/build_ps.go
deleted file mode 100644
index ba18dfb..0000000
--- a/drone/build/build_ps.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package build
-
-import (
- "os"
- "strconv"
- "text/template"
-
- "github.com/drone/drone-cli/drone/internal"
- "github.com/urfave/cli"
-)
-
-var buildPsCmd = cli.Command{
- Name: "ps",
- Usage: "show build steps",
- ArgsUsage: " [build]",
- Action: buildPs,
- Flags: []cli.Flag{
- cli.StringFlag{
- Name: "format",
- Usage: "format output",
- Value: tmplBuildPs,
- },
- },
-}
-
-func buildPs(c *cli.Context) error {
- repo := c.Args().First()
-
- owner, name, err := internal.ParseRepo(repo)
- if err != nil {
- return err
- }
-
- client, err := internal.NewClient(c)
- if err != nil {
- return err
- }
-
- buildArg := c.Args().Get(1)
- var number int
-
- if buildArg == "last" || len(buildArg) == 0 {
- // Fetch the build number from the last build
- build, err := client.BuildLast(owner, name, "")
- if err != nil {
- return err
- }
-
- number = build.Number
- } else {
- number, err = strconv.Atoi(buildArg)
- if err != nil {
- return err
- }
- }
-
- build, err := client.Build(owner, name, number)
- if err != nil {
- return err
- }
-
- tmpl, err := template.New("_").Parse(c.String("format") + "\n")
- if err != nil {
- return err
- }
-
- for _, proc := range build.Procs {
- for _, child := range proc.Children {
- if err := tmpl.Execute(os.Stdout, child); err != nil {
- return err
- }
- }
- }
-
- return nil
-}
-
-// template for build ps information
-var tmplBuildPs = "\x1b[33mProc #{{ .PID }} \x1b[0m" + `
-Step: {{ .Name }}
-State: {{ .State }}
-`
diff --git a/drone/build/build_queue.go b/drone/build/build_queue.go
index 57e2540..0b3217e 100644
--- a/drone/build/build_queue.go
+++ b/drone/build/build_queue.go
@@ -1,18 +1,18 @@
package build
import (
- "fmt"
"os"
"text/template"
"github.com/drone/drone-cli/drone/internal"
+ "github.com/drone/funcmap"
"github.com/urfave/cli"
)
var buildQueueCmd = cli.Command{
Name: "queue",
Usage: "show build queue",
- ArgsUsage: " ",
+ ArgsUsage: "",
Action: buildQueue,
Flags: []cli.Flag{
cli.StringFlag{
@@ -20,44 +20,74 @@ var buildQueueCmd = cli.Command{
Usage: "format output",
Value: tmplBuildQueue,
},
+ cli.StringFlag{
+ Name: "repo",
+ Usage: "repo filter",
+ },
+ cli.StringFlag{
+ Name: "branch",
+ Usage: "branch filter",
+ },
+ cli.StringFlag{
+ Name: "event",
+ Usage: "event filter",
+ },
+ cli.StringFlag{
+ Name: "status",
+ Usage: "status filter",
+ },
},
}
func buildQueue(c *cli.Context) error {
-
client, err := internal.NewClient(c)
if err != nil {
return err
}
- builds, err := client.BuildQueue()
+ repos, err := client.Incomplete()
if err != nil {
return err
}
- if len(builds) == 0 {
- fmt.Println("there are no pending or running builds")
- return nil
- }
-
- tmpl, err := template.New("_").Parse(c.String("format") + "\n")
+ tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format") + "\n")
if err != nil {
return err
}
- for _, build := range builds {
- tmpl.Execute(os.Stdout, build)
+ slug := c.String("repo")
+ branch := c.String("branch")
+ event := c.String("event")
+ status := c.String("status")
+
+ for _, repo := range repos {
+ if slug != "" && repo.Slug != slug {
+ continue
+ }
+ if branch != "" && repo.Build.Target != branch {
+ continue
+ }
+ if event != "" && repo.Build.Event != event {
+ continue
+ }
+ if status != "" && repo.Build.Status != status {
+ continue
+ }
+ tmpl.Execute(os.Stdout, repo)
}
return nil
}
-// template for build list information
-var tmplBuildQueue = "\x1b[33m{{ .FullName }} #{{ .Number }} \x1b[0m" + `
-Status: {{ .Status }}
-Event: {{ .Event }}
-Commit: {{ .Commit }}
-Branch: {{ .Branch }}
-Ref: {{ .Ref }}
-Author: {{ .Author }} {{ if .Email }}<{{.Email}}>{{ end }}
-Message: {{ .Message }}
+// template for build queue information
+var tmplBuildQueue = "\x1b[33m{{ .Slug }}#{{ .Build.Number }} \x1b[0m" + `
+Name: {{ .Slug }}
+Build: {{ .Build.Number }}
+Status: {{ .Build.Status }}
+Event: {{ .Build.Event }}
+Branch: {{ .Build.Target }}
+Ref: {{ .Build.Ref }}
+Author: {{ .Build.Author }}{{ if .Build.AuthorEmail }} <{{ .Build.AuthorEmail }}>{{ end }}
+Created: {{ .Build.Created | time }}
+Started: {{ .Build.Started | time }}
+Updated: {{ .Build.Updated | time }}
`
diff --git a/drone/build/build_rollback.go b/drone/build/build_rollback.go
new file mode 100644
index 0000000..22f999e
--- /dev/null
+++ b/drone/build/build_rollback.go
@@ -0,0 +1,47 @@
+package build
+
+import (
+ "strconv"
+
+ "github.com/drone/drone-cli/drone/internal"
+ "github.com/urfave/cli"
+)
+
+var buildRollbackCmd = cli.Command{
+ Name: "rollback",
+ Usage: "rollback a build",
+ ArgsUsage: " ",
+ Action: buildRollback,
+ Flags: []cli.Flag{
+ cli.StringSliceFlag{
+ Name: "param, p",
+ Usage: "custom parameters to be injected into the job environment. Format: KEY=value",
+ },
+ },
+}
+
+func buildRollback(c *cli.Context) (err error) {
+ repo := c.Args().First()
+ owner, name, err := internal.ParseRepo(repo)
+ if err != nil {
+ return err
+ }
+ number, err := strconv.Atoi(c.Args().Get(1))
+ if err != nil {
+ return err
+ }
+ target := c.Args().Get(2)
+ params := internal.ParseKeyPair(c.StringSlice("param"))
+
+ client, err := internal.NewClient(c)
+ if err != nil {
+ return err
+ }
+
+ _, err = client.Rollback(owner, name, number, target, params)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
diff --git a/drone/build/build_start.go b/drone/build/build_start.go
index d886eb3..9d25614 100644
--- a/drone/build/build_start.go
+++ b/drone/build/build_start.go
@@ -2,16 +2,18 @@ package build
import (
"errors"
- "fmt"
+ "os"
"strconv"
+ "text/template"
"github.com/drone/drone-cli/drone/internal"
+ "github.com/drone/funcmap"
"github.com/urfave/cli"
)
var buildStartCmd = cli.Command{
- Name: "start",
- Usage: "start a build",
+ Name: "restart",
+ Usage: "restart a build",
ArgsUsage: " [build]",
Action: buildStart,
Flags: []cli.Flag{
@@ -19,6 +21,11 @@ var buildStartCmd = cli.Command{
Name: "param, p",
Usage: "custom parameters to be injected into the job environment. Format: KEY=value",
},
+ cli.StringFlag{
+ Name: "format",
+ Usage: "format output",
+ Value: tmplBuildInfo,
+ },
},
}
@@ -42,7 +49,7 @@ func buildStart(c *cli.Context) (err error) {
if err != nil {
return err
}
- number = build.Number
+ number = int(build.Number)
} else {
if len(buildArg) == 0 {
return errors.New("missing job number")
@@ -55,11 +62,14 @@ func buildStart(c *cli.Context) (err error) {
params := internal.ParseKeyPair(c.StringSlice("param"))
- build, err := client.BuildStart(owner, name, number, params)
+ build, err := client.BuildRestart(owner, name, number, params)
if err != nil {
return err
}
- fmt.Printf("Starting build %s/%s#%d\n", owner, name, build.Number)
- return nil
+ tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format"))
+ if err != nil {
+ return err
+ }
+ return tmpl.Execute(os.Stdout, build)
}
diff --git a/drone/build/build_stop.go b/drone/build/build_stop.go
index c996174..aa71806 100644
--- a/drone/build/build_stop.go
+++ b/drone/build/build_stop.go
@@ -11,7 +11,7 @@ import (
var buildStopCmd = cli.Command{
Name: "stop",
Usage: "stop a build",
- ArgsUsage: " [build] [job]",
+ ArgsUsage: " [build]",
Action: buildStop,
}
@@ -25,21 +25,17 @@ func buildStop(c *cli.Context) (err error) {
if err != nil {
return err
}
- job, _ := strconv.Atoi(c.Args().Get(2))
- if job == 0 {
- job = 1
- }
client, err := internal.NewClient(c)
if err != nil {
return err
}
- err = client.BuildStop(owner, name, number, job)
+ err = client.BuildCancel(owner, name, number)
if err != nil {
return err
}
- fmt.Printf("Stopping build %s/%s#%d.%d\n", owner, name, number, job)
+ fmt.Printf("Stopping build %s/%s#%d\n", owner, name, number)
return nil
}
diff --git a/drone/convert/convert.go b/drone/convert/convert.go
new file mode 100644
index 0000000..d9afa7b
--- /dev/null
+++ b/drone/convert/convert.go
@@ -0,0 +1,49 @@
+package convert
+
+import (
+ "bytes"
+ "io"
+ "io/ioutil"
+ "os"
+
+ "github.com/drone/drone-yaml/yaml/converter"
+ "github.com/urfave/cli"
+)
+
+// Command exports the convert command.
+var Command = cli.Command{
+ Name: "convert",
+ Usage: "convert legacy format",
+ ArgsUsage: "