github.com/unclejack/drone@v0.2.1-0.20140918182345-831b034aa33b/pkg/plugin/publish/publish.go (about)

     1  package publish
     2  
     3  import (
     4  	"github.com/drone/drone/pkg/build/buildfile"
     5  	"github.com/drone/drone/pkg/build/repo"
     6  )
     7  
     8  // Publish stores the configuration details
     9  // for publishing build artifacts when
    10  // a Build has succeeded
    11  type Publish struct {
    12  	S3     *S3     `yaml:"s3,omitempty"`
    13  	Swift  *Swift  `yaml:"swift,omitempty"`
    14  	PyPI   *PyPI   `yaml:"pypi,omitempty"`
    15  	NPM    *NPM    `yaml:"npm,omitempty"`
    16  	Docker *Docker `yaml:"docker,omitempty"`
    17  }
    18  
    19  func (p *Publish) Write(f *buildfile.Buildfile, r *repo.Repo) {
    20  	// S3
    21  	if p.S3 != nil && (len(p.S3.Branch) == 0 || (len(p.S3.Branch) > 0 && r.Branch == p.S3.Branch)) {
    22  		p.S3.Write(f)
    23  	}
    24  
    25  	// Swift
    26  	if p.Swift != nil && (len(p.Swift.Branch) == 0 || (len(p.Swift.Branch) > 0 && r.Branch == p.Swift.Branch)) {
    27  		p.Swift.Write(f)
    28  	}
    29  
    30  	// PyPI
    31  	if p.PyPI != nil && (len(p.PyPI.Branch) == 0 || (len(p.PyPI.Branch) > 0 && r.Branch == p.PyPI.Branch)) {
    32  		p.PyPI.Write(f)
    33  	}
    34  
    35  	// NPM
    36  	if p.NPM != nil && (len(p.NPM.Branch) == 0 || (len(p.NPM.Branch) > 0 && r.Branch == p.NPM.Branch)) {
    37  		p.NPM.Write(f)
    38  	}
    39  
    40  	// Docker
    41  	if p.Docker != nil && (len(p.Docker.Branch) == 0 || (len(p.Docker.Branch) > 0 && r.Branch == p.Docker.Branch)) {
    42  		p.Docker.Write(f, r)
    43  	}
    44  }