Sha256: 1ea4e34e8a7d55acfd5f07cc8c24ffee4f6a1bff3c093d20be67c6a35e0965f6
Contents?: true
Size: 1.8 KB
Versions: 8
Compression:
Stored size: 1.8 KB
Contents
# frozen_string_literal: true module FastCI class Configuration attr_accessor :run_key, :build_id, :commit_msg, :commit, :branch, :api_url, :secret_key, :author, :fastci_main_url, :fastci_api_url, :orig_build_id def initialize # Settings defaults self.run_key = nil self.build_id = guess_build_id self.commit = guess_commit self.commit_msg = `git log -1 --pretty=%B`.chomp self.branch = guess_branch self.api_url = ENV["FAST_CI_API_URL"] || "apx.fast.ci" self.secret_key = ENV.fetch("FAST_CI_SECRET_KEY") self.author = guess_author self.fastci_main_url = ENV.fetch('FASTCI_MAIN_URL', 'https://events.ruby.ci') self.fastci_api_url = ENV.fetch('FASTCI_API_RB_URL', 'https://ruby.fast.ci') self.orig_build_id = ENV['FSCI_ORIG_BUILD_ID'] end def reset initialize end def run_key @run_key || raise("#run_key was not configured.") end def guess_author author_Line = `git show | grep Author:` name, email = author_Line.scan(/Author: (.*) <(.*)>/).first { name: name, email: email } end def guess_build_id %w[FSCI_BUILD_ID GITHUB_RUN_ID BUILD_ID CIRCLE_BUILD_NUM].find do |keyword| key = ENV.keys.find { |k| k[keyword] } break ENV[key] if key && ENV[key] end || guess_commit end def guess_commit %w[FSCI_COMMIT _COMMIT _SHA1 _SHA].find do |keyword| key = ENV.keys.find { |k| k[keyword] } break ENV[key] if key && ENV[key] end || `git rev-parse HEAD`.chomp end def guess_branch %w[FSCI_BRANCH _BRANCH _REF].find do |keyword| key = ENV.keys.find { |k| k[keyword] } break ENV[key] if key && ENV[key] end || `git rev-parse --abbrev-ref HEAD`.chomp end end end
Version data entries
8 entries across 8 versions & 1 rubygems