Does anyone know if the MSTest plugin supports pipelines and how to use it in a pipeline (jenkinsfile)?

1,259 views
Skip to first unread message

red 888

unread,
Aug 15, 2017, 11:12:47 AM8/15/17
to Jenkins Users
I have my test runner configured and its generating a trx file, now I want to use the MSTest plugin to read it: https://wiki.jenkins.io/display/JENKINS/MSTest+Plugin

But I don't know how to refer to it in a pipeline (Jenkinsfile). Does this plugin support jenkinsfile? Is there a way to use plugins in a jenkinsfile even if they don't support it explicitly?

Slide

unread,
Aug 15, 2017, 11:24:18 AM8/15/17
to Jenkins Users
From looking at the source, it doesn't look like you can use mstest in pipeline right now. It doesn't implement SimpleBuildStep, so it relies on AbstractBuild, which is not what pipeline jobs use as a base class for a build. 

On Tue, Aug 15, 2017 at 8:12 AM red 888 <fakemai...@gmail.com> wrote:
I have my test runner configured and its generating a trx file, now I want to use the MSTest plugin to read it: https://wiki.jenkins.io/display/JENKINS/MSTest+Plugin

But I don't know how to refer to it in a pipeline (Jenkinsfile). Does this plugin support jenkinsfile? Is there a way to use plugins in a jenkinsfile even if they don't support it explicitly?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/beb7b643-6da5-4e72-9771-da860fbb8f34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

red 888

unread,
Aug 15, 2017, 11:56:33 AM8/15/17
to Jenkins Users
Is there a way I could refer to the plugin directly via a bat command? Is there any way to call it directly even if it doesn't implement the pipeline methods? aren't plugin just groovy scripts?

Slide

unread,
Aug 15, 2017, 12:03:48 PM8/15/17
to Jenkins Users
No, you can't really use the plugin via a bat file, you'd need to just run mstest directly. You can't use the plugin in pipeline if it doesn't support it. The issue is that the pipeline calls the "perform" method that matches a specific signature, there is no "perform" method in the mstest plugin that has that signature, only one that takes incorrect parameters for legacy projects (freestyle and friends). Someone would need to update the plugin to support pipeline.

jer...@bodycad.com

unread,
Aug 16, 2017, 8:24:13 AM8/16/17
to Jenkins Users
Sadly no, many puglin are still incompatible, you can see the compatibility list here: 

Since the .trx is just an xml file, you could try to do an .xslt file that do the convertion to junit .xml. Maybe someone already did it somewhere, worth googling, I known some people have done .trx to .html graph (which you could use and publish the html results too).

Daniel Butler

unread,
Aug 16, 2017, 8:31:39 AM8/16/17
to jenkins...@googlegroups.com

The XUnit plugin has support for MSTest output and is pipeline compatible.

You’d still need to run MSTest from a bat/powershell command but the Xunit plugin will publish the test output.

--

You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

red 888

unread,
Aug 17, 2017, 9:49:34 PM8/17/17
to Jenkins Users
Yes the xunit plugin is great! thats what I'm using now. As you say I still use an MS test runner exe which generates a trx and then point the xunit plugin to that report and it does everything else.

Ivo Bellin Salarin

unread,
Aug 19, 2017, 6:20:55 AM8/19/17
to Jenkins Users

Is it sufficient to inherit from SimpleBuildStep to enable the pipeline? Should I expose attributes via some kind of decorator?
Where to find the documentation about that?

There's some code that waits for being released. It could be a good opportunity to deliver also the pipeline, if I get to know which changes it involves.


Ivo Bellin Salarin

unread,
Aug 19, 2017, 6:28:06 AM8/19/17
to Jenkins Users

BTW, is there anybody to test a alpha version of the plugin? (With the pipeline enabled?)

Ivo Bellin Salarin

unread,
Aug 19, 2017, 9:25:47 AM8/19/17
to Jenkins Users
If anyone tests the plugin present on this website: http://nilleb.com/pub/mstest-0.20-snapshot/
I will release it the next friday.

Have a good day,
Ivo

Ivo Bellin Salarin

unread,
Aug 19, 2017, 9:32:13 AM8/19/17
to Jenkins Users
Please accept this as the changelog of the current test binary :-)
- this version completely disables the emma coverage report...
- ...keeping the transformation steps which convert the MS coverage reports into emma-compatible coverage reports.
- and tries to expose the MsTestPublisher as a SimpleBuildStep (in order to use it from pipeline workflows)

Slide

unread,
Aug 19, 2017, 2:21:18 PM8/19/17
to Jenkins Users
SimpleBuildStep is one part, you'll want to change your perform method to override the one that takes a Run<?,?>, FilePath, TaskListener and Launcher (note, this overload does NOT return a true/false for build result, you need to set the result on the Run object using setResult). You don't need to override both, you can just override the one that I mention and it will work for both pipeline and freestyle. You'll also want to add an @Symbol annotation to your descriptor so that people can use a shorthand when using mstest from pipeline. I'd recommend something like @Symbol("mstest"). You may need to add a dependency on the structs plugin for the @Symbol to be available.

Ivo Bellin Salarin

unread,
Aug 20, 2017, 4:39:18 AM8/20/17
to Jenkins Users

Great! Thanks a lot Slide, I'll add the @Symbol this afternoon (and I think that I have implemented the right method yesterday, hooray 😁)


Ivo Bellin Salarin

unread,
Aug 20, 2017, 1:11:55 PM8/20/17
to Jenkins Users

The hpi present at the address http://nilleb.com/pub/mstest-0.20-snapshot/
Exposes the mstest plugin to a pipeline (jenkinsfile) with the "mstest" symbol.

I have linted a little a part of the plugin code, as described in the pipeline devguide. I will eventually continue on the next days. The lint doesn't alter the plugin behavior.

For the ones using the xUnit plugin, I have opened a pull request on that plugin repository in order to update the mstest-to-junit XSL (because the one included with that plugin still contained some bugs fixed in 2015).

Many thanks to the testers, if any, and have a good day.

Slide

unread,
Aug 20, 2017, 3:45:42 PM8/20/17
to Jenkins Users

This is great. Just so you are aware, you can release snapshots and they will show up in the experimental plugin site, but then you don't have to host the hpi on your own server, it's available on the jenkins infra. Just make the release version have alpha or beta or something in the version number for the release.


Daniel Beck

unread,
Aug 25, 2017, 3:19:04 AM8/25/17
to jenkins...@googlegroups.com

> On 20. Aug 2017, at 21:45, Slide <slide...@gmail.com> wrote:
>
> Just so you are aware, you can release snapshots and they will show up in the experimental plugin site

To clarify, these aren't snapshots, just releases with a magic version number (containing 'alpha' or 'beta').

Reply all
Reply to author
Forward
0 new messages