@@ -78,11 +78,13 @@ const supportFileCleanup = () => {
78
78
} ) ;
79
79
}
80
80
81
- exports . printBuildLink = async ( ) => {
81
+ exports . printBuildLink = async ( shouldStopSession , exitCode = null ) => {
82
82
if ( ! this . isTestObservabilitySession ( ) ) return ;
83
83
try {
84
- supportFileCleanup ( ) ;
85
- await this . stopBuildUpstream ( ) ;
84
+ if ( shouldStopSession ) {
85
+ supportFileCleanup ( ) ;
86
+ await this . stopBuildUpstream ( ) ;
87
+ }
86
88
try {
87
89
if ( process . env . BS_TESTOPS_BUILD_HASHED_ID
88
90
&& process . env . BS_TESTOPS_BUILD_HASHED_ID != "null"
@@ -96,6 +98,7 @@ exports.printBuildLink = async () => {
96
98
} catch ( err ) {
97
99
exports . debug ( `Error while stopping build with error : ${ err } ` , true , err ) ;
98
100
}
101
+ if ( exitCode ) process . exit ( exitCode ) ;
99
102
}
100
103
101
104
const nodeRequest = ( type , url , data , config ) => {
@@ -748,16 +751,28 @@ exports.isTestObservabilitySupportedCypressVersion = (cypress_config_filename) =
748
751
exports . setTestObservabilityFlags = ( bsConfig ) => {
749
752
/* testObservability */
750
753
let isTestObservabilitySession = true ;
751
- if ( ! utils . isUndefined ( bsConfig [ "testObservability" ] ) ) isTestObservabilitySession = ( bsConfig [ "testObservability" ] == true || bsConfig [ "testObservability" ] == 1 ) ;
752
- if ( ! utils . isUndefined ( process . env . BROWSERSTACK_TEST_OBSERVABILITY ) ) isTestObservabilitySession = ( process . env . BROWSERSTACK_TEST_OBSERVABILITY == "true" || process . env . BROWSERSTACK_TEST_OBSERVABILITY == "1" ) ;
753
- if ( process . argv . includes ( '--disable-test-observability' ) ) isTestObservabilitySession = false ;
754
- isTestObservabilitySession = isTestObservabilitySession && this . isTestObservabilitySupportedCypressVersion ( bsConfig . run_settings . cypress_config_file ) ;
754
+ try {
755
+ if ( ! utils . isUndefined ( bsConfig [ "testObservability" ] ) ) isTestObservabilitySession = ( bsConfig [ "testObservability" ] == true || bsConfig [ "testObservability" ] == 1 ) ;
756
+ if ( ! utils . isUndefined ( process . env . BROWSERSTACK_TEST_OBSERVABILITY ) ) isTestObservabilitySession = ( process . env . BROWSERSTACK_TEST_OBSERVABILITY == "true" || process . env . BROWSERSTACK_TEST_OBSERVABILITY == "1" ) ;
757
+ if ( process . argv . includes ( '--disable-test-observability' ) ) isTestObservabilitySession = false ;
758
+ isTestObservabilitySession = isTestObservabilitySession && this . isTestObservabilitySupportedCypressVersion ( bsConfig . run_settings . cypress_config_file ) ;
759
+ } catch ( e ) {
760
+ isTestObservabilitySession = false ;
761
+ exports . debug ( `EXCEPTION while parsing testObservability capability with error ${ e } ` ) ;
762
+ }
763
+
755
764
756
765
/* browserstackAutomation */
757
766
let isBrowserstackInfra = true ;
758
- if ( ! utils . isUndefined ( bsConfig [ "browserstackAutomation" ] ) ) isBrowserstackInfra = ( bsConfig [ "browserstackAutomation" ] == true || bsConfig [ "browserstackAutomation" ] == 1 ) ;
759
- if ( ! utils . isUndefined ( process . env . BROWSERSTACK_AUTOMATION ) ) isBrowserstackInfra = ( process . env . BROWSERSTACK_AUTOMATION == "true" || process . env . BROWSERSTACK_AUTOMATION == "1" ) ;
760
- if ( process . argv . includes ( '--disable-browserstack-automation' ) ) isBrowserstackInfra = false ;
767
+ try {
768
+ if ( ! utils . isUndefined ( bsConfig [ "browserstackAutomation" ] ) ) isBrowserstackInfra = ( bsConfig [ "browserstackAutomation" ] == true || bsConfig [ "browserstackAutomation" ] == 1 ) ;
769
+ if ( ! utils . isUndefined ( process . env . BROWSERSTACK_AUTOMATION ) ) isBrowserstackInfra = ( process . env . BROWSERSTACK_AUTOMATION == "true" || process . env . BROWSERSTACK_AUTOMATION == "1" ) ;
770
+ if ( process . argv . includes ( '--disable-browserstack-automation' ) ) isBrowserstackInfra = false ;
771
+ } catch ( e ) {
772
+ isBrowserstackInfra = true ;
773
+ exports . debug ( `EXCEPTION while parsing browserstackAutomation capability with error ${ e } ` ) ;
774
+ }
775
+
761
776
762
777
process . env . BROWSERSTACK_TEST_OBSERVABILITY = isTestObservabilitySession ;
763
778
process . env . BROWSERSTACK_AUTOMATION = isBrowserstackInfra ;
@@ -961,7 +976,7 @@ exports.runCypressTestsLocally = (bsConfig, args, rawArgs) => {
961
976
) ;
962
977
cypressProcess . on ( 'close' , async ( code ) => {
963
978
logger . info ( `Cypress process exited with code ${ code } ` ) ;
964
- await this . printBuildLink ( ) ;
979
+ await this . printBuildLink ( true ) ;
965
980
} ) ;
966
981
967
982
cypressProcess . on ( 'error' , ( err ) => {
0 commit comments