--- a/bitbucket/docker-parser.go Mon May 08 21:29:01 2017 -0500
+++ b/bitbucket/docker-parser.go Mon May 08 22:57:33 2017 -0500
@@ -19,6 +19,7 @@
"github.com/alecthomas/kingpin"
@@ -26,6 +27,8 @@
"bitbucket.org/rw_grim/convey/tasks"
+// parseDockerCommand is a super stripped down kingpin parse that will parse +// docker command line options and return a convey task or an error func parseDockerCommand(argv []string) (tasks.Task, error) {
app := kingpin.New("", "")
@@ -44,6 +47,24 @@
push := app.Command("push", "")
pushImage := push.Arg("", "").Required().String()
+ pull := app.Command("pull", "") + pullImage := pull.Arg("", "").Required().String() + rmi := app.Command("rmi", "") + rmi.Flag("--force", "").Short('f').Default("false").Bool() + rmiImage := rmi.Arg("", "").Required().String() + run := app.Command("run", "") + runEntryPoint := run.Flag("entrypoint", "").String() + runEnv := run.Flag("env", "").Short('e').Strings() + runImage := run.Arg("image", "").Required().String() + runWorkdir := run.Flag("workdir", "").Short('w').String() + runCommand := run.Arg("", "").Strings() + tag := app.Command("tag", "") + tagSource := tag.Arg("src", "").Required().String() + tagDestination := tag.Arg("dest", "").Required().String() cmd, err := app.Parse(argv[1:])
@@ -67,10 +88,31 @@
+ Command: strings.Join(*runCommand, " "), + EntryPoint: *runEntryPoint, + Destination: *tagDestination, --- a/bitbucket/loader.go Mon May 08 21:29:01 2017 -0500
+++ b/bitbucket/loader.go Mon May 08 22:57:33 2017 -0500
@@ -72,7 +72,7 @@
currentScript := []string{}
for scriptIdx, command := range pipeline.Steps.Script {
argv, err := shellwords.Parse(command)
@@ -83,12 +83,14 @@
if strings.TrimSpace(strings.ToLower(argv[0])) == "docker" {
- name := fmt.Sprintf("%s-step-%d-%d", name, idx, scriptIdx)
+ taskName := fmt.Sprintf("%s-step-%d-%d", name, idx, scriptIdx) // if we have existing script commands add them now
if len(currentScript) > 0 {
- addScript(name, image, currentScript, plan, cfg)
+ taskName := fmt.Sprintf("%s-step-%d-%d", name, idx, scriptIdx-1) + addScript(taskName, image, currentScript, plan, cfg) currentScript = []string{}
// now figure out what docker command we're running
@@ -98,16 +100,18 @@
- addTask(name, task, plan, cfg)
+ addTask(taskName, task, plan, cfg) currentScript = append(currentScript, command)
// if we have existing script commands add them now
if len(currentScript) > 0 {
- name := fmt.Sprintf("%s-step-%d-%d", name, idx, scriptIdx)
+ name := fmt.Sprintf("%s-step-%d-%d", name, idx, last+1) addScript(name, image, currentScript, plan, cfg)
--- a/bitbucket/loader_test.go Mon May 08 21:29:01 2017 -0500
+++ b/bitbucket/loader_test.go Mon May 08 22:57:33 2017 -0500
@@ -86,7 +86,91 @@
Expect(cfg).To(Equal(expected))
-func (b *bitbucketSuite) TestLoaderDocker(t *testing.T) {
+func (b *bitbucketSuite) TestLoaderDockerMixed(t *testing.T) { + data := []byte(`image: gliderlabs/alpine:edge + - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + - docker build -t atlassian/my-app:$BITBUCKET_COMMIT . + - docker push atlassian/my-app:$BITBUCKET_COMMIT + cfg, err := l.Load("", "", data) + Expect(err).To(BeNil()) + expected := &config.Config{ + Tasks: map[string]tasks.Task{ + "import": &docker.Import{ + "default-step-0-0": &docker.Run{ + Image: "gliderlabs/alpine:edge", + Script: []string{"hostname"}, + "default-step-0-1": &docker.Login{ + Username: "$DOCKER_USERNAME", + Password: "$DOCKER_PASSWORD", + "default-step-0-2": &docker.Run{ + Image: "gliderlabs/alpine:edge", + Script: []string{"date +%s"}, + "default-step-0-3": &docker.Build{ + Tag: "atlassian/my-app:$BITBUCKET_COMMIT", + "default-step-0-4": &docker.Push{ + Image: "atlassian/my-app:$BITBUCKET_COMMIT", + "default-step-0-5": &docker.Run{ + Image: "gliderlabs/alpine:edge", + Script: []string{"date +%s"}, + Plans: map[string]plans.Plan{ + Stages: []stages.Stage{ + Expect(cfg).To(Equal(expected)) +func (b *bitbucketSuite) TestLoaderDockerSimple(t *testing.T) { data := []byte(`pipelines: