Skip to content

Commit

Permalink
Init CI_COMMIT_TAG if commit ref is a tag (#2934)
Browse files Browse the repository at this point in the history
When triggering a deployment event on an existing pipeline, there is no
way to get the tag used to trigger the parent pipeline, even if this
parent was a tag event.

In our company CI/CD current setup with drone, we use the tag event to
trigger a kaniko image build step, using the git tag as an image tag,
and the deployment/promotion step to effectively deploy this image using
the tag reference in our cluster. This is the only point blocking us to
completely switch to woodpecker and get rid of drone...

What's done:
- changed the metadata environ() method to populate CI_COMMIT_TAG env
var if commit ref starts with /refs/tags (like it's done in drone),
independently of event type EventTag.

Please let me know if I'm wrong, I will happily contribute in this nice
project.

---------

Co-authored-by: Christian Gapany <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2023
1 parent b3541e3 commit 547f5de
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pipeline/frontend/metadata/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (m *Metadata) Environ() map[string]string {
// TODO Deprecated, remove in 3.x
"CI_COMMIT_URL": m.Curr.ForgeURL,
}
if m.Curr.Event == EventTag {
if m.Curr.Event == EventTag || strings.HasPrefix(m.Curr.Commit.Ref, "refs/tags/") {
params["CI_COMMIT_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/")
}
if m.Curr.Event == EventPull {
Expand Down

0 comments on commit 547f5de

Please sign in to comment.