Tslint: Junit formatter prevents Jenkins picking up results on success

Created on 27 Feb 2018  路  6Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.9.1
  • __TypeScript version__: 2.7.1
  • __Running TSLint via__: CLI

Actual behavior

Running tslint -o lint-results.xml -t junit -p tsconfig.json on a lint-free project results in an xml file with an empty <testsuites> element. While this is acceptable by some consuming tools, others reject it. Unfortunately for me, the latter includes Jenkins. Jenkins hits a non-breaking error trying to consume lint-results.xml, and skips it. Which makes generating the file in the first place pointless.

Before you added the core junit formatter, we could use tslint-junit-formatter, whose [last commit] before then seems to have been a fix for this very issue. But because tslint prioritises its own core formatters over external ones with the same name, this formatter can no longer be used (it's mostly redundant except for that one fix, anyway).

Expected behavior

A single "success" <testsuite> element is generated inside the <testuites>, and Jenkins is able to consume it (as is Bamboo, which has the same problem, according to the referenced tslint-junit-formatter [issue]).

I will say I'm happy to submit a PR for this one, if you'll have me!

Easy Accepting PRs Bug

All 6 comments

https://github.com/palantir/tslint/pull/3838 would pave the way for this.

As a current workaround if running in a pipeline build then it's possible to use this with a try/catch block -

stage("Lint") {
  steps {
    script {
      try {
        sh 'tslint "**/*.ts" --format junit --out jslint-test-results.xml'
      } catch(Exception e) {
        junit 'jslint-test-results.xml'
      }
    }
  }
}

This is the same for Bamboo and probably other CI tools.

tslint-junit-formatter already does this, so it's solution could be used, see:
See https://github.com/GenoLogics-OpenSource/tslint-junit-formatter/issues/8

@DaemonExMachina You still want to create a PR for that? 馃憤

Just added https://github.com/palantir/tslint/pull/4566 - that should fix the problem.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cretz picture cretz  路  3Comments

ghost picture ghost  路  3Comments

denkomanceski picture denkomanceski  路  3Comments

dashmug picture dashmug  路  3Comments

SwintDC picture SwintDC  路  3Comments