Unverified Commit f6f9973b authored by Scott Hain's avatar Scott Hain Committed by GitHub
Browse files

Merge pull request #805 from aojea/issue#481

Use BUILD_TIMESTAMP instead of BUILD_ID
parents cf894175 493438e4
...@@ -124,12 +124,21 @@ module Omnibus ...@@ -124,12 +124,21 @@ module Omnibus
build_tag build_tag
end end
# We'll attempt to retrive the timestamp from the Jenkin's set BUILD_ID # We'll attempt to retrieve the timestamp from the Jenkin's set BUILD_TIMESTAMP
# environment variable. This will ensure platform specfic packages for the # or fall back to BUILD_ID environment variable. This will ensure platform specfic
# same build will share the same timestamp. # packages for the same build will share the same timestamp.
def build_start_time def build_start_time
@build_start_time ||= begin @build_start_time ||= begin
if ENV["BUILD_ID"] if ENV["BUILD_TIMESTAMP"]
begin
Time.strptime(ENV["BUILD_TIMESTAMP"], "%Y-%m-%d_%H-%M-%S")
rescue ArgumentError
error_message = "BUILD_TIMESTAMP environment variable "
error_message << "should be in YYYY-MM-DD_hh-mm-ss "
error_message << "format."
raise ArgumentError, error_message
end
elsif ENV["BUILD_ID"]
begin begin
Time.strptime(ENV["BUILD_ID"], "%Y-%m-%d_%H-%M-%S") Time.strptime(ENV["BUILD_ID"], "%Y-%m-%d_%H-%M-%S")
rescue ArgumentError rescue ArgumentError
......
...@@ -112,7 +112,17 @@ module Omnibus ...@@ -112,7 +112,17 @@ module Omnibus
expect(build_version.semver).to match(/11.0.0-alpha1\+#{today_string}[0-9]+.git.207.694b062/) expect(build_version.semver).to match(/11.0.0-alpha1\+#{today_string}[0-9]+.git.207.694b062/)
end end
it "uses ENV['BUILD_ID'] to generate timestamp if set" do it "uses ENV['BUILD_TIMESTAMP'] to generate timestamp if set" do
stub_env("BUILD_TIMESTAMP", "2012-12-25_16-41-40")
expect(build_version.semver).to eq("11.0.0-alpha1+20121225164140.git.207.694b062")
end
it "fails on invalid ENV['BUILD_TIMESTAMP'] values" do
stub_env("BUILD_TIMESTAMP", "AAAA")
expect { build_version.semver }.to raise_error(ArgumentError)
end
it "uses ENV['BUILD_ID'] to generate timestamp if set and BUILD_TIMESTAMP is not set" do
stub_env("BUILD_ID", "2012-12-25_16-41-40") stub_env("BUILD_ID", "2012-12-25_16-41-40")
expect(build_version.semver).to eq("11.0.0-alpha1+20121225164140.git.207.694b062") expect(build_version.semver).to eq("11.0.0-alpha1+20121225164140.git.207.694b062")
end end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment