From ce5247c675da09ed6d4408d20f568ab687699f8f Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 19 Dec 2021 17:01:03 +0100 Subject: [PATCH] pipeline env migrate CI_TAG & CI_PULL_REQUEST to new CI_COMMIT_TAG & CI_COMMIT_PULL_REQUEST (#624) * CI_TAG => CI_COMMIT_TAG * CI_PULL_REQUEST => CI_COMMIT_PULL_REQUEST * add TODO for drop with v0.16.0 development --- docs/docs/91-migrations.md | 2 ++ pipeline/frontend/metadata.go | 13 +++++++++---- pipeline/frontend/yaml/container.go | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/docs/91-migrations.md b/docs/docs/91-migrations.md index c9128b473..dccf462ed 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -29,6 +29,8 @@ Some versions need some changes to the server configuration or the pipeline conf - Some variables got deprecated and will be removed in future versions. Please migrate to the new names. Same applies for `DRONE_` of them. - CI_ARCH => use CI_SYSTEM_ARCH - CI_COMMIT => CI_COMMIT_SHA + - CI_TAG => CI_COMMIT_TAG + - CI_PULL_REQUEST => CI_COMMIT_PULL_REQUEST - CI_REMOTE_URL => use CI_REPO_REMOTE - CI_REPO_BRANCH => use CI_REPO_DEFAULT_BRANCH - CI_PARENT_BUILD_NUMBER => use CI_BUILD_PARENT diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index 6d57c1079..830af5c47 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -141,8 +141,8 @@ func (m *Metadata) Environ() map[string]string { "CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, "CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, "CI_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar, - "CI_TAG": "", // will be set if event is tag - "CI_PULL_REQUEST": "", // will be set if event is pr + "CI_COMMIT_TAG": "", // will be set if event is tag + "CI_COMMIT_PULL_REQUEST": "", // will be set if event is pr "CI_BUILD_NUMBER": strconv.FormatInt(m.Curr.Number, 10), "CI_BUILD_PARENT": strconv.FormatInt(m.Curr.Parent, 10), @@ -185,6 +185,7 @@ func (m *Metadata) Environ() map[string]string { "CI_SYSTEM_ARCH": m.Sys.Arch, "CI_SYSTEM_VERSION": version.Version, + // TODO drop for v0.16.0 development // DEPRECATED "CI_ARCH": m.Sys.Arch, // use CI_SYSTEM_ARCH "CI_COMMIT": m.Curr.Commit.Sha, // use CI_COMMIT_SHA @@ -199,12 +200,16 @@ func (m *Metadata) Environ() map[string]string { "CI_BRANCH": m.Curr.Commit.Branch, // use CI_COMMIT_BRANCH "CI_SOURCE_BRANCH": sourceBranch, // use CI_COMMIT_SOURCE_BRANCH "CI_TARGET_BRANCH": targetBranch, // use CI_COMMIT_TARGET_BRANCH + "CI_TAG": "", // use CI_COMMIT_TAG + "CI_PULL_REQUEST": "", // use CI_COMMIT_PULL_REQUEST } if m.Curr.Event == EventTag { - params["CI_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") + params["CI_COMMIT_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") + params["CI_TAG"] = params["CI_COMMIT_TAG"] } if m.Curr.Event == EventPull { - params["CI_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) + params["CI_COMMIT_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) + params["CI_PULL_REQUEST"] = params["CI_COMMIT_PULL_REQUEST"] } return params diff --git a/pipeline/frontend/yaml/container.go b/pipeline/frontend/yaml/container.go index 180805306..9b30356f0 100644 --- a/pipeline/frontend/yaml/container.go +++ b/pipeline/frontend/yaml/container.go @@ -87,7 +87,7 @@ func (c *Containers) UnmarshalYAML(value *yaml.Node) error { } } - // TODO: drop Vargs in favor of Settings in v1.16.0 release + // TODO drop Vargs in favor of Settings in v0.16.0 release for _, cc := range c.Containers { if cc.Settings == nil && cc.Vargs != nil { cc.Settings = make(map[string]interface{})