Forum Discussion

tvklovesu's avatar
tvklovesu
Frequent Contributor
2 years ago
Solved

how to get the testcomplete actiononerror status in jenkins pipeline

Hello, I have tests running in jenkins pipeline and I have the following script to run the test and send the email at the end of the test. But I want to make the email sent with condition where if t...
  • KB1's avatar
    2 years ago

     

    It looks like you are getting a ClassCastException error when running your Jenkins pipeline. This error is caused by an issue with the error step you have added to your script.

    The error step expects a string argument that specifies the error message to be displayed. However, in your script, you are passing a closure (i.e., the code block inside the error step) as the error message. This is causing the ClassCastException error.

    To fix this issue, you need to remove the code block inside the error step and pass a string argument as the error message instead. Here's an example of how you can do this:

     

     
    node("windows") {
      git credentialsId: 'GitHub-clientid', url: 'https://github.xxx.com/ea-e2e-test.git', branch: 'master'
      withVault(configuration: [timeout: 60, vaultCredentialId: 'credensid', vaultUrl: 'https://vault.xxx.com'],
      vaultSecrets: [[engineVersion: 1, path: 'secret/cloudbees/platforms/testing',
      secretValues: [[envVar: 'USERNAME', vaultKey: 'username'], [envVar: 'PASSWORD', vaultKey: 'password']]]]) {
              testcompletetest commandLineArguments: "/run /psv:env=pro /psv:username=${USERNAME} /psv:password=${PASSWORD}", generateMHT: true, launchType: 'lcProject', actionOnErrors: 'MAKE_FAILED', project: 'TestProject_EAProd', suite: 'TestProject_EA.pjs'
      }
      // Use the error step to check if the previous stage has failed
      error 'Test failed. Sending email notification.'
      emailext (
        subject: 'EA Smoke test results in Prod',
        body: 'Please click below to access the test results \n' + env.BUILD_URL+'/TestComplete/',
        to: 'abc@gmail.com',
        from: 'donotreply@cloudbees.xxx.com')
    }

    This script will still check whether the previous stage has failed and send the email notification if it has. However, it will not throw the ClassCastException error anymore.

    I hope this helps! Let me know if you have any questions.