From 262c0d66c0ff52a1ec916317409882e672f2eae1 Mon Sep 17 00:00:00 2001 From: Grzegorz Graczyk Date: Mon, 5 Jan 2015 11:26:52 +0100 Subject: [PATCH 01/11] check if tag wasn't used for image building --- plugin/publish/docker.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/publish/docker.go b/plugin/publish/docker.go index 387d44395..40873d83d 100644 --- a/plugin/publish/docker.go +++ b/plugin/publish/docker.go @@ -99,7 +99,10 @@ func (d *Docker) Write(f *buildfile.Buildfile) { // Tag and push all tags for _, tag := range d.Tags { - f.WriteCmd(fmt.Sprintf("docker tag %s:%s %s:%s", d.ImageName, buildImageTag, d.ImageName, tag)) + if tag != buildImageTag { + f.WriteCmd(fmt.Sprintf("docker tag %s:%s %s:%s", d.ImageName, buildImageTag, d.ImageName, tag)) + } + f.WriteCmd(fmt.Sprintf("docker push %s:%s", d.ImageName, tag)) } From a6278f35fb7b326f80b8b789fe43571ff280eed5 Mon Sep 17 00:00:00 2001 From: ap4y Date: Tue, 6 Jan 2015 00:24:53 +1300 Subject: [PATCH 02/11] Enforce word breaks in terminal output --- server/app/styles/drone.less | 1 + 1 file changed, 1 insertion(+) diff --git a/server/app/styles/drone.less b/server/app/styles/drone.less index 9c0703921..727688f19 100644 --- a/server/app/styles/drone.less +++ b/server/app/styles/drone.less @@ -1338,6 +1338,7 @@ nav { font-family:@mono; font-size:13px; white-space: pre-wrap; + word-break: break-all; overflow: hidden; line-height:18px; } From 49a591b4511f1b7c78bb015931232348a74e3220 Mon Sep 17 00:00:00 2001 From: Nathan Youngman Date: Fri, 9 Jan 2015 23:22:03 -0700 Subject: [PATCH 03/11] README: flat style SVG badges For consistency. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f0406d00c..125158714 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![Build Status](http://test.drone.io/api/badge/github.com/drone/drone/status.svg)](http://test.drone.io/github.com/drone/drone) -[![GoDoc](https://godoc.org/github.com/drone/drone?status.png)](https://godoc.org/github.com/drone/drone) +[![Build Status](http://test.drone.io/api/badge/github.com/drone/drone/status.svg?style=flat)](http://test.drone.io/github.com/drone/drone) +[![GoDoc](https://godoc.org/github.com/drone/drone?status.svg)](https://godoc.org/github.com/drone/drone) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/drone/drone?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Documentation From cb6ade69196409f876d1ab97e68dd02ec37419f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 11 Jan 2015 02:13:12 +0100 Subject: [PATCH 04/11] Missing URL for bitbucket Repo --- plugin/remote/bitbucket/bitbucket.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/remote/bitbucket/bitbucket.go b/plugin/remote/bitbucket/bitbucket.go index d035889f0..410d1bb41 100644 --- a/plugin/remote/bitbucket/bitbucket.go +++ b/plugin/remote/bitbucket/bitbucket.go @@ -155,6 +155,7 @@ func (r *Bitbucket) GetRepos(user *model.User) ([]*model.Repo, error) { // these are the urls required to clone the repository // TODO use the bitbucketurl.Host and bitbucketurl.Scheme instead of hardcoding // so that we can support Stash. + var html = fmt.Sprintf("https://bitbucket.org/%s/%s", item.Owner, item.Name) var clone = fmt.Sprintf("https://bitbucket.org/%s/%s.git", item.Owner, item.Name) var ssh = fmt.Sprintf("git@bitbucket.org:%s/%s.git", item.Owner, item.Name) @@ -165,6 +166,7 @@ func (r *Bitbucket) GetRepos(user *model.User) ([]*model.Repo, error) { Owner: item.Owner, Name: item.Name, Private: item.Private, + URL: html, CloneURL: clone, GitURL: clone, SSHURL: ssh, From 3cb015a287bdd04ffedb1ea40a38bf73df091bd5 Mon Sep 17 00:00:00 2001 From: Matt Bostock Date: Sun, 11 Jan 2015 17:47:56 +0000 Subject: [PATCH 05/11] Remove explicit `go get` for goblin package The goblin package will be pulled in by the `go get` invocation on the following line as it's references by imports, so there's no need to list it separately. --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index e6efdd2a0..53df09c67 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,6 @@ all: build deps: # which npm && npm -g install uglify-js less autoprefixer go get github.com/GeertJohan/go.rice/rice - go get github.com/franela/goblin go get -t -v ./... test: From b027bd839214bc1e4f6f2cb9b211467527a656a2 Mon Sep 17 00:00:00 2001 From: Matt Bostock Date: Sun, 11 Jan 2015 18:35:30 +0000 Subject: [PATCH 06/11] Run gofmt and add test to prevent regressions Run `go fmt ./...` [1] and add a test to the `test` make target that checks if `go fmt` has been run. [1]: http://blog.golang.org/go-fmt-your-code --- Makefile | 1 + cli/restart.go | 2 +- plugin/deploy/deis/deis.go | 14 ++-- plugin/deploy/deis/deis_test.go | 10 +-- plugin/deploy/deployment.go | 4 +- plugin/deploy/heroku/heroku.go | 2 +- plugin/deploy/heroku/heroku_test.go | 4 +- shared/build/script/docker.go | 30 ++++----- shared/build/script/docker_test.go | 100 ++++++++++++++-------------- 9 files changed, 84 insertions(+), 83 deletions(-) diff --git a/Makefile b/Makefile index e6efdd2a0..9ad60a13e 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ deps: go get -t -v ./... test: + @test -z "$(shell find . -name '*.go' | xargs gofmt -l)" || (echo "Need to run 'go fmt ./...'"; exit 1) go vet ./... go test -cover -short ./... diff --git a/cli/restart.go b/cli/restart.go index 727af2545..cf6b51ecb 100644 --- a/cli/restart.go +++ b/cli/restart.go @@ -30,7 +30,7 @@ func restartCommandFunc(c *cli.Context, client *client.Client) error { case 2: branch = "master" sha = args[1] - case 3,4,5: + case 3, 4, 5: branch = args[1] sha = args[2] } diff --git a/plugin/deploy/deis/deis.go b/plugin/deploy/deis/deis.go index acc5a7439..b98721ec8 100644 --- a/plugin/deploy/deis/deis.go +++ b/plugin/deploy/deis/deis.go @@ -22,20 +22,20 @@ const ( // deisurl: deis.myurl.tdl:2222/ type Deis struct { - App string `yaml:"app,omitempty"` - Force bool `yaml:"force,omitempty"` - Deisurl string `yaml:"deisurl,omitempty"` - Condition *condition.Condition `yaml:"when,omitempty"` + App string `yaml:"app,omitempty"` + Force bool `yaml:"force,omitempty"` + Deisurl string `yaml:"deisurl,omitempty"` + Condition *condition.Condition `yaml:"when,omitempty"` } func (h *Deis) Write(f *buildfile.Buildfile) { f.WriteCmdSilent(CmdRevParse) f.WriteCmdSilent(CmdGlobalUser) f.WriteCmdSilent(CmdGlobalEmail) - + // git@deis.yourdomain.com:2222/drone.git - - f.WriteCmd(fmt.Sprintf("git remote add deis ssh://git@%s%s.git", h.Deisurl , h.App)) + + f.WriteCmd(fmt.Sprintf("git remote add deis ssh://git@%s%s.git", h.Deisurl, h.App)) switch h.Force { case true: diff --git a/plugin/deploy/deis/deis_test.go b/plugin/deploy/deis/deis_test.go index 42b053f4d..b9621aa9e 100644 --- a/plugin/deploy/deis/deis_test.go +++ b/plugin/deploy/deis/deis_test.go @@ -16,8 +16,8 @@ func Test_Deis(t *testing.T) { g.It("Should set git.config", func() { b := new(buildfile.Buildfile) h := Deis{ - App: "drone", - Deisurl: "deis.yourdomain.com:2222", + App: "drone", + Deisurl: "deis.yourdomain.com:2222", } h.Write(b) @@ -30,8 +30,8 @@ func Test_Deis(t *testing.T) { g.It("Should add remote", func() { b := new(buildfile.Buildfile) h := Deis{ - App: "drone", - Deisurl: "deis.yourdomain.com:2222/", + App: "drone", + Deisurl: "deis.yourdomain.com:2222/", } h.Write(b) @@ -54,7 +54,7 @@ func Test_Deis(t *testing.T) { b := new(buildfile.Buildfile) h := Deis{ Force: true, - App: "drone", + App: "drone", } h.Write(b) diff --git a/plugin/deploy/deployment.go b/plugin/deploy/deployment.go index 3e059ac1e..198c71a27 100644 --- a/plugin/deploy/deployment.go +++ b/plugin/deploy/deployment.go @@ -5,9 +5,9 @@ import ( "github.com/drone/drone/shared/build/buildfile" "github.com/drone/drone/shared/build/repo" + "github.com/drone/drone/plugin/deploy/deis" "github.com/drone/drone/plugin/deploy/git" "github.com/drone/drone/plugin/deploy/heroku" - "github.com/drone/drone/plugin/deploy/deis" "github.com/drone/drone/plugin/deploy/modulus" "github.com/drone/drone/plugin/deploy/nodejitsu" "github.com/drone/drone/plugin/deploy/tsuru" @@ -20,7 +20,7 @@ type Deploy struct { CloudFoundry *CloudFoundry `yaml:"cloudfoundry,omitempty"` Git *git.Git `yaml:"git,omitempty"` Heroku *heroku.Heroku `yaml:"heroku,omitempty"` - Deis *deis.Deis `yaml:"deis,omitempty"` + Deis *deis.Deis `yaml:"deis,omitempty"` Modulus *modulus.Modulus `yaml:"modulus,omitempty"` Nodejitsu *nodejitsu.Nodejitsu `yaml:"nodejitsu,omitempty"` SSH *SSH `yaml:"ssh,omitempty"` diff --git a/plugin/deploy/heroku/heroku.go b/plugin/deploy/heroku/heroku.go index 7a551fbb0..75135f640 100644 --- a/plugin/deploy/heroku/heroku.go +++ b/plugin/deploy/heroku/heroku.go @@ -17,7 +17,7 @@ const ( // Command to write the API token to ~/.netrc // use "_" since heroku git authentication ignores username - CmdLogin = "echo 'machine git.heroku.com login _ password %s' >> ~/.netrc" + CmdLogin = "echo 'machine git.heroku.com login _ password %s' >> ~/.netrc" ) type Heroku struct { diff --git a/plugin/deploy/heroku/heroku_test.go b/plugin/deploy/heroku/heroku_test.go index e5a8eeef9..71e3d160c 100644 --- a/plugin/deploy/heroku/heroku_test.go +++ b/plugin/deploy/heroku/heroku_test.go @@ -29,14 +29,14 @@ func Test_Heroku(t *testing.T) { g.It("Should write token", func() { b := new(buildfile.Buildfile) h := Heroku{ - App: "drone", + App: "drone", Token: "mock-token", } h.Write(b) out := b.String() g.Assert(strings.Contains(out, "\necho 'machine git.heroku.com login _ password mock-token' >> ~/.netrc\n")).Equal(true) - }) + }) g.It("Should add remote", func() { b := new(buildfile.Buildfile) diff --git a/shared/build/script/docker.go b/shared/build/script/docker.go index dfceeeba3..185c293e0 100644 --- a/shared/build/script/docker.go +++ b/shared/build/script/docker.go @@ -1,19 +1,19 @@ package script const ( - DefaultDockerNetworkMode = "bridge" + DefaultDockerNetworkMode = "bridge" ) // Docker stores the configuration details for // configuring docker container. type Docker struct { - // NetworkMode (also known as `--net` option) - // Could be set only if Docker is running in privileged mode - NetworkMode *string `yaml:"net,omitempty"` + // NetworkMode (also known as `--net` option) + // Could be set only if Docker is running in privileged mode + NetworkMode *string `yaml:"net,omitempty"` - // Hostname (also known as `--hostname` option) - // Could be set only if Docker is running in privileged mode - Hostname *string `yaml:"hostname,omitempty"` + // Hostname (also known as `--hostname` option) + // Could be set only if Docker is running in privileged mode + Hostname *string `yaml:"hostname,omitempty"` } // DockerNetworkMode returns DefaultNetworkMode @@ -21,10 +21,10 @@ type Docker struct { // DockerNetworkMode returns Docker.NetworkMode // when it is not empty. func DockerNetworkMode(d *Docker) string { - if d == nil || d.NetworkMode == nil { - return DefaultDockerNetworkMode - } - return *d.NetworkMode + if d == nil || d.NetworkMode == nil { + return DefaultDockerNetworkMode + } + return *d.NetworkMode } // DockerNetworkMode returns empty string @@ -32,8 +32,8 @@ func DockerNetworkMode(d *Docker) string { // DockerNetworkMode returns Docker.NetworkMode // when it is not empty. func DockerHostname(d *Docker) string { - if d == nil || d.Hostname == nil { - return "" - } - return *d.Hostname + if d == nil || d.Hostname == nil { + return "" + } + return *d.Hostname } diff --git a/shared/build/script/docker_test.go b/shared/build/script/docker_test.go index e089d9ea4..a145d3a3f 100644 --- a/shared/build/script/docker_test.go +++ b/shared/build/script/docker_test.go @@ -1,69 +1,69 @@ package script import ( - "testing" + "testing" ) func TestDockerNetworkMode(t *testing.T) { - var d *Docker - var expected string + var d *Docker + var expected string - expected = DefaultDockerNetworkMode - d = nil - if actual := DockerNetworkMode(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = DefaultDockerNetworkMode + d = nil + if actual := DockerNetworkMode(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = DefaultDockerNetworkMode - d = &Docker{} - if actual := DockerNetworkMode(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = DefaultDockerNetworkMode + d = &Docker{} + if actual := DockerNetworkMode(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = DefaultDockerNetworkMode - d = &Docker{NetworkMode: nil} - if actual := DockerNetworkMode(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = DefaultDockerNetworkMode + d = &Docker{NetworkMode: nil} + if actual := DockerNetworkMode(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = "bridge" - d = &Docker{NetworkMode: &expected} - if actual := DockerNetworkMode(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "bridge" + d = &Docker{NetworkMode: &expected} + if actual := DockerNetworkMode(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = "host" - d = &Docker{NetworkMode: &expected} - if actual := DockerNetworkMode(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "host" + d = &Docker{NetworkMode: &expected} + if actual := DockerNetworkMode(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } } func TestDockerHostname(t *testing.T) { - var d *Docker - var expected string + var d *Docker + var expected string - expected = "" - d = nil - if actual := DockerHostname(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "" + d = nil + if actual := DockerHostname(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = "" - d = &Docker{} - if actual := DockerHostname(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "" + d = &Docker{} + if actual := DockerHostname(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = "" - d = &Docker{Hostname: nil} - if actual := DockerHostname(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "" + d = &Docker{Hostname: nil} + if actual := DockerHostname(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = "host" - d = &Docker{Hostname: &expected} - if actual := DockerHostname(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "host" + d = &Docker{Hostname: &expected} + if actual := DockerHostname(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } } From 9f2849d5adf2aa47745e1b7b9f76f1fcca1ebdb3 Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Mon, 12 Jan 2015 02:16:48 +0000 Subject: [PATCH 07/11] Add Gogs to the TOML config file While updating an Ansible module I noticed that while Gogs is supported, it doesn't appear, commented out, in the TOML file. This commit adds it Signed-off-by: Dave Tucker --- README.md | 4 ++++ packaging/root/etc/drone/drone.toml | 3 +++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 125158714..fef19f00a 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,10 @@ secret="" url="" skip_verify=false +[gogs] +url="" +secret="" + [smtp] host="" port="" diff --git a/packaging/root/etc/drone/drone.toml b/packaging/root/etc/drone/drone.toml index 6332c7404..29dfbe42e 100644 --- a/packaging/root/etc/drone/drone.toml +++ b/packaging/root/etc/drone/drone.toml @@ -53,6 +53,9 @@ datasource="/var/lib/drone/drone.sqlite" # url="" # skip_verify=false +# [gogs] +# url="" +# secret="" ##################################################################### # SMTP configuration for Drone. This is required if you plan From ce5d4edca55d9885a83170b35a1241a6dfa98203 Mon Sep 17 00:00:00 2001 From: Kirill Zaitsev Date: Mon, 12 Jan 2015 16:50:59 +0300 Subject: [PATCH 08/11] Bintray plugin --- plugin/publish/bintray.go | 1 - plugin/publish/bintray/bintray.go | 50 +++++++++++++ plugin/publish/bintray/package.go | 116 ++++++++++++++++++++++++++++++ plugin/publish/publish.go | 21 ++++-- 4 files changed, 180 insertions(+), 8 deletions(-) delete mode 100644 plugin/publish/bintray.go create mode 100644 plugin/publish/bintray/bintray.go create mode 100644 plugin/publish/bintray/package.go diff --git a/plugin/publish/bintray.go b/plugin/publish/bintray.go deleted file mode 100644 index 30b1a5b2a..000000000 --- a/plugin/publish/bintray.go +++ /dev/null @@ -1 +0,0 @@ -package publish diff --git a/plugin/publish/bintray/bintray.go b/plugin/publish/bintray/bintray.go new file mode 100644 index 000000000..9a0383e2a --- /dev/null +++ b/plugin/publish/bintray/bintray.go @@ -0,0 +1,50 @@ +package bintray + +import ( + "github.com/drone/drone/plugin/condition" + "github.com/drone/drone/shared/build/buildfile" +) + +type Bintray struct { + Username string `yaml:"username"` + ApiKey string `yaml:"api_key"` + Packages []Package `yaml:"packages"` + + Condition *condition.Condition `yaml:"when,omitempty"` +} + +func (b *Bintray) Write(f *buildfile.Buildfile) { + var cmd string + + // Validate Username, ApiKey, Packages + if len(b.Username) == 0 || len(b.ApiKey) == 0 || len(b.Packages) == 0 { + f.WriteCmdSilent(`echo -e "Bintray Plugin: Missing argument(s)\n\n"`) + + if len(b.Username) == 0 { + f.WriteCmdSilent(`echo -e "\tusername not defined in yaml config"`) + } + + if len(b.ApiKey) == 0 { + f.WriteCmdSilent(`echo -e "\tapi_key not defined in yaml config"`) + } + + if len(b.Packages) == 0 { + f.WriteCmdSilent(`echo -e "\tpackages not defined in yaml config"`) + } + + f.WriteCmdSilent("exit 1") + + return + } + + for _, pkg := range b.Packages { + pkg.Write(b.Username, b.ApiKey, f) + } + + f.WriteCmd(cmd) + +} + +func (b *Bintray) GetCondition() *condition.Condition { + return b.Condition +} diff --git a/plugin/publish/bintray/package.go b/plugin/publish/bintray/package.go new file mode 100644 index 000000000..31f35e1d6 --- /dev/null +++ b/plugin/publish/bintray/package.go @@ -0,0 +1,116 @@ +package bintray + +import ( + "fmt" + "strings" + + "github.com/drone/drone/shared/build/buildfile" +) + +const bintray_endpoint = "https://api.bintray.com/content/%s/%s/%s/%s/%s" + +type Package struct { + File string `yaml:"file"` + Type string `yaml:"type"` + Owner string `yaml:"owner"` + Repository string `yaml:"repository"` + Package string `yaml:"package"` + Version string `yaml:"version"` + Target string `yaml:"target"` + Distr string `yaml:"distr,omitempty"` + Component string `yaml:"component,omitempty"` + Arch []string `yaml:"arch,omitempty"` + Publish bool `yaml:"publish,omitempty"` + Override bool `yaml:"override,omitempty"` +} + +func (p *Package) Write(username, api_key string, f *buildfile.Buildfile) { + if len(p.File) == 0 || len(p.Owner) == 0 || len(p.Repository) == 0 || len(p.Package) == 0 || len(p.Version) == 0 || len(p.Target) == 0 { + f.WriteCmdSilent(`echo -e "Bintray Plugin: Missing argument(s)\n\n"`) + + if len(p.Package) == 0 { + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\tpackage not defined in yaml config"`)) + return + } + + if len(p.File) == 0 { + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\tpackage %s: file not defined in yaml config"`, p.Package)) + } + + if len(p.Owner) == 0 { + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\tpackage %s: owner not defined in yaml config"`, p.Package)) + } + + if len(p.Repository) == 0 { + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\tpackage %s: repository not defined in yaml config"`, p.Package)) + } + + if len(p.Version) == 0 { + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\tpackage %s: version not defined in yaml config"`, p.Package)) + } + + if len(p.Target) == 0 { + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\tpackage %s: target not defined in yaml config"`, p.Package)) + } + + f.WriteCmdSilent("exit 1") + + return + } + + switch p.Type { + case "deb": + p.debUpload(username, api_key, f) + case "rpm": + p.upload(username, api_key, f) + case "maven": + p.upload(username, api_key, f) + default: + p.upload(username, api_key, f) + } +} + +func (p *Package) debUpload(username, api_key string, f *buildfile.Buildfile) { + if len(p.Distr) == 0 || len(p.Component) == 0 || len(p.Arch) == 0 { + f.WriteCmdSilent(`echo -e "Bintray Plugin: Missing argument(s)\n\n"`) + + if len(p.Distr) == 0 { + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\tpackage %s: distr not defined in yaml config"`, p.Package)) + } + + if len(p.Component) == 0 { + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\tpackage %s: component not defined in yaml config"`, p.Package)) + } + + if len(p.Arch) == 0 { + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\tpackage %s: arch not defined in yaml config"`, p.Package)) + } + + f.WriteCmdSilent("exit 1") + + return + } + + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\nUpload %s to %s/%s/%s"`, p.File, p.Owner, p.Repository, p.Package)) + f.WriteCmdSilent(fmt.Sprintf("curl -s -T %s -u%s:%s %s\\;deb_distribution\\=%s\\;deb_component\\=%s\\;deb_architecture=\\%s\\;publish\\=%d\\;override\\=%d", + p.File, username, api_key, p.getEndpoint(), p.Distr, p.Component, strings.Join(p.Arch, ","), boolToInt(p.Publish), boolToInt(p.Override))) + +} + +func (p *Package) upload(username, api_key string, f *buildfile.Buildfile) { + f.WriteCmdSilent(fmt.Sprintf(`echo -e "\nUpload %s to %s/%s/%s"`, p.File, p.Owner, p.Repository, p.Package)) + f.WriteCmdSilent(fmt.Sprintf("curl -s -T %s -u%s:%s %s\\;publish\\=%d\\;override\\=%d", + p.File, username, api_key, p.getEndpoint(), boolToInt(p.Publish), boolToInt(p.Override))) +} + +func (p *Package) getEndpoint() string { + return fmt.Sprintf(bintray_endpoint, p.Owner, p.Repository, p.Package, p.Version, p.Target) +} + +func boolToInt(val bool) int { + if val { + return 1 + } else { + return 0 + } +} diff --git a/plugin/publish/publish.go b/plugin/publish/publish.go index 4ce6d4b1f..8286097dc 100644 --- a/plugin/publish/publish.go +++ b/plugin/publish/publish.go @@ -2,6 +2,7 @@ package publish import ( "github.com/drone/drone/plugin/condition" + "github.com/drone/drone/plugin/publish/bintray" "github.com/drone/drone/plugin/publish/npm" "github.com/drone/drone/shared/build/buildfile" "github.com/drone/drone/shared/build/repo" @@ -11,13 +12,14 @@ import ( // for publishing build artifacts when // a Build has succeeded type Publish struct { - S3 *S3 `yaml:"s3,omitempty"` - Swift *Swift `yaml:"swift,omitempty"` - PyPI *PyPI `yaml:"pypi,omitempty"` - NPM *npm.NPM `yaml:"npm,omitempty"` - Docker *Docker `yaml:"docker,omitempty"` - Github *Github `yaml:"github,omitempty"` - Dropbox *Dropbox `yaml:"dropbox,omitempty"` + S3 *S3 `yaml:"s3,omitempty"` + Swift *Swift `yaml:"swift,omitempty"` + PyPI *PyPI `yaml:"pypi,omitempty"` + NPM *npm.NPM `yaml:"npm,omitempty"` + Docker *Docker `yaml:"docker,omitempty"` + Github *Github `yaml:"github,omitempty"` + Dropbox *Dropbox `yaml:"dropbox,omitempty"` + Bintray *bintray.Bintray `yaml:"bintray,omitempty"` } func (p *Publish) Write(f *buildfile.Buildfile, r *repo.Repo) { @@ -55,6 +57,11 @@ func (p *Publish) Write(f *buildfile.Buildfile, r *repo.Repo) { if p.Dropbox != nil && match(p.Dropbox.GetCondition(), r) { p.Dropbox.Write(f) } + + // Bintray + if p.Bintray != nil && match(p.Bintray.GetCondition(), r) { + p.Bintray.Write(f) + } } func match(c *condition.Condition, r *repo.Repo) bool { From 6534bc79b4f07863f4426ec82f658264a8b59baa Mon Sep 17 00:00:00 2001 From: Matt Bostock Date: Mon, 12 Jan 2015 14:02:48 +0000 Subject: [PATCH 09/11] Clarify 'sync running' message Improve the grammar of the 'sync already runned' message to 'sync already in progress', which should clarify what is happening when this message is displayed. --- server/app/views/home.html | 2 +- server/app/views/repo_list.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/app/views/home.html b/server/app/views/home.html index 68c452656..83fb6dd0a 100644 --- a/server/app/views/home.html +++ b/server/app/views/home.html @@ -1,5 +1,5 @@
- sync already runned + sync already in progress bad response
diff --git a/server/app/views/repo_list.html b/server/app/views/repo_list.html index 4fda16c8f..83df9a992 100644 --- a/server/app/views/repo_list.html +++ b/server/app/views/repo_list.html @@ -1,5 +1,5 @@
- sync already runned + sync already in progress bad response
From fc014768f1160f296d052c439a9fe9f76941b343 Mon Sep 17 00:00:00 2001 From: Andy Gardner Date: Mon, 12 Jan 2015 16:09:55 +0200 Subject: [PATCH 10/11] Fixing an issue with branch grouping due to substring matching --- server/app/views/repo.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/app/views/repo.html b/server/app/views/repo.html index a0d80201e..bb121dc62 100644 --- a/server/app/views/repo.html +++ b/server/app/views/repo.html @@ -38,7 +38,7 @@

{{group.branch}}

- +

{{ commit.message }}

{{ commit.author }}
{{ commit.finished_at | fromNow }}
From ef3fba75a908e5f7866e2f09c58fabbdc1062ca5 Mon Sep 17 00:00:00 2001 From: Kirill Zaitsev Date: Mon, 12 Jan 2015 16:51:54 +0300 Subject: [PATCH 11/11] Version from file --- Makefile | 12 ++++++++---- VERSION | 1 + cli/main.go | 2 +- server/main.go | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 VERSION diff --git a/Makefile b/Makefile index e6efdd2a0..2e9e12e01 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ SHA := $(shell git rev-parse --short HEAD) +VERSION := $(shell cat VERSION) +ITTERATION := $(shell date +%s) all: build @@ -23,8 +25,8 @@ test_postgres: build: mkdir -p packaging/output mkdir -p packaging/root/usr/local/bin - go build -o packaging/root/usr/local/bin/drone -ldflags "-X main.revision $(SHA)" github.com/drone/drone/cli - go build -o packaging/root/usr/local/bin/droned -ldflags "-X main.revision $(SHA)" github.com/drone/drone/server + go build -o packaging/root/usr/local/bin/drone -ldflags "-X main.revision $(SHA) -X main.version $(VERSION)" github.com/drone/drone/cli + go build -o packaging/root/usr/local/bin/droned -ldflags "-X main.revision $(SHA) -X main.version $(VERSION)" github.com/drone/drone/server install: install -t /usr/local/bin packaging/root/usr/local/bin/drone @@ -52,9 +54,10 @@ embed: # creates a debian package for drone to install # `sudo dpkg -i drone.deb` deb: - fpm -s dir -t deb -n drone -v 0.3 -p packaging/output/drone.deb \ + fpm -s dir -t deb -n drone -v $(VERSION) -p packaging/output/drone.deb \ --deb-priority optional --category admin \ --force \ + --iteration $(ITTERATION) \ --deb-compression bzip2 \ --after-install packaging/scripts/postinst.deb \ --before-remove packaging/scripts/prerm.deb \ @@ -68,9 +71,10 @@ deb: packaging/root/=/ rpm: - fpm -s dir -t rpm -n drone -v 0.3 -p packaging/output/drone.rpm \ + fpm -s dir -t rpm -n drone -v $(VERSION) -p packaging/output/drone.rpm \ --rpm-compression bzip2 --rpm-os linux \ --force \ + --iteration $(ITTERATION) \ --after-install packaging/scripts/postinst.rpm \ --before-remove packaging/scripts/prerm.rpm \ --after-remove packaging/scripts/postrm.rpm \ diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..0852d432c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.3.0-alpha \ No newline at end of file diff --git a/cli/main.go b/cli/main.go index d051834c8..0a2e3b908 100644 --- a/cli/main.go +++ b/cli/main.go @@ -7,7 +7,7 @@ import ( var ( // commit sha for the current build. - version string = "0.3-dev" + version string revision string ) diff --git a/server/main.go b/server/main.go index 9fd47cd2b..ae41dc7b3 100644 --- a/server/main.go +++ b/server/main.go @@ -41,7 +41,7 @@ const ( var ( // commit sha for the current build, set by // the compile process. - version string = "0.3-dev" + version string revision string )