Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sentry-ruby/lib/sentry/release_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class ReleaseDetector
class << self
def detect_release(project_root:, running_on_heroku:)
detect_release_from_env ||
detect_release_from_kamal ||
detect_release_from_git ||
detect_release_from_capistrano(project_root) ||
detect_release_from_heroku(running_on_heroku)
Expand All @@ -31,6 +32,10 @@ def detect_release_from_git
Sentry.sys_command("git rev-parse HEAD") if File.directory?(".git")
end

def detect_release_from_kamal
ENV["KAMAL_VERSION"]
end

def detect_release_from_env
ENV["SENTRY_RELEASE"]
end
Expand Down
9 changes: 9 additions & 0 deletions sentry-ruby/spec/sentry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,15 @@
end
end

it 'uses `KAMAL_VERSION` env variable' do
ENV['KAMAL_VERSION'] = 'GIT_SHA'

described_class.init
expect(described_class.configuration.release).to eq('GIT_SHA')

ENV.delete('KAMAL_VERSION')
end

context "when git is available" do
before do
allow(File).to receive(:directory?).and_return(false)
Expand Down