Sha256: e1495a27ddfda077df4f3a7629691e69bfa4dd30aed3d02d1c4f698962cc23ad

Contents?: true

Size: 999 Bytes

Versions: 3

Compression:

Stored size: 999 Bytes

Contents

# frozen_string_literal: true

module Rake
  module Funnel
    module Integration
      module TeamCity
        PROJECT_ENV_VAR = 'TEAMCITY_PROJECT_NAME'.freeze
        JRE_ENV_VAR = 'TEAMCITY_JRE'.freeze

        class << self
          def running?
            ENV.include?(PROJECT_ENV_VAR)
          end

          def rake_runner?
            running? && Object.const_defined?('Rake') && Rake.const_defined?('TeamCityApplication')
          end

          def with_java_runtime
            return unless block_given?

            begin
              original_path = ENV['PATH']

              ENV['PATH'] = ([] << ENV['PATH'] << teamcity_jre).compact.join(File::PATH_SEPARATOR)

              yield
            ensure
              ENV['PATH'] = original_path
            end
          end

          private

          def teamcity_jre
            return nil unless ENV.include?(JRE_ENV_VAR)

            File.join(ENV[JRE_ENV_VAR], 'bin')
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rake-funnel-0.24.0 lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.23.0 lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.22.3 lib/rake/funnel/integration/teamcity/teamcity.rb