Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Junit formatter prevents Jenkins picking up results on success #3744

Closed
arch-daemone opened this issue Feb 27, 2018 · 6 comments · Fixed by #4566
Closed

Junit formatter prevents Jenkins picking up results on success #3744

arch-daemone opened this issue Feb 27, 2018 · 6 comments · Fixed by #4566

Comments

@arch-daemone
Copy link

arch-daemone commented Feb 27, 2018

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!

@mastermatt
Copy link
Contributor

#3838 would pave the way for this.

@Rycochet
Copy link

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'
      }
    }
  }
}

@spikyjt
Copy link

spikyjt commented Dec 11, 2018

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 GenoLogics-OpenSource/tslint-junit-formatter#8

@LekoArts
Copy link

LekoArts commented Mar 5, 2019

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

@darrena092
Copy link
Contributor

Just added #4566 - that should fix the problem.

@LekoArts
Copy link

Thanks!

@adidahiya adidahiya added this to the 5.14.0 milestone Mar 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants