From 6fe8d0bfb574bee719320248c078fc08ad789d2c Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 1 Jul 2026 23:39:38 +0200 Subject: [PATCH] Rename CI_COMMIT_PRERELEASE to CI_PIPELINE_RELEASE_PRE (#6794) --- cli/exec/flags.go | 6 ++++-- docs/docs/20-usage/50-environment.md | 3 ++- docs/src/pages/migrations.md | 1 + pipeline/frontend/metadata/environment.go | 3 +++ pipeline/frontend/metadata/environment_test.go | 3 ++- pipeline/frontend/yaml/linter/linter.go | 1 + pipeline/frontend/yaml/linter/linter_test.go | 9 +++++---- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cli/exec/flags.go b/cli/exec/flags.go index 452c8c887..b1c562d33 100644 --- a/cli/exec/flags.go +++ b/cli/exec/flags.go @@ -328,9 +328,11 @@ var flags = []cli.Flag{ Usage: "Set the metadata environment variable \"CI_COMMIT_PULL_REQUEST_DRAFT\".", }, &cli.BoolFlag{ - Sources: cli.EnvVars("CI_COMMIT_PRERELEASE"), + // CI_COMMIT_PRERELEASE is kept as a deprecated alias. + // TODO remove CI_COMMIT_PRERELEASE in next major + Sources: cli.EnvVars("CI_PIPELINE_RELEASE_PRE", "CI_COMMIT_PRERELEASE"), Name: "commit-release-is-pre", - Usage: "Set the metadata environment variable \"CI_COMMIT_PRERELEASE\".", + Usage: "Set the metadata environment variable \"CI_PIPELINE_RELEASE_PRE\".", }, &cli.Int64Flag{ Sources: cli.EnvVars("CI_PREV_PIPELINE_NUMBER"), diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index fb085f38d..2c2daf330 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -80,7 +80,7 @@ This is the reference list of all environment variables available to your pipeli | `CI_COMMIT_TIMESTAMP` | commit UNIX timestamp | `1722617519` | | `CI_COMMIT_AUTHOR` | commit author username | `john-doe` | | `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | `john-doe@example.com` | -| `CI_COMMIT_PRERELEASE` | release is a pre-release (empty if event is not `release`) | `false` | +| `CI_COMMIT_PRERELEASE` | release is a pre-release (empty if event is not `release`) — **deprecated**, use `CI_PIPELINE_RELEASE_PRE` | `false` | | | **Current pipeline** | | | `CI_PIPELINE_NUMBER` | pipeline number | `8` | | `CI_PIPELINE_PARENT` | number of parent pipeline | `0` | @@ -92,6 +92,7 @@ This is the reference list of all environment variables available to your pipeli | `CI_PIPELINE_DEPLOY_TARGET` | pipeline deploy target for `deployment` events | `production` | | `CI_PIPELINE_DEPLOY_TASK` | pipeline deploy task for `deployment` events | `migration` | | `CI_PIPELINE_RELEASE_TITLE` | release title (empty if event is not `release`) | `v1.10.3` | +| `CI_PIPELINE_RELEASE_PRE` | release is a pre-release (empty if event is not `release`) | `false` | | `CI_PIPELINE_CREATED` | pipeline created UNIX timestamp | `1722617519` | | `CI_PIPELINE_STARTED` | pipeline started UNIX timestamp | `1722617519` | | `CI_PIPELINE_FILES` | changed files (empty if event is not `push` or `pull_request`), it is undefined if more than 500 files are touched | `[]`, `[".woodpecker.yml","README.md"]` | diff --git a/docs/src/pages/migrations.md b/docs/src/pages/migrations.md index 65110bf8f..b52273cc9 100644 --- a/docs/src/pages/migrations.md +++ b/docs/src/pages/migrations.md @@ -10,6 +10,7 @@ To enhance the usability of Woodpecker and meet evolving security standards, occ - (Kubernetes) Deprecated `step` label on pod in favor of new namespaced label `woodpecker-ci.org/step`. The `step` label will be removed in a future update. - deprecated `CI_COMMIT_AUTHOR_AVATAR` and `CI_PREV_COMMIT_AUTHOR_AVATAR` env vars in favor of `CI_PIPELINE_AVATAR` and `CI_PREV_PIPELINE_AVATAR` +- deprecated `CI_COMMIT_PRERELEASE` env var in favor of `CI_PIPELINE_RELEASE_PRE` - deprecated `runs_on` workflow property in favor of `when.status`. ### API changes diff --git a/pipeline/frontend/metadata/environment.go b/pipeline/frontend/metadata/environment.go index 5343f646a..94d8fbe33 100644 --- a/pipeline/frontend/metadata/environment.go +++ b/pipeline/frontend/metadata/environment.go @@ -105,6 +105,9 @@ func (m *Metadata) Environ() map[string]string { } if pipeline.Event == EventRelease { setNonEmptyEnvVar(params, "CI_PIPELINE_RELEASE_TITLE", pipeline.Release.Title) + setNonEmptyEnvVar(params, "CI_PIPELINE_RELEASE_PRE", strconv.FormatBool(pipeline.Release.IsPrerelease)) + // Deprecated: use CI_PIPELINE_RELEASE_PRE instead. + // TODO remove in next major setNonEmptyEnvVar(params, "CI_COMMIT_PRERELEASE", strconv.FormatBool(pipeline.Release.IsPrerelease)) } if pipeline.Event.IsPull() { diff --git a/pipeline/frontend/metadata/environment_test.go b/pipeline/frontend/metadata/environment_test.go index 5c378ff1e..882a912c6 100644 --- a/pipeline/frontend/metadata/environment_test.go +++ b/pipeline/frontend/metadata/environment_test.go @@ -48,7 +48,8 @@ func TestEnviron(t *testing.T) { assert.Equal(t, "release", envs["CI_PIPELINE_EVENT"]) assert.Equal(t, "pull_request_metadata", envs["CI_PREV_PIPELINE_EVENT"]) assert.Equal(t, "v1.2.3", envs["CI_PIPELINE_RELEASE_TITLE"]) - assert.Equal(t, "true", envs["CI_COMMIT_PRERELEASE"]) + assert.Equal(t, "true", envs["CI_PIPELINE_RELEASE_PRE"]) + assert.Equal(t, "true", envs["CI_COMMIT_PRERELEASE"]) // deprecated alias assert.Equal(t, "branch-a", envs["CI_PREV_COMMIT_SOURCE_BRANCH"]) assert.Equal(t, "branch-b", envs["CI_PREV_COMMIT_TARGET_BRANCH"]) assert.Equal(t, "[]", envs["CI_PIPELINE_FILES"]) diff --git a/pipeline/frontend/yaml/linter/linter.go b/pipeline/frontend/yaml/linter/linter.go index de0bac313..013540397 100644 --- a/pipeline/frontend/yaml/linter/linter.go +++ b/pipeline/frontend/yaml/linter/linter.go @@ -359,6 +359,7 @@ var deprecatedEnvVars = []struct { replacement string re *regexp.Regexp }{ + {"CI_COMMIT_PRERELEASE", "CI_PIPELINE_RELEASE_PRE", deprecatedEnvVarRefRegexp("CI_COMMIT_PRERELEASE")}, {"CI_COMMIT_AUTHOR_AVATAR", "CI_PIPELINE_AVATAR", deprecatedEnvVarRefRegexp("CI_COMMIT_AUTHOR_AVATAR")}, {"CI_PREV_COMMIT_AUTHOR_AVATAR", "CI_PREV_PIPELINE_AVATAR", deprecatedEnvVarRefRegexp("CI_PREV_COMMIT_AUTHOR_AVATAR")}, } diff --git a/pipeline/frontend/yaml/linter/linter_test.go b/pipeline/frontend/yaml/linter/linter_test.go index f7baaa5de..d35f34bbd 100644 --- a/pipeline/frontend/yaml/linter/linter_test.go +++ b/pipeline/frontend/yaml/linter/linter_test.go @@ -216,15 +216,16 @@ func TestDeprecations(t *testing.T) { from string want string // empty = expect no deprecation warning }{ - {from: `steps: { build: { image: golang, commands: ["echo $CI_COMMIT_AUTHOR_AVATAR"] } }`, want: "Usage of `CI_COMMIT_AUTHOR_AVATAR` is deprecated, use `CI_PIPELINE_AVATAR`"}, - {from: `steps: { build: { image: golang, commands: ["echo $$CI_COMMIT_AUTHOR_AVATAR"] } }`, want: "Usage of `CI_COMMIT_AUTHOR_AVATAR` is deprecated, use `CI_PIPELINE_AVATAR`"}, + {from: `steps: { build: { image: golang, commands: ["echo $CI_COMMIT_PRERELEASE"] } }`, want: "Usage of `CI_COMMIT_PRERELEASE` is deprecated, use `CI_PIPELINE_RELEASE_PRE`"}, + {from: `steps: { build: { image: golang, commands: ["echo $$CI_COMMIT_PRERELEASE"] } }`, want: "Usage of `CI_COMMIT_PRERELEASE` is deprecated, use `CI_PIPELINE_RELEASE_PRE`"}, + {from: `steps: { build: { image: golang, commands: ["echo ${CI_COMMIT_PRERELEASE}"] } }`, want: "Usage of `CI_COMMIT_PRERELEASE` is deprecated, use `CI_PIPELINE_RELEASE_PRE`"}, {from: `steps: { build: { image: golang, commands: ["echo ${CI_COMMIT_AUTHOR_AVATAR}"] } }`, want: "Usage of `CI_COMMIT_AUTHOR_AVATAR` is deprecated, use `CI_PIPELINE_AVATAR`"}, {from: `steps: { build: { image: golang, commands: ["echo $CI_PREV_COMMIT_AUTHOR_AVATAR"] } }`, want: "Usage of `CI_PREV_COMMIT_AUTHOR_AVATAR` is deprecated, use `CI_PREV_PIPELINE_AVATAR`"}, // new names must not warn + {from: `steps: { build: { image: golang, commands: ["echo $CI_PIPELINE_RELEASE_PRE"] } }`, want: ""}, {from: `steps: { build: { image: golang, commands: ["echo $CI_PIPELINE_AVATAR"] } }`, want: ""}, - {from: `steps: { build: { image: golang, commands: ["echo $CI_PREV_PIPELINE_AVATAR"] } }`, want: ""}, // must not match a longer var name - {from: `steps: { build: { image: golang, commands: ["echo $CI_COMMIT_AUTHOR_AVATAR_FOO"] } }`, want: ""}, + {from: `steps: { build: { image: golang, commands: ["echo $CI_COMMIT_PRERELEASE_FOO"] } }`, want: ""}, // CI_COMMIT_AUTHOR_AVATAR regexp must not fire on CI_PREV_COMMIT_AUTHOR_AVATAR only {from: `steps: { build: { image: golang, commands: ["echo $CI_PREV_COMMIT_AUTHOR_AVATAR"] } }`, want: "Usage of `CI_PREV_COMMIT_AUTHOR_AVATAR` is deprecated, use `CI_PREV_PIPELINE_AVATAR`"}, }