mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 10:07:21 +02:00
fix: update CI_COMMIT_BRANCH
value to source branch in PRs
This commit is contained in:
parent
2e490f3c7b
commit
bfbfd5c867
@ -17,6 +17,7 @@ This will be the next version of Woodpecker.
|
||||
- `CI_PIPELINE_FINISHED` as empty during execution
|
||||
- `CI_PIPELINE_STATUS` was always `success`
|
||||
- `CI_STEP_STATUS` was always `success`
|
||||
- `CI_COMMIT_BRANCH` now always returns the source branch, even for pull requests (previously it returned the target branch)
|
||||
- Set `/woodpecker` as default workdir for the **woodpecker-cli** container
|
||||
- Secret filters for plugins now check against tag if specified
|
||||
- Compatibility mode of deprecated `pipeline:`, `platform:` and `branches:` pipeline config options are now removed and pipeline will now fail if still in use.
|
||||
|
@ -87,11 +87,12 @@ func (m *Metadata) Environ() map[string]string {
|
||||
// CI_STEP_STARTED will be set by agent
|
||||
|
||||
commit := pipeline.Commit
|
||||
sourceBranch, targetBranch := getSourceTargetBranches(commit.Refspec)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_SHA", commit.Sha)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_REF", commit.Ref)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_REFSPEC", commit.Refspec)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_MESSAGE", commit.Message)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_BRANCH", commit.Branch)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_BRANCH", sourceBranch)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_AUTHOR", commit.Author.Name)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_AUTHOR_EMAIL", commit.Author.Email)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_AUTHOR_AVATAR", commit.Author.Avatar)
|
||||
@ -102,7 +103,6 @@ func (m *Metadata) Environ() map[string]string {
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_PRERELEASE", strconv.FormatBool(pipeline.Commit.IsPrerelease))
|
||||
}
|
||||
if pipeline.Event == EventPull || pipeline.Event == EventPullClosed {
|
||||
sourceBranch, targetBranch := getSourceTargetBranches(commit.Refspec)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_SOURCE_BRANCH", sourceBranch)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_TARGET_BRANCH", targetBranch)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_PULL_REQUEST", pullRegexp.FindString(pipeline.Commit.Ref))
|
||||
@ -137,16 +137,16 @@ func (m *Metadata) Environ() map[string]string {
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_FINISHED", strconv.FormatInt(prevPipeline.Finished, 10))
|
||||
|
||||
prevCommit := prevPipeline.Commit
|
||||
prevSourceBranch, prevTargetBranch := getSourceTargetBranches(prevCommit.Refspec)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_SHA", prevCommit.Sha)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_REF", prevCommit.Ref)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_REFSPEC", prevCommit.Refspec)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_MESSAGE", prevCommit.Message)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_BRANCH", prevCommit.Branch)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_BRANCH", prevSourceBranch)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR", prevCommit.Author.Name)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR_EMAIL", prevCommit.Author.Email)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR_AVATAR", prevCommit.Author.Avatar)
|
||||
if prevPipeline.Event == EventPull || prevPipeline.Event == EventPullClosed {
|
||||
prevSourceBranch, prevTargetBranch := getSourceTargetBranches(prevCommit.Refspec)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_SOURCE_BRANCH", prevSourceBranch)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_TARGET_BRANCH", prevTargetBranch)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user