Exit code reporting of stepchain job failures to MONIT requires improvement
**Impact of the bug**
Monitoring

**Describe the bug**
When a stepchain job fails, different cmsRuns generate different exit codes. While one of these exit codes indicate the real error, the others indicate that the particular cmsRun couldn't run because the previous one failed. Our MONIT dashboards use ` Chirp_WMCore_cmsRun_ExitCode, ExitCode` classAds to demonstrate the error and in many cases, these fields don't include the main exit code, but rather the `Skipping this step due to a failure in a previous one. (Exit Code: 99108)`


**How to reproduce it**

Please check this JSON file to see an example. 
```
"Chirp_WMCore_cmsRun3_ExitCode": 8021,
```
is the main problem whereas `Chirp_WMCore_cmsRun_ExitCode`, `Chirp_WMCore_cmsRun[4-6]_ExitCode` and `ExitCode` shows `99108`. 

[99108.json.zip](https://github.com/dmwm/WMCore/files/9839338/99108.json.zip)

**Expected behavior**
IMO, MONIT dashboards should use `ExitCode` for exit code monitoring (`Chirp_WMCore_cmsRun_ExitCode` has precedence over `ExitCode`, don't know why) and the agent should report the real exit code in this classAd, not 99108. 

It's also possible to implement this logic in MONIT, but I don't think it's the proper way to do it. IMO, this info should be propagated from central services.

**Additional context and error message**
None

diff --git a/src/python/WMCore/WMSpec/Steps/Executors/CMSSW.py b/src/python/WMCore/WMSpec/Steps/Executors/CMSSW.py
index 2e4d045fc..17aeebeef 100644
--- a/src/python/WMCore/WMSpec/Steps/Executors/CMSSW.py
+++ b/src/python/WMCore/WMSpec/Steps/Executors/CMSSW.py
@@ -50,14 +50,18 @@ class CMSSW(Executor):
         self.failedPreviousStep = None
 
     def _setStatus(self, returnCode, returnMessage):
-        """
-        Set return code.
-        """
-        self.setCondorChirpAttrDelayed('Chirp_WMCore_cmsRun_ExitCode', returnCode)
+        """Chirp Job/step exit code through HTCondor"""
+        # we will set Chirp_WMCore_cmsRun_ExitCode codes only if previous step was clean
+        if not self.failedPreviousStep:
+            self.setCondorChirpAttrDelayed('Chirp_WMCore_cmsRun_ExitCode', returnCode)
+            logging.info("Step %s: Chirp_WMCore_cmsRun_ExitCode %s", self.stepName, returnCode)
+            if returnMessage and returnCode != 0:
+                self.setCondorChirpAttrDelayed('Chirp_WMCore_cmsRun_Exception_Message', returnMessage, compress=True)
         self.setCondorChirpAttrDelayed('Chirp_WMCore_%s_ExitCode' % self.stepName, returnCode)
+        logging.info("Step %s: Chirp_WMCore_%s_ExitCode %s", self.stepName, self.stepName, returnCode)
         if returnMessage and returnCode != 0:
-            self.setCondorChirpAttrDelayed('Chirp_WMCore_cmsRun_Exception_Message', returnMessage, compress=True)
             self.setCondorChirpAttrDelayed('Chirp_WMCore_%s_Exception_Message' % self.stepName, returnMessage, compress=True)
+
         self.step.execution.exitStatus = returnCode
 
     def pre(self, emulator=None):
['src/python/WMCore/WMSpec/Steps/Executors/CMSSW.py']