mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-08-10 18:11:42 +00:00
Fix deploy task env (#3878)
This commit is contained in:
parent
fb37147948
commit
ceb14cadc5
@ -201,12 +201,12 @@ var flags = []cli.Flag{
|
|||||||
Name: "pipeline-url",
|
Name: "pipeline-url",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_TARGET"},
|
EnvVars: []string{"CI_PIPELINE_DEPLOY_TARGET", "CI_PIPELINE_TARGET"}, // TODO: remove CI_PIPELINE_TARGET in 3.x
|
||||||
Name: "pipeline-target",
|
Name: "pipeline-deploy-to",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_TASK"},
|
EnvVars: []string{"CI_PIPELINE_DEPLOY_TASK", "CI_PIPELINE_TASK"}, // TODO: remove CI_PIPELINE_TASK in 3.x
|
||||||
Name: "pipeline-task",
|
Name: "pipeline-deploy-task",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_COMMIT_SHA"},
|
EnvVars: []string{"CI_COMMIT_SHA"},
|
||||||
|
@ -60,8 +60,8 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata {
|
|||||||
Status: c.String("pipeline-status"),
|
Status: c.String("pipeline-status"),
|
||||||
Event: c.String("pipeline-event"),
|
Event: c.String("pipeline-event"),
|
||||||
ForgeURL: c.String("pipeline-url"),
|
ForgeURL: c.String("pipeline-url"),
|
||||||
Target: c.String("pipeline-target"),
|
DeployTo: c.String("pipeline-deploy-to"),
|
||||||
Task: c.String("pipeline-task"),
|
DeployTask: c.String("pipeline-deploy-task"),
|
||||||
Commit: metadata.Commit{
|
Commit: metadata.Commit{
|
||||||
Sha: c.String("commit-sha"),
|
Sha: c.String("commit-sha"),
|
||||||
Ref: c.String("commit-ref"),
|
Ref: c.String("commit-ref"),
|
||||||
|
@ -76,8 +76,8 @@ func (m *Metadata) Environ() map[string]string {
|
|||||||
"CI_PIPELINE_EVENT": m.Curr.Event,
|
"CI_PIPELINE_EVENT": m.Curr.Event,
|
||||||
"CI_PIPELINE_URL": m.getPipelineWebURL(m.Curr, 0),
|
"CI_PIPELINE_URL": m.getPipelineWebURL(m.Curr, 0),
|
||||||
"CI_PIPELINE_FORGE_URL": m.Curr.ForgeURL,
|
"CI_PIPELINE_FORGE_URL": m.Curr.ForgeURL,
|
||||||
"CI_PIPELINE_DEPLOY_TARGET": m.Curr.Target,
|
"CI_PIPELINE_DEPLOY_TARGET": m.Curr.DeployTo,
|
||||||
"CI_PIPELINE_DEPLOY_TASK": m.Curr.Task,
|
"CI_PIPELINE_DEPLOY_TASK": m.Curr.DeployTask,
|
||||||
"CI_PIPELINE_STATUS": m.Curr.Status,
|
"CI_PIPELINE_STATUS": m.Curr.Status,
|
||||||
"CI_PIPELINE_CREATED": strconv.FormatInt(m.Curr.Created, 10),
|
"CI_PIPELINE_CREATED": strconv.FormatInt(m.Curr.Created, 10),
|
||||||
"CI_PIPELINE_STARTED": strconv.FormatInt(m.Curr.Started, 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_EVENT": m.Prev.Event,
|
||||||
"CI_PREV_PIPELINE_URL": m.getPipelineWebURL(m.Prev, 0),
|
"CI_PREV_PIPELINE_URL": m.getPipelineWebURL(m.Prev, 0),
|
||||||
"CI_PREV_PIPELINE_FORGE_URL": m.Prev.ForgeURL,
|
"CI_PREV_PIPELINE_FORGE_URL": m.Prev.ForgeURL,
|
||||||
"CI_PREV_PIPELINE_DEPLOY_TARGET": m.Prev.Target,
|
"CI_PREV_PIPELINE_DEPLOY_TARGET": m.Prev.DeployTo,
|
||||||
"CI_PREV_PIPELINE_DEPLOY_TASK": m.Prev.Task,
|
"CI_PREV_PIPELINE_DEPLOY_TASK": m.Prev.DeployTask,
|
||||||
"CI_PREV_PIPELINE_STATUS": m.Prev.Status,
|
"CI_PREV_PIPELINE_STATUS": m.Prev.Status,
|
||||||
"CI_PREV_PIPELINE_CREATED": strconv.FormatInt(m.Prev.Created, 10),
|
"CI_PREV_PIPELINE_CREATED": strconv.FormatInt(m.Prev.Created, 10),
|
||||||
"CI_PREV_PIPELINE_STARTED": strconv.FormatInt(m.Prev.Started, 10),
|
"CI_PREV_PIPELINE_STARTED": strconv.FormatInt(m.Prev.Started, 10),
|
||||||
|
@ -48,13 +48,11 @@ type (
|
|||||||
Created int64 `json:"created,omitempty"`
|
Created int64 `json:"created,omitempty"`
|
||||||
Started int64 `json:"started,omitempty"`
|
Started int64 `json:"started,omitempty"`
|
||||||
Finished int64 `json:"finished,omitempty"`
|
Finished int64 `json:"finished,omitempty"`
|
||||||
Timeout int64 `json:"timeout,omitempty"`
|
|
||||||
Status string `json:"status,omitempty"`
|
Status string `json:"status,omitempty"`
|
||||||
Event string `json:"event,omitempty"`
|
Event string `json:"event,omitempty"`
|
||||||
ForgeURL string `json:"forge_url,omitempty"`
|
ForgeURL string `json:"forge_url,omitempty"`
|
||||||
Target string `json:"target,omitempty"`
|
DeployTo string `json:"target,omitempty"`
|
||||||
Task string `json:"task,omitempty"`
|
DeployTask string `json:"task,omitempty"`
|
||||||
Trusted bool `json:"trusted,omitempty"`
|
|
||||||
Commit Commit `json:"commit,omitempty"`
|
Commit Commit `json:"commit,omitempty"`
|
||||||
Parent int64 `json:"parent,omitempty"`
|
Parent int64 `json:"parent,omitempty"`
|
||||||
Cron string `json:"cron,omitempty"`
|
Cron string `json:"cron,omitempty"`
|
||||||
|
@ -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) &&
|
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.Event.Match(m.Curr.Event) &&
|
||||||
c.Repo.Match(path.Join(m.Repo.Owner, m.Repo.Name)) &&
|
c.Repo.Match(path.Join(m.Repo.Owner, m.Repo.Name)) &&
|
||||||
c.Ref.Match(m.Curr.Commit.Ref) &&
|
c.Ref.Match(m.Curr.Commit.Ref) &&
|
||||||
|
@ -562,7 +562,7 @@ func PostPipeline(c *gin.Context) {
|
|||||||
return
|
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
|
// 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(),
|
Message: hook.GetDeployment().GetDescription(),
|
||||||
Ref: hook.GetDeployment().GetRef(),
|
Ref: hook.GetDeployment().GetRef(),
|
||||||
Branch: hook.GetDeployment().GetRef(),
|
Branch: hook.GetDeployment().GetRef(),
|
||||||
Deploy: hook.GetDeployment().GetEnvironment(),
|
|
||||||
Avatar: hook.GetSender().GetAvatarURL(),
|
Avatar: hook.GetSender().GetAvatarURL(),
|
||||||
Author: hook.GetSender().GetLogin(),
|
Author: hook.GetSender().GetLogin(),
|
||||||
Sender: hook.GetSender().GetLogin(),
|
Sender: hook.GetSender().GetLogin(),
|
||||||
|
DeployTo: hook.GetDeployment().GetEnvironment(),
|
||||||
DeployTask: hook.GetDeployment().GetTask(),
|
DeployTask: hook.GetDeployment().GetTask(),
|
||||||
}
|
}
|
||||||
// if the ref is a sha or short sha we need to manually construct the ref.
|
// 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(b).IsNotNil()
|
||||||
g.Assert(p).IsNil()
|
g.Assert(p).IsNil()
|
||||||
g.Assert(b.Event).Equal(model.EventDeploy)
|
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")
|
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
|
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
|
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
|
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"`
|
DeployTask string `json:"deploy_task" xorm:"deploy_task"`
|
||||||
Commit string `json:"commit" xorm:"commit"`
|
Commit string `json:"commit" xorm:"commit"`
|
||||||
Branch string `json:"branch" xorm:"branch"`
|
Branch string `json:"branch" xorm:"branch"`
|
||||||
|
@ -115,7 +115,8 @@ func metadataPipelineFromModelPipeline(pipeline *model.Pipeline, includeParent b
|
|||||||
Status: string(pipeline.Status),
|
Status: string(pipeline.Status),
|
||||||
Event: string(pipeline.Event),
|
Event: string(pipeline.Event),
|
||||||
ForgeURL: pipeline.ForgeURL,
|
ForgeURL: pipeline.ForgeURL,
|
||||||
Target: pipeline.Deploy,
|
DeployTo: pipeline.DeployTo,
|
||||||
|
DeployTask: pipeline.DeployTask,
|
||||||
Commit: metadata.Commit{
|
Commit: metadata.Commit{
|
||||||
Sha: pipeline.Commit,
|
Sha: pipeline.Commit,
|
||||||
Ref: pipeline.Ref,
|
Ref: pipeline.Ref,
|
||||||
|
Loading…
Reference in New Issue
Block a user