jenkins pipeline after run unit test karma script do not stop jenkins pipeline after run unit test karma script do not stop jenkins jenkins

jenkins pipeline after run unit test karma script do not stop


I assume that karma was watching for changes which is nice for development machines but not good for CI builds. If you want to avoid changing the karma config, you can pass --watch false as parameter to ng test. (Although you have singleRun: true I am not sure whether autoWatch: true will have higher priority.)

I suggest you use the docker container to execute the complete build instead of single docker-run commands.Jenkins provides a nice abstraction to run commands inside a docker container:

docker.image('trion/ng-cli-karma').inside {        stage ('load npm dependencies') {            echo 'Load npm dependencies'            sh 'npm install'        }        stage ('build') {            echo "building"            sh 'npm run build'        }        stage ('unit test') {          sh 'ng test --progress false --watch false'          echo 'generate test report **/dist/test-reports/*.xml'          junit allowEmptyResults: false, testResults: '**/test-results.xml'          echo 'end test & coverage'        }   ...


I fixed the problem, before in my Jenkinsfile, i used the command sh('ng test') to run test without to know exatly what's happen in background.

So i used directly the karma command

sh ('./node_modules/karma/bin/karma start karma.conf.js')