mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 11:51:02 +00:00
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
This commit is contained in:
parent
5dc9de870b
commit
ce5247c675
3 changed files with 12 additions and 5 deletions
|
@ -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.
|
- 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_ARCH => use CI_SYSTEM_ARCH
|
||||||
- CI_COMMIT => CI_COMMIT_SHA
|
- 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_REMOTE_URL => use CI_REPO_REMOTE
|
||||||
- CI_REPO_BRANCH => use CI_REPO_DEFAULT_BRANCH
|
- CI_REPO_BRANCH => use CI_REPO_DEFAULT_BRANCH
|
||||||
- CI_PARENT_BUILD_NUMBER => use CI_BUILD_PARENT
|
- CI_PARENT_BUILD_NUMBER => use CI_BUILD_PARENT
|
||||||
|
|
|
@ -141,8 +141,8 @@ func (m *Metadata) Environ() map[string]string {
|
||||||
"CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name,
|
"CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name,
|
||||||
"CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email,
|
"CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email,
|
||||||
"CI_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar,
|
"CI_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar,
|
||||||
"CI_TAG": "", // will be set if event is tag
|
"CI_COMMIT_TAG": "", // will be set if event is tag
|
||||||
"CI_PULL_REQUEST": "", // will be set if event is pr
|
"CI_COMMIT_PULL_REQUEST": "", // will be set if event is pr
|
||||||
|
|
||||||
"CI_BUILD_NUMBER": strconv.FormatInt(m.Curr.Number, 10),
|
"CI_BUILD_NUMBER": strconv.FormatInt(m.Curr.Number, 10),
|
||||||
"CI_BUILD_PARENT": strconv.FormatInt(m.Curr.Parent, 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_ARCH": m.Sys.Arch,
|
||||||
"CI_SYSTEM_VERSION": version.Version,
|
"CI_SYSTEM_VERSION": version.Version,
|
||||||
|
|
||||||
|
// TODO drop for v0.16.0 development
|
||||||
// DEPRECATED
|
// DEPRECATED
|
||||||
"CI_ARCH": m.Sys.Arch, // use CI_SYSTEM_ARCH
|
"CI_ARCH": m.Sys.Arch, // use CI_SYSTEM_ARCH
|
||||||
"CI_COMMIT": m.Curr.Commit.Sha, // use CI_COMMIT_SHA
|
"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_BRANCH": m.Curr.Commit.Branch, // use CI_COMMIT_BRANCH
|
||||||
"CI_SOURCE_BRANCH": sourceBranch, // use CI_COMMIT_SOURCE_BRANCH
|
"CI_SOURCE_BRANCH": sourceBranch, // use CI_COMMIT_SOURCE_BRANCH
|
||||||
"CI_TARGET_BRANCH": targetBranch, // use CI_COMMIT_TARGET_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 {
|
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 {
|
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
|
return params
|
||||||
|
|
|
@ -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 {
|
for _, cc := range c.Containers {
|
||||||
if cc.Settings == nil && cc.Vargs != nil {
|
if cc.Settings == nil && cc.Vargs != nil {
|
||||||
cc.Settings = make(map[string]interface{})
|
cc.Settings = make(map[string]interface{})
|
||||||
|
|
Loading…
Reference in a new issue