Sha256: 5c32a15d16c54d6ac8c4aaa6330f4e902ae4638d304b559c2b82a2386eb01271

Contents?: true

Size: 1.04 KB

Versions: 9

Compression:

Stored size: 1.04 KB

Contents

module Pantograph
  class JUnitGenerator
    def self.generate(results)
      # JUnit file documentation: http://llg.cubic.org/docs/junit/
      # And http://nelsonwells.net/2012/09/how-jenkins-ci-parses-and-displays-junit-output/
      # And http://windyroad.com.au/dl/Open%20Source/JUnit.xsd

      containing_folder = ENV['FL_REPORT_PATH'] || PantographCore::PantographFolder.path || Dir.pwd
      path = File.join(containing_folder, 'report.xml')

      @steps = results
      xml_path = File.join(Pantograph::ROOT, "lib/assets/report_template.xml.erb")
      xml = ERB.new(File.read(xml_path)).result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system

      xml = xml.gsub('system_', 'system-').delete("\e") # Jenkins can not parse 'ESC' symbol

      begin
        File.write(path, xml)
      rescue => ex
        UI.error(ex)
        UI.error("Couldn't save report.xml at path '#{File.expand_path(path)}', make sure you have write access to the containing directory.")
      end

      return path
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pantograph-0.1.12 pantograph/lib/pantograph/junit_generator.rb
pantograph-0.1.10 pantograph/lib/pantograph/junit_generator.rb
pantograph-0.1.8 pantograph/lib/pantograph/junit_generator.rb
pantograph-0.1.7 pantograph/lib/pantograph/junit_generator.rb
pantograph-0.1.6 pantograph/lib/pantograph/junit_generator.rb
pantograph-0.1.4 pantograph/lib/pantograph/junit_generator.rb
pantograph-0.1.3 pantograph/lib/pantograph/junit_generator.rb
pantograph-0.1.1 pantograph/lib/pantograph/junit_generator.rb
pantograph-0.1.0 pantograph/lib/pantograph/junit_generator.rb