Integrate Polymer test build process into Jenkins CI/CD pipeline

544 views Asked by At

I want to integrate our Polymer test build process into Jenkins CI/CD pipeline using polymer-cli. I want to automate this steps to build our web-components test cases. At the moment, I am doing this manually by executing "polymer test" on the terminal. I also want the automated process to provide the reports that indicate failed test cases. Please provide step if you have implemented this in your CI/CD pipeline.

1

There are 1 answers

0
schlm3 On

We have the following working setup for this case, using Jenkins2 Pipelines:

node{        
....
  stage('build'){
    testresult = bat returnStatus: true, script: 'polymer test --plugin xunit-reporter -l chrome'
    step([$class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '5', failureThreshold: '10', unstableNewThreshold: '2', unstableThreshold: '5'], [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']], tools: [[$class: 'XUnitDotNetTestType', deleteOutputFiles: true, failIfNotNew: true, pattern: 'TEST-wct.xml', skipNoTestFiles: false, stopProcessingIfError: true]]])

    if (testresult != 0) {
      currentBuild.result =  "UNSTABLE"
      echo "ALERT: Some Unittests failed, see log above."
    }
  }
....
}

The testresult is written by the wct-plugin https://github.com/garcus/wct-xunit-reporter to "/TEST-wct.xml". The XUnit Builder step is configured as such, that it picks that file up and creates the testresult page. You can lookup the syntax for that in the Jenkins Pipeline syntax help page.

See also How to display the XUnit test output on Jenkins and JUnit formatted test output