How to read the error code in console output from Jenkins pipeline script
Hello,
I have configured my jenkins pipeline with Declarative pipeline script as shown below. Currently I am able to send the emails when the build is unstable. But there are some other situations where the build fails due to testExecute launch error on the remote machine. And even for that failure it is sending emails to everyone in the recipient list. I want to check if the error code is -1 then send the email only to selected emails list else send to everyone.
pipeline{
agent {label "windows"}
stages {
stage('Test complete'){
steps {
Step1
}
}
}
post{
unstable {
// echo "This will run when test unstable"
emailext (
subject: "EA smoke test results in Prod",
body: "Please click below to access the test results \n" + env.BUILD_URL+"TestComplete/",
to: "vinod@xxx.com",
from: "donotreply@cloudbees.com")
}
}
}
console output with the error exit code to read in the above pipeline script and if that's true then send the emails to only selected people.
[TestComplete] Test runner exit code: -1.
[TestComplete] [WARNING] Error: The user did not log in using the SmartBear account or did not pass the accesskey in the command-line arguments. TestComplete will be closed.The user did not log in using the SmartBear account or did not pass the accesskey in the command-line arguments. TestComplete will be closed..
[TestComplete] [WARNING] Unable to find the log file "1677263408853.tclogx".
[TestComplete] [WARNING] Unable to find the log file "1677263408853.htmlx".
[TestComplete] [WARNING] Unable to find the log file "1677263408853.mht".
[TestComplete] [WARNING] Errors occurred during the test execution.
[TestComplete] Marking the build as UNSTABLE.
[TestComplete] [WARNING] Unable to publish test results (xml data is empty).
[TestComplete] The test execution finished (Prod_SmokeTest/CORE_Prod_Smoke).