mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-24 08:08:38 +00:00
added code to append private environment variables for non-PRs
This commit is contained in:
parent
41ca011d27
commit
e7e6b2c608
2 changed files with 14 additions and 5 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/drone/drone/plugin/notify"
|
||||||
"github.com/drone/drone/server/database"
|
"github.com/drone/drone/server/database"
|
||||||
"github.com/drone/drone/server/pubsub"
|
"github.com/drone/drone/server/pubsub"
|
||||||
"github.com/drone/drone/shared/build"
|
"github.com/drone/drone/shared/build"
|
||||||
|
@ -103,6 +104,15 @@ func (w *worker) Execute(r *model.Request) {
|
||||||
log.Printf("Error parsing YAML for %s/%s, Err: %s", r.Repo.Owner, r.Repo.Name, err.Error())
|
log.Printf("Error parsing YAML for %s/%s, Err: %s", r.Repo.Owner, r.Repo.Name, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// append private parameters to the environment
|
||||||
|
// variable section of the .drone.yml file, iff
|
||||||
|
// this is not a pull request (for security purposes)
|
||||||
|
if params != nil && len(r.Commit.PullRequest) == 0 {
|
||||||
|
for k, v := range params {
|
||||||
|
script.Env = append(script.Env, k+"="+v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
path := r.Repo.Host + "/" + r.Repo.Owner + "/" + r.Repo.Name
|
path := r.Repo.Host + "/" + r.Repo.Owner + "/" + r.Repo.Name
|
||||||
repo := &repo.Repo{
|
repo := &repo.Repo{
|
||||||
Name: path,
|
Name: path,
|
||||||
|
@ -125,8 +135,9 @@ func (w *worker) Execute(r *model.Request) {
|
||||||
|
|
||||||
// send all "started" notifications
|
// send all "started" notifications
|
||||||
if script.Notifications != nil {
|
if script.Notifications != nil {
|
||||||
script.Notifications.Send(r)
|
script.Notifications = ¬ify.Notification{}
|
||||||
}
|
}
|
||||||
|
script.Notifications.Send(r)
|
||||||
|
|
||||||
// create an instance of the Docker builder
|
// create an instance of the Docker builder
|
||||||
builder := build.New(dockerClient)
|
builder := build.New(dockerClient)
|
||||||
|
@ -166,7 +177,5 @@ func (w *worker) Execute(r *model.Request) {
|
||||||
commitc.Publish(r)
|
commitc.Publish(r)
|
||||||
|
|
||||||
// send all "finished" notifications
|
// send all "finished" notifications
|
||||||
if script.Notifications != nil {
|
script.Notifications.Send(r)
|
||||||
script.Notifications.Send(r)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ type Build struct {
|
||||||
|
|
||||||
Deploy *deploy.Deploy `yaml:"deploy,omitempty"`
|
Deploy *deploy.Deploy `yaml:"deploy,omitempty"`
|
||||||
Publish *publish.Publish `yaml:"publish,omitempty"`
|
Publish *publish.Publish `yaml:"publish,omitempty"`
|
||||||
Notifications *notify.Notification `yaml:"notify"`
|
Notifications *notify.Notification `yaml:"notify,omitempty"`
|
||||||
|
|
||||||
// Git specified git-specific parameters, such as
|
// Git specified git-specific parameters, such as
|
||||||
// the clone depth and path
|
// the clone depth and path
|
||||||
|
|
Loading…
Reference in a new issue