@@ -22,6 +22,7 @@ def run(params) {
2222 // Declare lock resource use during node bootstrap
2323 mgrCreateBootstrapRepo = ' share resource to avoid running mgr create bootstrap repo in parallel'
2424 retailProxyConfigurationLock = ' lock proxy retail setup'
25+ def muSemaphoreLock = createSemaphore(5 )
2526 // Variables to store none critical stage run status
2627 def monitoring_stage_result_fail = false
2728 def client_stage_result_fail = false
@@ -587,13 +588,15 @@ def clientTestingStages(params) {
587588 if (params. confirm_before_continue) {
588589 input ' Press any key to start adding Maintenance Update repositories'
589590 }
590- echo ' Add custom channels and MU repositories'
591- res_mu_repos = runCucumberRakeTarget(" cucumber:build_validation_add_maintenance_update_repositories_${ nodeTag} " , true , temporaryList)
592- echoHtmlReportPath(" build_validation_add_maintenance_update_repositories_${ nodeTag} " )
593- echo " Custom channels and MU repositories status code: ${ res_mu_repos} "
594- if (res_mu_repos != 0 ) {
595- required_custom_channel_status[node] = ' FAIL'
596- error(" Add custom channels and MU repositories failed with status code: ${ res_mu_repos} " )
591+ withThrottle(muSemaphoreLock) {
592+ echo ' Add custom channels and MU repositories'
593+ res_mu_repos = runCucumberRakeTarget(" cucumber:build_validation_add_maintenance_update_repositories_${ nodeTag} " , true , temporaryList)
594+ echoHtmlReportPath(" build_validation_add_maintenance_update_repositories_${ nodeTag} " )
595+ echo " Custom channels and MU repositories status code: ${ res_mu_repos} "
596+ if (res_mu_repos != 0 ) {
597+ required_custom_channel_status[node] = ' FAIL'
598+ error(" Add custom channels and MU repositories failed with status code: ${ res_mu_repos} " )
599+ }
597600 }
598601 }
599602 }
@@ -611,13 +614,15 @@ def clientTestingStages(params) {
611614 if (params. confirm_before_continue) {
612615 input ' Press any key to start adding common channels'
613616 }
614- echo ' Add non MU Repositories'
615- res_non_MU_repositories = runCucumberRakeTarget(" cucumber:${ build_validation_non_MU_script} " , true , temporaryList)
616- echo " Non MU Repositories status code: ${ res_non_MU_repositories} "
617- echoHtmlReportPath(build_validation_non_MU_script)
618- if (res_non_MU_repositories != 0 ) {
619- required_custom_channel_status[node] = ' FAIL'
620- error(" Add common channels failed with status code: ${ res_non_MU_repositories} " )
617+ withThrottle(muSemaphoreLock) {
618+ echo ' Add non MU Repositories'
619+ res_non_MU_repositories = runCucumberRakeTarget(" cucumber:${ build_validation_non_MU_script} " , true , temporaryList)
620+ echo " Non MU Repositories status code: ${ res_non_MU_repositories} "
621+ echoHtmlReportPath(build_validation_non_MU_script)
622+ if (res_non_MU_repositories != 0 ) {
623+ required_custom_channel_status[node] = ' FAIL'
624+ error(" Add common channels failed with status code: ${ res_non_MU_repositories} " )
625+ }
621626 }
622627 }
623628 }
@@ -922,4 +927,30 @@ def echoHtmlReportPath(String rake_target) {
922927 }
923928}
924929
930+ @NonCPS
931+ def createSemaphore (int count ) {
932+ return new java.util.concurrent.Semaphore (count)
933+ }
934+
935+ @NonCPS
936+ def tryAcquireSlot (semaphore ) {
937+ return semaphore. tryAcquire()
938+ }
939+
940+ @NonCPS
941+ def releaseSlot (semaphore ) {
942+ semaphore. release()
943+ }
944+
945+ def withThrottle = { semaphore , Closure body ->
946+ waitUntil {
947+ tryAcquireSlot(semaphore)
948+ }
949+ try {
950+ body()
951+ } finally {
952+ releaseSlot(semaphore)
953+ }
954+ }
955+
925956return this
0 commit comments