mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-08 16:45:30 +00:00
Fix deploy task env (#3878)
This commit is contained in:
parent
fb37147948
commit
ceb14cadc5
10 changed files with 45 additions and 46 deletions
|
@ -201,12 +201,12 @@ var flags = []cli.Flag{
|
|||
Name: "pipeline-url",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"CI_PIPELINE_TARGET"},
|
||||
Name: "pipeline-target",
|
||||
EnvVars: []string{"CI_PIPELINE_DEPLOY_TARGET", "CI_PIPELINE_TARGET"}, // TODO: remove CI_PIPELINE_TARGET in 3.x
|
||||
Name: "pipeline-deploy-to",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"CI_PIPELINE_TASK"},
|
||||
Name: "pipeline-task",
|
||||
EnvVars: []string{"CI_PIPELINE_DEPLOY_TASK", "CI_PIPELINE_TASK"}, // TODO: remove CI_PIPELINE_TASK in 3.x
|
||||
Name: "pipeline-deploy-task",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"CI_COMMIT_SHA"},
|
||||
|
|
|
@ -52,16 +52,16 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata {
|
|||
Trusted: c.Bool("repo-trusted"),
|
||||
},
|
||||
Curr: metadata.Pipeline{
|
||||
Number: c.Int64("pipeline-number"),
|
||||
Parent: c.Int64("pipeline-parent"),
|
||||
Created: c.Int64("pipeline-created"),
|
||||
Started: c.Int64("pipeline-started"),
|
||||
Finished: c.Int64("pipeline-finished"),
|
||||
Status: c.String("pipeline-status"),
|
||||
Event: c.String("pipeline-event"),
|
||||
ForgeURL: c.String("pipeline-url"),
|
||||
Target: c.String("pipeline-target"),
|
||||
Task: c.String("pipeline-task"),
|
||||
Number: c.Int64("pipeline-number"),
|
||||
Parent: c.Int64("pipeline-parent"),
|
||||
Created: c.Int64("pipeline-created"),
|
||||
Started: c.Int64("pipeline-started"),
|
||||
Finished: c.Int64("pipeline-finished"),
|
||||
Status: c.String("pipeline-status"),
|
||||
Event: c.String("pipeline-event"),
|
||||
ForgeURL: c.String("pipeline-url"),
|
||||
DeployTo: c.String("pipeline-deploy-to"),
|
||||
DeployTask: c.String("pipeline-deploy-task"),
|
||||
Commit: metadata.Commit{
|
||||
Sha: c.String("commit-sha"),
|
||||
Ref: c.String("commit-ref"),
|
||||
|
|
|
@ -76,8 +76,8 @@ func (m *Metadata) Environ() map[string]string {
|
|||
"CI_PIPELINE_EVENT": m.Curr.Event,
|
||||
"CI_PIPELINE_URL": m.getPipelineWebURL(m.Curr, 0),
|
||||
"CI_PIPELINE_FORGE_URL": m.Curr.ForgeURL,
|
||||
"CI_PIPELINE_DEPLOY_TARGET": m.Curr.Target,
|
||||
"CI_PIPELINE_DEPLOY_TASK": m.Curr.Task,
|
||||
"CI_PIPELINE_DEPLOY_TARGET": m.Curr.DeployTo,
|
||||
"CI_PIPELINE_DEPLOY_TASK": m.Curr.DeployTask,
|
||||
"CI_PIPELINE_STATUS": m.Curr.Status,
|
||||
"CI_PIPELINE_CREATED": strconv.FormatInt(m.Curr.Created, 10),
|
||||
"CI_PIPELINE_STARTED": strconv.FormatInt(m.Curr.Started, 10),
|
||||
|
@ -108,8 +108,8 @@ func (m *Metadata) Environ() map[string]string {
|
|||
"CI_PREV_PIPELINE_EVENT": m.Prev.Event,
|
||||
"CI_PREV_PIPELINE_URL": m.getPipelineWebURL(m.Prev, 0),
|
||||
"CI_PREV_PIPELINE_FORGE_URL": m.Prev.ForgeURL,
|
||||
"CI_PREV_PIPELINE_DEPLOY_TARGET": m.Prev.Target,
|
||||
"CI_PREV_PIPELINE_DEPLOY_TASK": m.Prev.Task,
|
||||
"CI_PREV_PIPELINE_DEPLOY_TARGET": m.Prev.DeployTo,
|
||||
"CI_PREV_PIPELINE_DEPLOY_TASK": m.Prev.DeployTask,
|
||||
"CI_PREV_PIPELINE_STATUS": m.Prev.Status,
|
||||
"CI_PREV_PIPELINE_CREATED": strconv.FormatInt(m.Prev.Created, 10),
|
||||
"CI_PREV_PIPELINE_STARTED": strconv.FormatInt(m.Prev.Started, 10),
|
||||
|
|
|
@ -44,20 +44,18 @@ type (
|
|||
|
||||
// Pipeline defines runtime metadata for a pipeline.
|
||||
Pipeline struct {
|
||||
Number int64 `json:"number,omitempty"`
|
||||
Created int64 `json:"created,omitempty"`
|
||||
Started int64 `json:"started,omitempty"`
|
||||
Finished int64 `json:"finished,omitempty"`
|
||||
Timeout int64 `json:"timeout,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Event string `json:"event,omitempty"`
|
||||
ForgeURL string `json:"forge_url,omitempty"`
|
||||
Target string `json:"target,omitempty"`
|
||||
Task string `json:"task,omitempty"`
|
||||
Trusted bool `json:"trusted,omitempty"`
|
||||
Commit Commit `json:"commit,omitempty"`
|
||||
Parent int64 `json:"parent,omitempty"`
|
||||
Cron string `json:"cron,omitempty"`
|
||||
Number int64 `json:"number,omitempty"`
|
||||
Created int64 `json:"created,omitempty"`
|
||||
Started int64 `json:"started,omitempty"`
|
||||
Finished int64 `json:"finished,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Event string `json:"event,omitempty"`
|
||||
ForgeURL string `json:"forge_url,omitempty"`
|
||||
DeployTo string `json:"target,omitempty"`
|
||||
DeployTask string `json:"task,omitempty"`
|
||||
Commit Commit `json:"commit,omitempty"`
|
||||
Parent int64 `json:"parent,omitempty"`
|
||||
Cron string `json:"cron,omitempty"`
|
||||
}
|
||||
|
||||
// Commit defines runtime metadata for a commit.
|
||||
|
|
|
@ -164,7 +164,7 @@ func (c *Constraint) Match(m metadata.Metadata, global bool, env map[string]stri
|
|||
}
|
||||
|
||||
match = match && c.Platform.Match(m.Sys.Platform) &&
|
||||
c.Environment.Match(m.Curr.Target) &&
|
||||
c.Environment.Match(m.Curr.DeployTo) &&
|
||||
c.Event.Match(m.Curr.Event) &&
|
||||
c.Repo.Match(path.Join(m.Repo.Owner, m.Repo.Name)) &&
|
||||
c.Ref.Match(m.Curr.Commit.Ref) &&
|
||||
|
|
|
@ -562,7 +562,7 @@ func PostPipeline(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
pl.Deploy = c.DefaultQuery("deploy_to", pl.Deploy)
|
||||
pl.DeployTo = c.DefaultQuery("deploy_to", pl.DeployTo)
|
||||
}
|
||||
|
||||
// Read query string parameters into pipelineParams, exclude reserved params
|
||||
|
|
|
@ -126,10 +126,10 @@ func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline
|
|||
Message: hook.GetDeployment().GetDescription(),
|
||||
Ref: hook.GetDeployment().GetRef(),
|
||||
Branch: hook.GetDeployment().GetRef(),
|
||||
Deploy: hook.GetDeployment().GetEnvironment(),
|
||||
Avatar: hook.GetSender().GetAvatarURL(),
|
||||
Author: hook.GetSender().GetLogin(),
|
||||
Sender: hook.GetSender().GetLogin(),
|
||||
DeployTo: hook.GetDeployment().GetEnvironment(),
|
||||
DeployTask: hook.GetDeployment().GetTask(),
|
||||
}
|
||||
// if the ref is a sha or short sha we need to manually construct the ref.
|
||||
|
|
|
@ -119,7 +119,7 @@ func Test_parser(t *testing.T) {
|
|||
g.Assert(b).IsNotNil()
|
||||
g.Assert(p).IsNil()
|
||||
g.Assert(b.Event).Equal(model.EventDeploy)
|
||||
g.Assert(b.Deploy).Equal("production")
|
||||
g.Assert(b.DeployTo).Equal("production")
|
||||
g.Assert(b.DeployTask).Equal("deploy")
|
||||
})
|
||||
})
|
||||
|
|
|
@ -32,7 +32,7 @@ type Pipeline struct {
|
|||
Updated int64 `json:"updated_at" xorm:"'updated' NOT NULL DEFAULT 0 updated"` // TODO change JSON field to "updated" in 3.0
|
||||
Started int64 `json:"started_at" xorm:"started"` // TODO change JSON field to "started" in 3.0
|
||||
Finished int64 `json:"finished_at" xorm:"finished"` // TODO change JSON field to "finished" in 3.0
|
||||
Deploy string `json:"deploy_to" xorm:"deploy"`
|
||||
DeployTo string `json:"deploy_to" xorm:"deploy"`
|
||||
DeployTask string `json:"deploy_task" xorm:"deploy_task"`
|
||||
Commit string `json:"commit" xorm:"commit"`
|
||||
Branch string `json:"branch" xorm:"branch"`
|
||||
|
|
|
@ -107,15 +107,16 @@ func metadataPipelineFromModelPipeline(pipeline *model.Pipeline, includeParent b
|
|||
}
|
||||
|
||||
return metadata.Pipeline{
|
||||
Number: pipeline.Number,
|
||||
Parent: parent,
|
||||
Created: pipeline.Created,
|
||||
Started: pipeline.Started,
|
||||
Finished: pipeline.Finished,
|
||||
Status: string(pipeline.Status),
|
||||
Event: string(pipeline.Event),
|
||||
ForgeURL: pipeline.ForgeURL,
|
||||
Target: pipeline.Deploy,
|
||||
Number: pipeline.Number,
|
||||
Parent: parent,
|
||||
Created: pipeline.Created,
|
||||
Started: pipeline.Started,
|
||||
Finished: pipeline.Finished,
|
||||
Status: string(pipeline.Status),
|
||||
Event: string(pipeline.Event),
|
||||
ForgeURL: pipeline.ForgeURL,
|
||||
DeployTo: pipeline.DeployTo,
|
||||
DeployTask: pipeline.DeployTask,
|
||||
Commit: metadata.Commit{
|
||||
Sha: pipeline.Commit,
|
||||
Ref: pipeline.Ref,
|
||||
|
|
Loading…
Reference in a new issue