class Assemblyline::CLI::Env
Public Instance Methods
to_flags()
click to toggle source
# File lib/assemblyline/cli.rb, line 89 def to_flags to_hash.map { |var, val| "-e #{var}=#{val}" }.join(" ") end
to_hash()
click to toggle source
# File lib/assemblyline/cli.rb, line 93 def to_hash { "SSH_KEY" => ssh_key, "DOCKERCFG" => dockercfg, "JSPM_GITHUB_TOKEN" => ENV["JSPM_GITHUB_TOKEN"], "CI" => ci?, "CI_MASTER" => ci_master?, "BUILD_URL" => build_url, "GIT_URL" => git_url, "GITHUB_ACCESS_TOKEN" => ENV["GITHUB_ACCESS_TOKEN"], }.reject { |_, v| v.nil? } end
Private Instance Methods
build_url()
click to toggle source
# File lib/assemblyline/cli.rb, line 144 def build_url ENV["BUILD_URL"] end
ci?()
click to toggle source
# File lib/assemblyline/cli.rb, line 132 def ci? %w(CI CONTINUOUS_INTEGRATION TDDIUM TRAVIS BUILD_ID JENKINS_URL CIRCLECI).each do |var| return true if ENV[var] end nil end
ci_master?()
click to toggle source
# File lib/assemblyline/cli.rb, line 139 def ci_master? return true if ENV["GIT_BRANCH"] == "origin/master" return true if ENV["CI_MASTER"] end
dockercfg()
click to toggle source
# File lib/assemblyline/cli.rb, line 121 def dockercfg cfg = ENV["DOCKERCFG"] [".dockercfg", ".docker/config.json"].each do |cfg_path| path = File.join(Dir.home, cfg_path) next unless File.exist? path cfg ||= File.read(path) end return unless cfg cfg.gsub("\n", "").gsub("\t", "").dump end
git_url()
click to toggle source
# File lib/assemblyline/cli.rb, line 148 def git_url u = `git ls-remote --get-url origin`.chomp u.empty? ? nil : u end
key_path()
click to toggle source
# File lib/assemblyline/cli.rb, line 113 def key_path %w(id_rsa id_dsa).map { |private_key| ssh_key_path(private_key) }.detect { |path| File.exist? path } end
ssh_key()
click to toggle source
# File lib/assemblyline/cli.rb, line 108 def ssh_key key = File.read(key_path) if key_path key.dump if key end
ssh_key_path(key)
click to toggle source
# File lib/assemblyline/cli.rb, line 117 def ssh_key_path(key) File.join(ENV["HOME"], ".ssh/#{key}") end