From d66becd12c794cb0b26409f5852c9fb7d25c6ebc Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 15 May 2015 14:55:26 -0700 Subject: [PATCH] fixed some minor bugs in build --- .gitignore | 6 +++++- Makefile | 13 ++++++++++++- cmd/drone-build/client.go | 2 +- cmd/drone-build/run.go | 11 ++++++----- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 9fc5afbb..691f0a16 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,8 @@ bindata.go drone drone-build -drone-bot \ No newline at end of file +drone-bot + +bin/drone +bin/drone-build +bin/drone-bot diff --git a/Makefile b/Makefile index 2c138379..690b15ba 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +.PHONY: dist + SHA := $(shell git rev-parse --short HEAD) VERSION := 0.4.0-alpha @@ -11,7 +13,7 @@ test: go test -cover -short ./... build: - go build -ldflags "-X main.revision $(SHA) -X main.version $(VERSION).$(SHA)" + go build -o bin/drone -ldflags "-X main.revision $(SHA) -X main.version $(VERSION).$(SHA)" clean: find . -name "*.out" -delete @@ -33,3 +35,12 @@ bindata_debug: bindata: $$GOPATH/bin/go-bindata server/static/... + +# creates a debian package for drone +# to install `sudo dpkg -i drone.deb` +dist: + mkdir -p dist/drone/usr/local/bin + mkdir -p dist/drone/var/lib/drone + mkdir -p dist/drone/var/cache/drone + cp bin/drone dist/drone/usr/local/bin + -dpkg-deb --build dist/drone diff --git a/cmd/drone-build/client.go b/cmd/drone-build/client.go index 0fde9617..f25ac3fa 100644 --- a/cmd/drone-build/client.go +++ b/cmd/drone-build/client.go @@ -102,7 +102,7 @@ func run(client dockerclient.Client, conf *dockerclient.ContainerConfig, pull bo id, err = client.CreateContainer(conf, "") // make sure the container is removed in // the event of a creation error. - if len(id) != 0 { + if err != nil && len(id) != 0 { client.RemoveContainer(id, true, true) } if err != nil { diff --git a/cmd/drone-build/run.go b/cmd/drone-build/run.go index faaf26c6..7158938f 100644 --- a/cmd/drone-build/run.go +++ b/cmd/drone-build/run.go @@ -134,11 +134,12 @@ func runSteps(c *Context, steps map[string]*common.Step) (int, error) { // verify the step matches the branch // and other specifications - if step.Condition == nil || - !step.Condition.MatchOwner(c.Repo.Owner) || - !step.Condition.MatchBranch(c.Clone.Branch) || - !step.Condition.MatchMatrix(c.Build.Environment) { - continue + if step.Condition != nil { + if !step.Condition.MatchOwner(c.Repo.Owner) || + !step.Condition.MatchBranch(c.Clone.Branch) || + !step.Condition.MatchMatrix(c.Build.Environment) { + continue + } } conf := toContainerConfig(step)