From d9f5fc5b3fdccac9f93c693c7b43817f6cfd2887 Mon Sep 17 00:00:00 2001 From: Fernando Barbosa Date: Tue, 19 Mar 2024 17:00:39 -0300 Subject: [PATCH 1/8] feat: support github deploy task --- cli/exec/flags.go | 4 ++++ cli/exec/metadata.go | 1 + docs/docs/20-usage/50-environment.md | 2 ++ .../20-usage/20-workflow-syntax.md | 11 ++++++++++ pipeline/frontend/metadata/environment.go | 2 ++ pipeline/frontend/metadata/types.go | 1 + .../frontend/yaml/constraint/constraint.go | 2 ++ .../linter/schema/.woodpecker/test-when.yaml | 1 + .../frontend/yaml/linter/schema/schema.json | 8 +++++++ server/api/pipeline.go | 3 +++ server/forge/github/convert_test.go | 1 + server/forge/github/parse.go | 21 ++++++++++--------- server/forge/github/parse_test.go | 2 ++ server/model/pipeline.go | 1 + server/pipeline/stepbuilder/metadata.go | 1 + server/pipeline/stepbuilder/metadata_test.go | 8 +++---- 16 files changed, 55 insertions(+), 14 deletions(-) diff --git a/cli/exec/flags.go b/cli/exec/flags.go index be2bb69a27d..199c40ae648 100644 --- a/cli/exec/flags.go +++ b/cli/exec/flags.go @@ -199,6 +199,10 @@ var flags = []cli.Flag{ EnvVars: []string{"CI_PIPELINE_TARGET"}, Name: "pipeline-target", }, + &cli.StringFlag{ + EnvVars: []string{"CI_PIPELINE_TASK"}, + Name: "pipeline-task", + }, &cli.StringFlag{ EnvVars: []string{"CI_COMMIT_SHA"}, Name: "commit-sha", diff --git a/cli/exec/metadata.go b/cli/exec/metadata.go index c72aeaffadc..0cb4716838c 100644 --- a/cli/exec/metadata.go +++ b/cli/exec/metadata.go @@ -61,6 +61,7 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata { Event: c.String("pipeline-event"), ForgeURL: c.String("pipeline-url"), Target: c.String("pipeline-target"), + Task: c.String("pipeline-task"), Commit: metadata.Commit{ Sha: c.String("commit-sha"), Ref: c.String("commit-ref"), diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index ce05812e407..84685e3dc6a 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -85,6 +85,7 @@ This is the reference list of all environment variables available to your pipeli | `CI_PIPELINE_URL` | link to the web UI for the pipeline | | `CI_PIPELINE_FORGE_URL` | link to the forge's web UI for the commit(s) or tag that triggered the pipeline | | `CI_PIPELINE_DEPLOY_TARGET` | pipeline deploy target for `deployment` events (i.e. production) | +| `CI_PIPELINE_DEPLOY_TASK` | pipeline deploy task for `deployment` events (i.e. migration) | | `CI_PIPELINE_STATUS` | pipeline status (success, failure) | | `CI_PIPELINE_CREATED` | pipeline created UNIX timestamp | | `CI_PIPELINE_STARTED` | pipeline started UNIX timestamp | @@ -118,6 +119,7 @@ This is the reference list of all environment variables available to your pipeli | `CI_PREV_PIPELINE_URL` | previous pipeline link in CI | | `CI_PREV_PIPELINE_FORGE_URL` | previous pipeline link to event in forge | | `CI_PREV_PIPELINE_DEPLOY_TARGET` | previous pipeline deploy target for `deployment` events (ie production) | +| `CI_PREV_PIPELINE_DEPLOY_TASK` | previous pipeline deploy task for `deployment` events (ie migration) | | `CI_PREV_PIPELINE_STATUS` | previous pipeline status (success, failure) | | `CI_PREV_PIPELINE_CREATED` | previous pipeline created UNIX timestamp | | `CI_PREV_PIPELINE_STARTED` | previous pipeline started UNIX timestamp | diff --git a/docs/versioned_docs/version-2.1/20-usage/20-workflow-syntax.md b/docs/versioned_docs/version-2.1/20-usage/20-workflow-syntax.md index 9efee6fbf2e..773519aed01 100644 --- a/docs/versioned_docs/version-2.1/20-usage/20-workflow-syntax.md +++ b/docs/versioned_docs/version-2.1/20-usage/20-workflow-syntax.md @@ -803,6 +803,17 @@ when: event: deployment ``` +### `task` + +Execute a step for deployment events matching the target deployment task: + +```diff +when: + task: migration + event: deployment +``` + + ### `instance` Execute a step only on a certain Woodpecker instance matching the specified hostname: diff --git a/pipeline/frontend/metadata/environment.go b/pipeline/frontend/metadata/environment.go index d32378d024f..7068aba0193 100644 --- a/pipeline/frontend/metadata/environment.go +++ b/pipeline/frontend/metadata/environment.go @@ -77,6 +77,7 @@ func (m *Metadata) Environ() map[string]string { "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_STATUS": m.Curr.Status, "CI_PIPELINE_CREATED": strconv.FormatInt(m.Curr.Created, 10), "CI_PIPELINE_STARTED": strconv.FormatInt(m.Curr.Started, 10), @@ -108,6 +109,7 @@ func (m *Metadata) Environ() map[string]string { "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_STATUS": m.Prev.Status, "CI_PREV_PIPELINE_CREATED": strconv.FormatInt(m.Prev.Created, 10), "CI_PREV_PIPELINE_STARTED": strconv.FormatInt(m.Prev.Started, 10), diff --git a/pipeline/frontend/metadata/types.go b/pipeline/frontend/metadata/types.go index c75f321e62d..932bb0a6378 100644 --- a/pipeline/frontend/metadata/types.go +++ b/pipeline/frontend/metadata/types.go @@ -53,6 +53,7 @@ type ( 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"` diff --git a/pipeline/frontend/yaml/constraint/constraint.go b/pipeline/frontend/yaml/constraint/constraint.go index 1d08ecb0961..1ad5268f7c9 100644 --- a/pipeline/frontend/yaml/constraint/constraint.go +++ b/pipeline/frontend/yaml/constraint/constraint.go @@ -42,6 +42,7 @@ type ( Instance List Platform List Environment List + Task List Branch List Cron List Status List @@ -164,6 +165,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.Task.Match(m.Curr.Task) && c.Event.Match(m.Curr.Event) && c.Repo.Match(path.Join(m.Repo.Owner, m.Repo.Name)) && c.Ref.Match(m.Curr.Commit.Ref) && diff --git a/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml b/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml index 86798928578..cef810e65bb 100644 --- a/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml +++ b/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml @@ -76,6 +76,7 @@ steps: - echo "test" when: environment: production + task: migration event: deployment when-matrix: diff --git a/pipeline/frontend/yaml/linter/schema/schema.json b/pipeline/frontend/yaml/linter/schema/schema.json index 41d69de6276..46e30c87b11 100644 --- a/pipeline/frontend/yaml/linter/schema/schema.json +++ b/pipeline/frontend/yaml/linter/schema/schema.json @@ -255,6 +255,10 @@ "description": "Execute a step only for a specific environment. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#environment", "$ref": "#/definitions/constraint_list" }, + "task": { + "description": "Execute a step only for a specific task. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax#task", + "$ref": "#/definitions/constraint_list" + }, "instance": { "description": "Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#instance", "$ref": "#/definitions/constraint_list" @@ -438,6 +442,10 @@ "description": "Execute a step only for a specific environment. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#environment", "$ref": "#/definitions/constraint_list" }, + "task": { + "description": "Execute a step only for a specific task. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax#task", + "$ref": "#/definitions/constraint_list" + }, "matrix": { "description": "Read more: https://woodpecker-ci.org/docs/usage/matrix-workflows", "type": "object", diff --git a/server/api/pipeline.go b/server/api/pipeline.go index c151e1f2643..af2bf178201 100644 --- a/server/api/pipeline.go +++ b/server/api/pipeline.go @@ -409,6 +409,9 @@ func PostPipeline(c *gin.Context) { // make Deploy overridable pl.Deploy = c.DefaultQuery("deploy_to", pl.Deploy) + // make Deploy task overridable + pl.DeployTask = c.DefaultQuery("deploy_task", pl.DeployTask) + // make Event overridable if event, ok := c.GetQuery("event"); ok { pl.Event = model.WebhookEvent(event) diff --git a/server/forge/github/convert_test.go b/server/forge/github/convert_test.go index 7894cd00b7f..3ad3df3f203 100644 --- a/server/forge/github/convert_test.go +++ b/server/forge/github/convert_test.go @@ -224,6 +224,7 @@ func Test_helper(t *testing.T) { from := &github.DeploymentEvent{Deployment: &github.Deployment{}, Sender: &github.User{}} from.Deployment.Description = github.String(":shipit:") from.Deployment.Environment = github.String("production") + from.Deployment.Task = github.String("deploy") from.Deployment.ID = github.Int64(42) from.Deployment.Ref = github.String("main") from.Deployment.SHA = github.String("f72fc19") diff --git a/server/forge/github/parse.go b/server/forge/github/parse.go index 4d47b10cca7..88cbb81340f 100644 --- a/server/forge/github/parse.go +++ b/server/forge/github/parse.go @@ -120,16 +120,17 @@ func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline) { // If the commit type is unsupported nil values are returned. func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline) { pipeline := &model.Pipeline{ - Event: model.EventDeploy, - Commit: hook.GetDeployment().GetSHA(), - ForgeURL: hook.GetDeployment().GetURL(), - 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(), + Event: model.EventDeploy, + Commit: hook.GetDeployment().GetSHA(), + ForgeURL: hook.GetDeployment().GetURL(), + 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(), + DeployTask: hook.GetDeployment().GetTask(), } // if the ref is a sha or short sha we need to manually construct the ref. if strings.HasPrefix(pipeline.Commit, pipeline.Ref) || pipeline.Commit == pipeline.Ref { diff --git a/server/forge/github/parse_test.go b/server/forge/github/parse_test.go index bbd4fb57fce..ff28df811b7 100644 --- a/server/forge/github/parse_test.go +++ b/server/forge/github/parse_test.go @@ -119,6 +119,8 @@ 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.DeployTask).Equal("deploy") }) }) diff --git a/server/model/pipeline.go b/server/model/pipeline.go index 1a0a7226d8c..407006c4db7 100644 --- a/server/model/pipeline.go +++ b/server/model/pipeline.go @@ -33,6 +33,7 @@ type Pipeline struct { Started int64 `json:"started_at" xorm:"pipeline_started"` Finished int64 `json:"finished_at" xorm:"pipeline_finished"` Deploy string `json:"deploy_to" xorm:"pipeline_deploy"` + DeployTask string `json:"deploy_task" xorm:"pipeline_deploy_task"` Commit string `json:"commit" xorm:"pipeline_commit"` Branch string `json:"branch" xorm:"pipeline_branch"` Ref string `json:"ref" xorm:"pipeline_ref"` diff --git a/server/pipeline/stepbuilder/metadata.go b/server/pipeline/stepbuilder/metadata.go index 2e2a3c106c4..61d2b79c295 100644 --- a/server/pipeline/stepbuilder/metadata.go +++ b/server/pipeline/stepbuilder/metadata.go @@ -116,6 +116,7 @@ func metadataPipelineFromModelPipeline(pipeline *model.Pipeline, includeParent b Event: string(pipeline.Event), ForgeURL: pipeline.ForgeURL, Target: pipeline.Deploy, + Task: pipeline.DeployTask, Commit: metadata.Commit{ Sha: pipeline.Commit, Ref: pipeline.Ref, diff --git a/server/pipeline/stepbuilder/metadata_test.go b/server/pipeline/stepbuilder/metadata_test.go index 62e8b50d52f..a0d45142539 100644 --- a/server/pipeline/stepbuilder/metadata_test.go +++ b/server/pipeline/stepbuilder/metadata_test.go @@ -47,11 +47,11 @@ func TestMetadataFromStruct(t *testing.T) { "CI_COMMIT_AUTHOR": "", "CI_COMMIT_AUTHOR_AVATAR": "", "CI_COMMIT_AUTHOR_EMAIL": "", "CI_COMMIT_BRANCH": "", "CI_COMMIT_MESSAGE": "", "CI_COMMIT_PULL_REQUEST": "", "CI_COMMIT_PULL_REQUEST_LABELS": "", "CI_COMMIT_REF": "", "CI_COMMIT_REFSPEC": "", "CI_COMMIT_SHA": "", "CI_COMMIT_SOURCE_BRANCH": "", "CI_COMMIT_TAG": "", "CI_COMMIT_TARGET_BRANCH": "", "CI_COMMIT_URL": "", "CI_FORGE_TYPE": "", "CI_FORGE_URL": "", - "CI_PIPELINE_CREATED": "0", "CI_PIPELINE_DEPLOY_TARGET": "", "CI_PIPELINE_EVENT": "", "CI_PIPELINE_FINISHED": "0", "CI_PIPELINE_FILES": "[]", "CI_PIPELINE_NUMBER": "0", + "CI_PIPELINE_CREATED": "0", "CI_PIPELINE_DEPLOY_TARGET": "", "CI_PIPELINE_DEPLOY_TASK": "", "CI_PIPELINE_EVENT": "", "CI_PIPELINE_FINISHED": "0", "CI_PIPELINE_FILES": "[]", "CI_PIPELINE_NUMBER": "0", "CI_PIPELINE_PARENT": "0", "CI_PIPELINE_STARTED": "0", "CI_PIPELINE_STATUS": "", "CI_PIPELINE_URL": "/repos/0/pipeline/0", "CI_PIPELINE_FORGE_URL": "", "CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "", "CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0", - "CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "0", "CI_PREV_PIPELINE_PARENT": "0", + "CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_DEPLOY_TASK": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "0", "CI_PREV_PIPELINE_PARENT": "0", "CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "/repos/0/pipeline/0", "CI_PREV_PIPELINE_FORGE_URL": "", "CI_REPO": "", "CI_REPO_CLONE_URL": "", "CI_REPO_CLONE_SSH_URL": "", "CI_REPO_DEFAULT_BRANCH": "", "CI_REPO_REMOTE_ID": "", "CI_REPO_NAME": "", "CI_REPO_OWNER": "", "CI_REPO_PRIVATE": "false", "CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_URL": "", "CI_STEP_FINISHED": "", "CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_STATUS": "", "CI_STEP_URL": "/repos/0/pipeline/0", "CI_SYSTEM_HOST": "", "CI_SYSTEM_NAME": "woodpecker", @@ -82,11 +82,11 @@ func TestMetadataFromStruct(t *testing.T) { "CI_COMMIT_AUTHOR": "", "CI_COMMIT_AUTHOR_AVATAR": "", "CI_COMMIT_AUTHOR_EMAIL": "", "CI_COMMIT_BRANCH": "", "CI_COMMIT_MESSAGE": "", "CI_COMMIT_PULL_REQUEST": "", "CI_COMMIT_PULL_REQUEST_LABELS": "", "CI_COMMIT_REF": "", "CI_COMMIT_REFSPEC": "", "CI_COMMIT_SHA": "", "CI_COMMIT_SOURCE_BRANCH": "", "CI_COMMIT_TAG": "", "CI_COMMIT_TARGET_BRANCH": "", "CI_COMMIT_URL": "", "CI_FORGE_TYPE": "gitea", "CI_FORGE_URL": "https://gitea.com", - "CI_PIPELINE_CREATED": "0", "CI_PIPELINE_DEPLOY_TARGET": "", "CI_PIPELINE_EVENT": "", "CI_PIPELINE_FINISHED": "0", "CI_PIPELINE_FILES": `["test.go","markdown file.md"]`, + "CI_PIPELINE_CREATED": "0", "CI_PIPELINE_DEPLOY_TARGET": "", "CI_PIPELINE_DEPLOY_TASK": "", "CI_PIPELINE_EVENT": "", "CI_PIPELINE_FINISHED": "0", "CI_PIPELINE_FILES": `["test.go","markdown file.md"]`, "CI_PIPELINE_NUMBER": "3", "CI_PIPELINE_PARENT": "0", "CI_PIPELINE_STARTED": "0", "CI_PIPELINE_STATUS": "", "CI_PIPELINE_URL": "https://example.com/repos/0/pipeline/3", "CI_PIPELINE_FORGE_URL": "", "CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "", "CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0", - "CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "2", "CI_PREV_PIPELINE_PARENT": "0", + "CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_DEPLOY_TASK": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "2", "CI_PREV_PIPELINE_PARENT": "0", "CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "https://example.com/repos/0/pipeline/2", "CI_PREV_PIPELINE_FORGE_URL": "", "CI_REPO": "testUser/testRepo", "CI_REPO_CLONE_URL": "https://gitea.com/testUser/testRepo.git", "CI_REPO_CLONE_SSH_URL": "git@gitea.com:testUser/testRepo.git", "CI_REPO_DEFAULT_BRANCH": "main", "CI_REPO_NAME": "testRepo", "CI_REPO_OWNER": "testUser", "CI_REPO_PRIVATE": "true", "CI_REPO_REMOTE_ID": "", "CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_URL": "https://gitea.com/testUser/testRepo", "CI_STEP_FINISHED": "", From a26a823757e33f0e899fd5db9f62c281c3d97aab Mon Sep 17 00:00:00 2001 From: Fernando Barbosa Date: Wed, 20 Mar 2024 14:44:16 -0300 Subject: [PATCH 2/8] fix: run generate-swagger --- cmd/server/docs/docs.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 6c1d65c4eee..16b37214906 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -3916,6 +3916,9 @@ const docTemplate = `{ "created_at": { "type": "integer" }, + "deploy_task": { + "type": "string" + }, "deploy_to": { "type": "string" }, From aab5e301ba0ecd7885b0253ff4c45e857739430e Mon Sep 17 00:00:00 2001 From: Fernando Barbosa Date: Sat, 6 Apr 2024 12:04:01 -0300 Subject: [PATCH 3/8] Add "deployment task" in the deployment ui --- web/src/assets/locales/en.json | 1 + web/src/assets/locales/es.json | 1 + web/src/assets/locales/fr.json | 1 + web/src/assets/locales/pt.json | 1 + web/src/components/layout/popups/DeployPipelinePopup.vue | 6 +++++- web/src/lib/api/index.ts | 4 +++- 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/web/src/assets/locales/en.json b/web/src/assets/locales/en.json index 159120e5c31..c49c4657007 100644 --- a/web/src/assets/locales/en.json +++ b/web/src/assets/locales/en.json @@ -48,6 +48,7 @@ "deploy_pipeline": { "title": "Trigger deployment event for current pipeline #{pipelineId}", "enter_target": "Target deployment environment", + "enter_task": "Deployment task", "trigger": "Deploy", "variables": { "delete": "Delete variable", diff --git a/web/src/assets/locales/es.json b/web/src/assets/locales/es.json index 75c7a624656..9b3641c0582 100644 --- a/web/src/assets/locales/es.json +++ b/web/src/assets/locales/es.json @@ -185,6 +185,7 @@ "branches": "Ramas", "deploy_pipeline": { "enter_target": "Entorno de despliegue de destino", + "enter_task": "Tarea de despliegue", "title": "Iniciar despliegue para el pipeline actual #{pipelineId}", "trigger": "Despliegue", "variables": { diff --git a/web/src/assets/locales/fr.json b/web/src/assets/locales/fr.json index 014fc1ffe44..d6c72b63fa9 100644 --- a/web/src/assets/locales/fr.json +++ b/web/src/assets/locales/fr.json @@ -187,6 +187,7 @@ "branches": "Branches", "deploy_pipeline": { "enter_target": "Environnement de déploiement ciblé", + "enter_task": "Tâche de déploiement", "title": "Déclenchement d'un événement de déploiement pour le pipeline courant #{pipelineId}", "trigger": "Déployer", "variables": { diff --git a/web/src/assets/locales/pt.json b/web/src/assets/locales/pt.json index fd623882ccb..b5a094359e6 100644 --- a/web/src/assets/locales/pt.json +++ b/web/src/assets/locales/pt.json @@ -27,6 +27,7 @@ }, "title": "Acionar o evento de implantação para o pipeline atual #{pipelineId}", "enter_target": "Ambiente de implantação de destino", + "enter_task": "Tarefa de implantação", "trigger": "Implementar" }, "enable": { diff --git a/web/src/components/layout/popups/DeployPipelinePopup.vue b/web/src/components/layout/popups/DeployPipelinePopup.vue index 57b88cd9d1a..9a4eefea700 100644 --- a/web/src/components/layout/popups/DeployPipelinePopup.vue +++ b/web/src/components/layout/popups/DeployPipelinePopup.vue @@ -8,6 +8,9 @@ + + + {{ $t('repo.deploy_pipeline.variables.desc') }}
@@ -69,9 +72,10 @@ const repo = inject('repo'); const router = useRouter(); -const payload = ref<{ id: string; environment: string; variables: { name: string; value: string }[] }>({ +const payload = ref<{ id: string; environment: string; task: string; variables: { name: string; value: string }[] }>({ id: '', environment: '', + task: '', variables: [ { name: '', diff --git a/web/src/lib/api/index.ts b/web/src/lib/api/index.ts index 819056cdd60..38e8d8c6056 100644 --- a/web/src/lib/api/index.ts +++ b/web/src/lib/api/index.ts @@ -31,6 +31,7 @@ type PipelineOptions = { type DeploymentOptions = { id: string; environment: string; + task: string; variables: Record; }; @@ -82,12 +83,13 @@ export default class WoodpeckerClient extends ApiClient { } // Deploy triggers a deployment for an existing pipeline using the - // specified target environment. + // specified target environment and task. deployPipeline(repoId: number, pipelineNumber: string, options: DeploymentOptions): Promise { const vars = { ...options.variables, event: 'deployment', deploy_to: options.environment, + deploy_task: options.task, }; const query = encodeQueryString(vars); return this._post(`/api/repos/${repoId}/pipelines/${pipelineNumber}?${query}`) as Promise; From 9c42156d84aab48749b16a02010f177145cdb30e Mon Sep 17 00:00:00 2001 From: Fernando Barbosa Date: Mon, 8 Apr 2024 16:28:31 -0300 Subject: [PATCH 4/8] remove localization changes --- web/src/assets/locales/es.json | 1 - web/src/assets/locales/fr.json | 1 - web/src/assets/locales/pt.json | 1 - 3 files changed, 3 deletions(-) diff --git a/web/src/assets/locales/es.json b/web/src/assets/locales/es.json index 9b3641c0582..75c7a624656 100644 --- a/web/src/assets/locales/es.json +++ b/web/src/assets/locales/es.json @@ -185,7 +185,6 @@ "branches": "Ramas", "deploy_pipeline": { "enter_target": "Entorno de despliegue de destino", - "enter_task": "Tarea de despliegue", "title": "Iniciar despliegue para el pipeline actual #{pipelineId}", "trigger": "Despliegue", "variables": { diff --git a/web/src/assets/locales/fr.json b/web/src/assets/locales/fr.json index d6c72b63fa9..014fc1ffe44 100644 --- a/web/src/assets/locales/fr.json +++ b/web/src/assets/locales/fr.json @@ -187,7 +187,6 @@ "branches": "Branches", "deploy_pipeline": { "enter_target": "Environnement de déploiement ciblé", - "enter_task": "Tâche de déploiement", "title": "Déclenchement d'un événement de déploiement pour le pipeline courant #{pipelineId}", "trigger": "Déployer", "variables": { diff --git a/web/src/assets/locales/pt.json b/web/src/assets/locales/pt.json index b5a094359e6..fd623882ccb 100644 --- a/web/src/assets/locales/pt.json +++ b/web/src/assets/locales/pt.json @@ -27,7 +27,6 @@ }, "title": "Acionar o evento de implantação para o pipeline atual #{pipelineId}", "enter_target": "Ambiente de implantação de destino", - "enter_task": "Tarefa de implantação", "trigger": "Implementar" }, "enable": { From 33b4358aca4ec468adab59f8a3391cc59640ccf2 Mon Sep 17 00:00:00 2001 From: Fernando Barbosa Date: Tue, 9 Apr 2024 19:14:34 -0300 Subject: [PATCH 5/8] Update pipeline/frontend/yaml/linter/schema/schema.json Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com> --- pipeline/frontend/yaml/linter/schema/schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline/frontend/yaml/linter/schema/schema.json b/pipeline/frontend/yaml/linter/schema/schema.json index 34f6ccdedbe..b5233b99e9b 100644 --- a/pipeline/frontend/yaml/linter/schema/schema.json +++ b/pipeline/frontend/yaml/linter/schema/schema.json @@ -443,7 +443,7 @@ "$ref": "#/definitions/constraint_list" }, "task": { - "description": "Execute a step only for a specific task. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax#task", + "description": "Execute a step only for a specific task. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#task", "$ref": "#/definitions/constraint_list" }, "matrix": { From fde0be19111d41241f80fedc0780a7b45a4b0a90 Mon Sep 17 00:00:00 2001 From: Fernando Barbosa Date: Tue, 9 Apr 2024 19:14:41 -0300 Subject: [PATCH 6/8] Update pipeline/frontend/yaml/linter/schema/schema.json Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com> --- pipeline/frontend/yaml/linter/schema/schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline/frontend/yaml/linter/schema/schema.json b/pipeline/frontend/yaml/linter/schema/schema.json index b5233b99e9b..d2042880af5 100644 --- a/pipeline/frontend/yaml/linter/schema/schema.json +++ b/pipeline/frontend/yaml/linter/schema/schema.json @@ -256,7 +256,7 @@ "$ref": "#/definitions/constraint_list" }, "task": { - "description": "Execute a step only for a specific task. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax#task", + "description": "Execute a step only for a specific task. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#task", "$ref": "#/definitions/constraint_list" }, "instance": { From c14c43d12484009dc3f4c8a71f79757f2929ed5b Mon Sep 17 00:00:00 2001 From: Fernando Barbosa Date: Wed, 1 May 2024 16:35:47 -0300 Subject: [PATCH 7/8] fix: remove task pipeline support --- .../version-2.1/20-usage/20-workflow-syntax.md | 11 ----------- pipeline/frontend/yaml/constraint/constraint.go | 2 -- .../yaml/linter/schema/.woodpecker/test-when.yaml | 1 - pipeline/frontend/yaml/linter/schema/schema.json | 4 ---- server/pipeline/stepbuilder/metadata.go | 1 - 5 files changed, 19 deletions(-) diff --git a/docs/versioned_docs/version-2.1/20-usage/20-workflow-syntax.md b/docs/versioned_docs/version-2.1/20-usage/20-workflow-syntax.md index 773519aed01..9efee6fbf2e 100644 --- a/docs/versioned_docs/version-2.1/20-usage/20-workflow-syntax.md +++ b/docs/versioned_docs/version-2.1/20-usage/20-workflow-syntax.md @@ -803,17 +803,6 @@ when: event: deployment ``` -### `task` - -Execute a step for deployment events matching the target deployment task: - -```diff -when: - task: migration - event: deployment -``` - - ### `instance` Execute a step only on a certain Woodpecker instance matching the specified hostname: diff --git a/pipeline/frontend/yaml/constraint/constraint.go b/pipeline/frontend/yaml/constraint/constraint.go index 1ad5268f7c9..1d08ecb0961 100644 --- a/pipeline/frontend/yaml/constraint/constraint.go +++ b/pipeline/frontend/yaml/constraint/constraint.go @@ -42,7 +42,6 @@ type ( Instance List Platform List Environment List - Task List Branch List Cron List Status List @@ -165,7 +164,6 @@ 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.Task.Match(m.Curr.Task) && c.Event.Match(m.Curr.Event) && c.Repo.Match(path.Join(m.Repo.Owner, m.Repo.Name)) && c.Ref.Match(m.Curr.Commit.Ref) && diff --git a/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml b/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml index cef810e65bb..86798928578 100644 --- a/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml +++ b/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml @@ -76,7 +76,6 @@ steps: - echo "test" when: environment: production - task: migration event: deployment when-matrix: diff --git a/pipeline/frontend/yaml/linter/schema/schema.json b/pipeline/frontend/yaml/linter/schema/schema.json index d2042880af5..03771787785 100644 --- a/pipeline/frontend/yaml/linter/schema/schema.json +++ b/pipeline/frontend/yaml/linter/schema/schema.json @@ -255,10 +255,6 @@ "description": "Execute a step only for a specific environment. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#environment", "$ref": "#/definitions/constraint_list" }, - "task": { - "description": "Execute a step only for a specific task. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#task", - "$ref": "#/definitions/constraint_list" - }, "instance": { "description": "Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#instance", "$ref": "#/definitions/constraint_list" diff --git a/server/pipeline/stepbuilder/metadata.go b/server/pipeline/stepbuilder/metadata.go index 61d2b79c295..2e2a3c106c4 100644 --- a/server/pipeline/stepbuilder/metadata.go +++ b/server/pipeline/stepbuilder/metadata.go @@ -116,7 +116,6 @@ func metadataPipelineFromModelPipeline(pipeline *model.Pipeline, includeParent b Event: string(pipeline.Event), ForgeURL: pipeline.ForgeURL, Target: pipeline.Deploy, - Task: pipeline.DeployTask, Commit: metadata.Commit{ Sha: pipeline.Commit, Ref: pipeline.Ref, From eed78b4a85cefa5ecbab005d837a065a7a9053ed Mon Sep 17 00:00:00 2001 From: Fernando Barbosa Date: Thu, 2 May 2024 11:20:14 -0300 Subject: [PATCH 8/8] Update pipeline/frontend/yaml/linter/schema/schema.json Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com> --- pipeline/frontend/yaml/linter/schema/schema.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pipeline/frontend/yaml/linter/schema/schema.json b/pipeline/frontend/yaml/linter/schema/schema.json index 03771787785..13d7af690ec 100644 --- a/pipeline/frontend/yaml/linter/schema/schema.json +++ b/pipeline/frontend/yaml/linter/schema/schema.json @@ -438,10 +438,6 @@ "description": "Execute a step only for a specific environment. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#environment", "$ref": "#/definitions/constraint_list" }, - "task": { - "description": "Execute a step only for a specific task. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#task", - "$ref": "#/definitions/constraint_list" - }, "matrix": { "description": "Read more: https://woodpecker-ci.org/docs/usage/matrix-workflows", "type": "object",