Menu

How to fail a jekins job if a scenario failed

Help
Michal
2014-03-20
2014-03-20
  • Michal

    Michal - 2014-03-20

    Hi,

    I have a jenkins job that runs regression scenarios using maven plugin. I want to run a small sanity scenario with one or two tests before starting the regression scenario and if that sanity scenario failed I want to fail the whole job. I want this to run in one single job (it will be another build step) and not split it to two jobs, is there a recommended way to check the sanity scenario status to know if to fail the job?

    Currently I'm parsing the JUnit XML report to see if it has any errors using some windows commands, but is there a better way? maybe there's some env variable that JSystem manages?

    Thanks,
    Michal

     
  • Alex Sigal

    Alex Sigal - 2014-03-20

    There is no need to parse xml, jenkins can do it by itself, just add JUNIT plugin to jenkins

     
  • Michal

    Michal - 2014-03-20

    Hi, thanks for the answer.

    Can you be more specific? Which plugin and how do I use it in the job for my purpose?

     
  • Itai Agmon

    Itai Agmon - 2014-03-20

    Check out the reporting section in the following blog:
    http://jsystem.org/703/

     
  • Michal

    Michal - 2014-03-20

    Yes but this is a post build step so this can run only at the end and it's not what I want. I want in the same job to run one scenario and if it passed run the full regression tests. If it failed I want to fail the job.. unless am missing something..

     
  • Alex Sigal

    Alex Sigal - 2014-03-20

    try downstream project

     
  • Itai Agmon

    Itai Agmon - 2014-03-20

    Oh.. Sorry, didn't read you post carefully enough. I don't think there is a better way. Why don't you want to split it to two jobs and create a downstream as Alex suggested? I think it is more elegant than parsing the XML.

     
  • Michal

    Michal - 2014-03-20

    Well, I've never tried it so could be I am mistaken but I am not sure I can get the requested behavior, lets say the following:

    • Have one job called "sanity" with one scenario to see if basic tests pass
    • Have one job called "regression" with all scenarios that runs only if "sanity" passed
    • I want the "regression" job to be the job that users trigger to run the regression tests and it will run the "sanity" before, is this possible?
    • Do I need in both jobs to take latest sources and compile?
     

Log in to post a comment.