From bc0ac472397084e48d51796b152fbc30ae69a1c2 Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Mon, 1 Oct 2018 08:57:18 -0700 Subject: [PATCH] remove commit_range env var since it is expensive and unused reverts https://github.com/zendesk/samson/pull/2225 --- app/models/job_execution.rb | 19 ++++++++----------- test/models/job_execution_test.rb | 1 - 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/models/job_execution.rb b/app/models/job_execution.rb index 14deb38cda..e3a863393b 100644 --- a/app/models/job_execution.rb +++ b/app/models/job_execution.rb @@ -84,13 +84,7 @@ def descriptor def base_commands(dir, env = {}) artifact_cache_dir = File.join(@job.project.repository.repo_cache_dir, "artifacts") FileUtils.mkdir_p(artifact_cache_dir) - - env = { - PROJECT_NAME: @job.project.name, - PROJECT_PERMALINK: @job.project.permalink, - PROJECT_REPOSITORY: @job.project.repository_url, - CACHE_DIR: artifact_cache_dir - }.merge(env) + env[:CACHE_DIR] = artifact_cache_dir commands = env.map do |key, value| "export #{key}=#{value.to_s.shellescape}" @@ -214,13 +208,16 @@ def commands(dir) REFERENCE: @reference, REVISION: @job.commit, TAG: (@job.tag || @job.commit) - }.merge(@env) + }.merge!(@env) env.merge!(make_builds_available) if stage&.builds_in_environment - if deploy = @job.deploy - env[:COMMIT_RANGE] = deploy.changeset.commit_range - end + # for shared notification scripts + env.merge!( + PROJECT_NAME: @job.project.name, + PROJECT_PERMALINK: @job.project.permalink, + PROJECT_REPOSITORY: @job.project.repository_url + ) env.merge!(Hash[*Samson::Hooks.fire(:job_additional_vars, @job).compact]) diff --git a/test/models/job_execution_test.rb b/test/models/job_execution_test.rb index 1c96316690..80b1626cfe 100644 --- a/test/models/job_execution_test.rb +++ b/test/models/job_execution_test.rb @@ -157,7 +157,6 @@ def last_line_of_output lines.must_include "[04:05:06] DEPLOYER_NAME=John Doe" lines.must_include "[04:05:06] REFERENCE=master" lines.must_include "[04:05:06] REVISION=#{job.commit}" - lines.must_include "[04:05:06] COMMIT_RANGE=#{job.commit}...#{job.commit}" lines.must_include "[04:05:06] TAG=v1" lines.must_include "[04:05:06] FOO=bar" end