Repository navigation
fix: resolve {sha} in custom image tag to the tag commit for webhook tag builds (#7092) - #7099
Open
prakash100198 wants to merge 1 commit into
Open
prakash100198 wants to merge 1 commit into
prakash100198 wants to merge 1 commit into
Conversation
…tag builds
On tag-creation webhook builds the material has no commit, so {sha} fell
back to the webhook target checkout, which is the tag name for GitHub and
Bitbucket (e.g. release/1.2 became "release_"). Resolve the tag to its
commit through git-sensor when the custom tag pattern uses {sha}. If the
tag cannot be resolved, {sha} stays empty and the existing "commit sha not
found" error fails the trigger instead of producing a misleading tag.
PR-merged events and manual builds are unchanged.
Fixes #7092
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prakash100198
requested review from
prakarsh-dt and
vivek-devtron
as code owners
November 25, 2026 11:46
|
Bito Automatic Review Skipped - Branch Excluded |
|
Some linked issues are invalid. Please update the issue links:\nIssue #7092 in devtron-labs/devtron is not found or invalid (HTTP 403).\n |
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Fixes #7092
Enterprise counterpart (identical diff): https://github.com/devtron-labs/devtron-enterprise/pull/3454
With a custom image tag such as
dev-{sha}-{x}(#7060, #7071), a CI build triggered by a tag creation webhook got the tag name in place of the commit. Pushingrelease/1.2produceddev-release_-<x>, andrelease/1.3gave the samerelease_, so the image could not be traced back to a commit.Cause: webhook builds carry no commit on the material, so
getCommitShaForCustomTagfell back to the webhook'starget checkoutvalue. For tag creation events git-sensor fillstarget checkoutwith the tag name: GitHubref, Bitbucketpush.changes.0.new.name. That value was cut to 8 characters, with/replaced by_.Fix (
pkg/build/trigger/HandlerService.go):target checkoutis resolved to the commit it points to. The lookup uses git-sensorcommit-metadatawithgitTag, which fetches the repo (--tags --force) before resolving.{sha}/{SHA}. Builds without{sha}make no extra git-sensor call.{sha}is empty and the existingcommit sha not found for variable {sha} in image tagerror fails the trigger, instead of the image being tagged with the tag name.Unchanged:
target checkoutischeckout_sha, and GitLab marks them asmerged.{sha}.Known limitation: annotated tags. git-sensor's tag lookup does not peel annotated tags. I checked this by running git-sensor's own
GetCommitsForTagon a repo with one annotated and one lightweight tag:object not foundgit show <tag>prints the tag header before the commitWith this PR, an annotated tag build whose pattern uses
{sha}fails with the missing-sha error above, where today it gets a tag-name based image tag. Making annotated tags resolve needs a small git-sensor change: peel the tag object to its commit (TagObject(...).Commit()in go-git,<tag>^{commit}in the CLI). That will be a separate PR.How Has This Been Tested?
New unit tests in
pkg/build/trigger/HandlerService_customTagSha_test.go:release/1.2): tag resolved,{sha}= first 8 chars of the tag commitrelease/1.2,release/1.3): each gets its own commit{sha}, so the existing missing-sha error fires{sha}, no lookup{sha}pipelineMaterialId+gitTagand handles a git-sensor error and an empty resultcommit-metadataendpoint: request isPOST /commit-metadatawith{"pipelineMaterialId", "gitTag"}; 200 with a commit, 400 not found, and a 200 null result are handled{sha}/{SHA}detection for the lookup guardAll existing tests in
pkg/build/triggergive the same result before and after this change.TestUpdateWorkflowRequestWithBuildxFlagsalready panics ondevelopand is unrelated.These tests ran on the enterprise build, which has the same change and test file. This branch was not compiled locally; the identifiers it uses were checked against this repo.
Checklist:
Does this PR introduce a user-facing change?
🤖 Generated with Claude Code