@@ -375,6 +375,7 @@ pipeline {
375375
376376 stage(' regressions-11 arm infrastructure' ) {
377377 when {
378+ beforeAgent true
378379 branch ' develop'
379380 expression { return ! params. regressions }
380381 expression { return env. EC2_PRIVATE_IP != null }
@@ -435,24 +436,23 @@ pipeline {
435436 }
436437 }
437438 echo " ✅ Terraform resources destroyed successfully."
439+ // Cleanup Jenkins agent using shared library function
440+ def nodeName = " java-client-agent-${ BUILD_NUMBER} "
441+ echo " 🗑️ Cleaning up Jenkins agent: ${ nodeName} "
442+ try {
443+ def cleanupResult = cleanupJenkinsAgent(nodeName)
444+ echo " ✅ Cleanup result: ${ cleanupResult.status} for node: ${ cleanupResult.nodeName} "
445+ } catch (Exception jenkinsCleanupException) {
446+ echo " ⚠️ Warning: Jenkins agent cleanup failed: ${ jenkinsCleanupException.message} "
447+ }
448+ echo " ✅ Pipeline cleanup completed successfully."
438449 } catch (Exception terraformException) {
439450 echo " ⚠️ Warning: Terraform cleanup failed: ${ terraformException.message} "
440451 }
441452 }
442453 } else {
443454 echo " ℹ️ No EC2 instance IP found, skipping Terraform cleanup"
444455 }
445- // Cleanup Jenkins agent using shared library function
446- def nodeName = " java-client-agent-${ BUILD_NUMBER} "
447- echo " 🗑️ Cleaning up Jenkins agent: ${ nodeName} "
448- try {
449- def cleanupResult = cleanupJenkinsAgent(nodeName)
450- echo " ✅ Cleanup result: ${ cleanupResult.status} for node: ${ cleanupResult.nodeName} "
451- } catch (Exception jenkinsCleanupException) {
452- echo " ⚠️ Warning: Jenkins agent cleanup failed: ${ jenkinsCleanupException.message} "
453- }
454- echo " ✅ Pipeline cleanup completed successfully."
455-
456456 } catch (Exception cleanupException) {
457457 echo " ⚠️ Warning: Cleanup encountered an error: ${ cleanupException.message} "
458458 echo " 📋 Continuing with pipeline completion despite cleanup issues..."
0 commit comments