Ask a Question

how to get the testcomplete actiononerror status in jenkins pipeline

SOLVED
tvklovesu
Frequent Contributor

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 the actionOnError = Make_Failed then send the email

 

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'
    }

// here I need to check that actionOnErrors value and if its only when failed then send the email. 

  if (actionOnErrors=='MAKE_FAILED'){

    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')
   }

}

 

TIA

11 REPLIES 11
KB1
Frequent Contributor

Sorry I had some problems myself fixing this haha,
But this should work I did some testing with this script.

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 message: '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')
}

 

tvklovesu
Frequent Contributor

Thanks for your reply. I looked at some forums online and as mentioned in the cloudbees documentation, I changed my pipeline script similar to this one in this URL and it is working fine.

https://docs.cloudbees.com/docs/admin-resources/latest/automating-with-jenkinsfile/using-multiple-ag....

 

cancel
Showing results for 
Search instead for 
Did you mean: