script { currentBuild.result = currentBuild.result ?: 'FAILED' }
Am Dienstag, 12. März 2019 23:31:43 UTC+1 schrieb Faad Sayaou: > > thanks for your contribution. Is there any other way of failing of failing > the pipeline when unit test stage is unstable? I have something like the > following in my code to ignore the failed test but I will like to stop the > pipeline and publish unit test result. > > I am currently experiencing a strange effect when using the MStest plugin. > My test report is only generated when the test is successful but when it > fails, no test report is generated. > > node { > > > stage('Checkout') { > cleanWs() > checkout scm > > return > skipRemainingStages = true > } > > > stage('Restore') { > > sh "dotnet restore $proj" > > } > > stage('Build') { > sh "dotnet publish $proj --output $outputFolder --configuration > Release -p:Version=$buildVersion -p:FileVersion=$buildVersion" > > } > stage ('Unit test') { > > sh "dotnet restore $UnitTest" > sh returnStdout: true, script: "dotnet test $UnitTest --logger > \'trx;LogFileName=unit_tests.xml\' || true" > > > step ([$class: 'MSTestPublisher', testResultsFile:"**/*.xml", > failOnError: true, keepLongStdio: true]) > > } > > stage ('publish') { > > } > > } > > > I do not want to publish when the build is unstable. Like I mentioned > earlier. I want to stop the build and publish test result. I tried using > answers suggested above but could not help in my use-case.any idea? > > On Monday, 11 March 2019 14:14:40 UTC+1, Mark Lübbehüsen wrote: >> >> Hi, >> >> its better you send emails in the post action >> >> post { >> always { >> >> } >> success { >> } >> unstable { >> >> >> } >> failure { >> >> } >> aborted { >> } >> } >> >> https://jenkins.io/doc/pipeline/tour/post/ >> >> >> Am Donnerstag, 28. Februar 2019 21:41:50 UTC+1 schrieb Faad Sayaou: >>> >>> Hi everyone >>> I am using the extended email plugin for notification when the build >>> fails by using try catch. I will also like to send email when the build is >>> unstable. Below is the structure of my pipeline >>> >>> node { >>> >>> try >>> { >>> >>> stage('Checkout') { >>> cleanWs() >>> checkout scm >>> >>> } >>> >>> >>> stage('Restore') { >>> >>> sh "dotnet restore $proj" >>> >>> } >>> >>> stage('Build') { >>> sh "dotnet restore $proj" >>> >>> } >>> stage ('Unit test') { >>> >>> sh "dotnet test $test" >>> } >>> } >>> } catch (err) { >>> emailext body: >>> ' ${JOB_NAME} ${BUILD_NUMBER} is failing! Somebody should do >>> something about that. >>> https://jenkins-ma.com/job/Test/${BUILD_NUMBER}/console >>> <https://jenkins-map.1worldsync.com/job/Heinemann_Build_pipeline/$%7BBUILD_NUMBER%7D/console>', >>> subject: 'FAILURE', to: 'someEmail..' >>> } >>> >>> >>> I will like to send not only when the pipeline fails but when the build >>> is unstable. thanks >>> >> -- 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-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/89ce27c6-c3fc-4479-b3f2-8fe707c9ce70%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.