diff --git a/plugin/deploy/deployment.go b/plugin/deploy/deployment.go index 198c71a27..20c19c09f 100644 --- a/plugin/deploy/deployment.go +++ b/plugin/deploy/deployment.go @@ -8,6 +8,7 @@ import ( "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/marathon" "github.com/drone/drone/plugin/deploy/modulus" "github.com/drone/drone/plugin/deploy/nodejitsu" "github.com/drone/drone/plugin/deploy/tsuru" @@ -26,6 +27,7 @@ type Deploy struct { SSH *SSH `yaml:"ssh,omitempty"` Tsuru *tsuru.Tsuru `yaml:"tsuru,omitempty"` Bash *Bash `yaml:"bash,omitempty"` + Marathon *marathon.Marathon `yaml:"marathon,omitempty"` } func (d *Deploy) Write(f *buildfile.Buildfile, r *repo.Repo) { @@ -57,6 +59,9 @@ func (d *Deploy) Write(f *buildfile.Buildfile, r *repo.Repo) { if d.Bash != nil && match(d.Bash.GetCondition(), r) { d.Bash.Write(f) } + if d.Marathon != nil && match(d.Marathon.GetCondition(), r) { + d.Marathon.Write(f) + } } func match(c *condition.Condition, r *repo.Repo) bool { diff --git a/plugin/deploy/marathon/marathon.go b/plugin/deploy/marathon/marathon.go new file mode 100644 index 000000000..b55000a68 --- /dev/null +++ b/plugin/deploy/marathon/marathon.go @@ -0,0 +1,39 @@ +package marathon + +import ( + "fmt" + + "github.com/drone/drone/plugin/condition" + "github.com/drone/drone/shared/build/buildfile" +) + +type Marathon struct { + //Hostname for the Marathon Master + Host string `yaml:"host,omitempty"` + + // The app config for marathon + //https://mesosphere.github.io/marathon/docs/rest-api.html#post-v2-apps + // Examples: + // /path/to/file + // /path/to/*.txt + // /path/to/*/*.txt + // /path/to/** + ConfigFile string `yaml:"config_file,omitempty"` + Condition *condition.Condition `yaml:"when,omitempty"` +} + +func (m *Marathon) Write(f *buildfile.Buildfile) { + // debugging purposes so we can see if / where something is failing + f.WriteCmdSilent("echo 'deploying to Marathon ...'") + + post := fmt.Sprintf( + "curl -X POST -d @%s http://%s/v2/apps --header \"Content-Type:application/json\"", + m.ConfigFile, + m.Host, + ) + f.WriteCmdSilent(post) +} + +func (m *Marathon) GetCondition() *condition.Condition { + return m.Condition +}