Esempio n. 1
0
func (b *Box) Release(repoUrl string, pathspec string) error {
	defer db.DB.Save(b)

	b.publish("Make new release")
	release, err := NewRelease(b, repoUrl, pathspec)
	if err != nil {
		return err
	}

	b.publish("Created release to stage")
	if err := b.stage(release); err != nil {
		return err
	}

	b.publish("Test on staging release")
	if err := b.Staging.test(); err != nil {
		dispatcher.Trigger("test_release_failed", b)
		return err
	}

	b.publish("Move staging to production")
	if err := b.deploy(); err != nil {
		return err
	}

	b.publish("Cleanup old releases")
	if err := b.cleanup(); err != nil {
		return err
	}

	b.UpdateTime = time.Now().Local().Format(TimeFormat)
	return nil
}
Esempio n. 2
0
func BoxDeploy(name string, repoUrl string, pathspec string, stream *hub.Stream) (err error) {
	defer func() {
		stream.Close(err)
	}()

	box, err := farmer.FindBoxByName(name)
	if err != nil {
		return errors.New("Cannot find box '" + name + "'")
	}

	if box.State == farmer.StagingState {
		return errors.New("Box '" + name + "' is in Staging progress!")
	}

	box.OutputStream = stream
	box.ErrorStream = stream

	if repoUrl == "" {
		repoUrl = box.Production.RepoUrl
	}

	if pathspec == "" {
		pathspec = box.Production.Pathspec
	}

	if err = box.Release(repoUrl, pathspec); err != nil {
		return
	}

	dispatcher.Trigger("new_release", box)
	return nil
}
Esempio n. 3
0
func (b *Box) SetState(state string) error {
	b.State = state
	err := db.DB.Save(b).Error

	dispatcher.Trigger("box_changed", b)

	return err
}