mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 08:56:29 +00:00
Merge pull request #291 from sivel/restrict-publish-branch
Add the ability to restrict publish plugins to a specific branch
This commit is contained in:
commit
cc9c6c9bde
5 changed files with 21 additions and 7 deletions
|
@ -229,6 +229,7 @@ publish:
|
|||
container: drone
|
||||
source: /tmp/drone.deb
|
||||
target: latest/drone.deb
|
||||
branch: master
|
||||
|
||||
```
|
||||
|
||||
|
@ -248,6 +249,10 @@ Drone currently has these `deploy` and `publish` plugins implemented (more to co
|
|||
- [OpenStack Swift](#docs)
|
||||
- [PyPI](#docs)
|
||||
|
||||
Publish plugins can be limited to a specific branch using the `branch` configuration
|
||||
as seen above in the `swift` example. If you do not specify a `branch` all branches
|
||||
will be published, with the exception of Pull Requests.
|
||||
|
||||
### Notifications
|
||||
|
||||
Drone can trigger email, hipchat and web hook notification at the beginning and
|
||||
|
|
|
@ -517,7 +517,7 @@ func (b *Builder) writeBuildScript(dir string) error {
|
|||
// we should only execute the build commands,
|
||||
// and omit the deploy and publish commands.
|
||||
if len(b.Repo.PR) == 0 {
|
||||
b.Build.Write(f)
|
||||
b.Build.Write(f, b.Repo)
|
||||
} else {
|
||||
// only write the build commands
|
||||
b.Build.WriteBuild(f)
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
"github.com/drone/drone/pkg/build/buildfile"
|
||||
"github.com/drone/drone/pkg/build/git"
|
||||
"github.com/drone/drone/pkg/build/repo"
|
||||
"github.com/drone/drone/pkg/plugin/deploy"
|
||||
"github.com/drone/drone/pkg/plugin/notify"
|
||||
"github.com/drone/drone/pkg/plugin/publish"
|
||||
|
@ -81,13 +82,13 @@ type Build struct {
|
|||
|
||||
// Write adds all the steps to the build script, including
|
||||
// build commands, deploy and publish commands.
|
||||
func (b *Build) Write(f *buildfile.Buildfile) {
|
||||
func (b *Build) Write(f *buildfile.Buildfile, r *repo.Repo) {
|
||||
// append build commands
|
||||
b.WriteBuild(f)
|
||||
|
||||
// write publish commands
|
||||
if b.Publish != nil {
|
||||
b.Publish.Write(f)
|
||||
b.Publish.Write(f, r)
|
||||
}
|
||||
|
||||
// write deployment commands
|
||||
|
|
|
@ -2,6 +2,7 @@ package publish
|
|||
|
||||
import (
|
||||
"github.com/drone/drone/pkg/build/buildfile"
|
||||
"github.com/drone/drone/pkg/build/repo"
|
||||
)
|
||||
|
||||
// Publish stores the configuration details
|
||||
|
@ -13,14 +14,19 @@ type Publish struct {
|
|||
PyPI *PyPI `yaml:"pypi,omitempty"`
|
||||
}
|
||||
|
||||
func (p *Publish) Write(f *buildfile.Buildfile) {
|
||||
if p.S3 != nil {
|
||||
func (p *Publish) Write(f *buildfile.Buildfile, r *repo.Repo) {
|
||||
// S3
|
||||
if p.S3 != nil && (len(p.S3.Branch) == 0 || (len(p.S3.Branch) > 0 && r.Branch == p.S3.Branch)) {
|
||||
p.S3.Write(f)
|
||||
}
|
||||
if p.Swift != nil {
|
||||
|
||||
// Swift
|
||||
if p.Swift != nil && (len(p.Swift.Branch) == 0 || (len(p.Swift.Branch) > 0 && r.Branch == p.Swift.Branch)) {
|
||||
p.Swift.Write(f)
|
||||
}
|
||||
if p.PyPI != nil {
|
||||
|
||||
// PyPI
|
||||
if p.PyPI != nil && (len(p.PyPI.Branch) == 0 || (len(p.PyPI.Branch) > 0 && r.Branch == p.PyPI.Branch)) {
|
||||
p.PyPI.Write(f)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package publish
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/drone/drone/pkg/build/buildfile"
|
||||
)
|
||||
|
||||
|
@ -36,6 +37,7 @@ type PyPI struct {
|
|||
Password string `yaml:"password,omitempty"`
|
||||
Formats []string `yaml:"formats,omitempty"`
|
||||
Repository string `yaml:"repository,omitempty"`
|
||||
Branch string `yaml:"branch,omitempty"`
|
||||
}
|
||||
|
||||
func (p *PyPI) Write(f *buildfile.Buildfile) {
|
||||
|
|
Loading…
Reference in a new issue