Class: Testcube::BuildEnv
- Inherits:
-
Object
- Object
- Testcube::BuildEnv
- Defined in:
- lib/testcube/build_env.rb
Class Method Summary collapse
-
.branch ⇒ Object
TODO: Add support for other CI systems.
- .build_url ⇒ Object
- .current ⇒ Object
- .git(cmd) ⇒ Object
- .git_show ⇒ Object
Class Method Details
.branch ⇒ Object
TODO: Add support for other CI systems
18 19 20 |
# File 'lib/testcube/build_env.rb', line 18 def self.branch ENV['BUILDKITE_BRANCH'] || git('rev-parse --abbrev-ref HEAD') end |
.build_url ⇒ Object
22 23 24 |
# File 'lib/testcube/build_env.rb', line 22 def self.build_url ENV['BUILDKITE_BUILD_URL'] end |
.current ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/testcube/build_env.rb', line 3 def self.current sha, , , = git_show # TODO master fork sha # TODO could also get some of this data from github api { sha: sha, author: , author_email: , commit_message: , branch: branch, build_url: build_url, } end |
.git(cmd) ⇒ Object
39 40 41 42 43 |
# File 'lib/testcube/build_env.rb', line 39 def self.git(cmd) `git #{cmd}`.strip rescue Errno::ENOENT nil end |
.git_show ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/testcube/build_env.rb', line 26 def self.git_show out = git('show --format=short --no-patch') return [nil, nil, nil, nil] if !out # TODO: dont rescue nil sha = out.match(/commit ([0-9a-f]+)\n/)[1] rescue nil = out.match(/Author: (.*?) <(.*)>\n/)[1] rescue nil = out.match(/Author: (.*?) <(.*)>\n/)[2] rescue nil = out.lines[2..(out.lines.length)].find { |l| l.strip.length > 0 }.strip rescue nil return [sha, , , ] end |