Sha256: 1138e28ae30996798b73af8454d3c61b5fe01af93abb8198478eab2cfcfc1e4e

Contents?: true

Size: 965 Bytes

Versions: 10

Compression:

Stored size: 965 Bytes

Contents

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

        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(&block)
            return unless block_given?

            begin
              original_path = ENV['PATH']

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

              block.call
            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

10 entries across 10 versions & 1 rubygems

Version Path
rake-funnel-0.18.0 lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.17.0 lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.16.1 lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.16.0 lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.15.0.pre lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.14.0.pre lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.13.0.pre lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.12.0.pre lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.11.0.pre lib/rake/funnel/integration/teamcity/teamcity.rb
rake-funnel-0.10.0.pre lib/rake/funnel/integration/teamcity/teamcity.rb