Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

How to Retrieve Running Builds in QuickBuild #4575

jctorres ·

Hello QuickBuild Community,

I'm using QuickBuild Version 13.0.22 and currently working on a promotion condition script in QuickBuild and I've encountered an issue when trying to retrieve a list of running builds. I want to disable the promotion button if there are any builds currently running for a specific promotion flow.

Here's the line of code that's causing trouble:

def runningBuilds = buildManager.runningBuilds

When I use this line in my script, I receive an error message indicating that the expression cannot be evaluated. I've tried including various imports, but the issue persists.

// Retrieve the list of running builds from the system
def runningBuilds = system.buildManager.runningBuilds

// Specify the name of the current promotion
def currentPromotionName = "Name of my promotion" // Replace with your actual promotion name

def isPromotionRunning = runningBuilds.any { build ->
    build.getPromotion().getName() == currentPromotionName
}

// If there is a running build for the promotion, return false to disable the button
if (isPromotionRunning) {
    return false
}


return true

Thank you in advance.

  • replies 1
  • views 320
  • stars 0
robinshen ADMIN ·

Please use below script instead:

groovy: 
 
def buildRequests = system.buildEngine.getBuildRequests(null) 
def currentPromotionName = "Release"  
return !buildRequests.any { request -> 
    request.promotionSource != null && request.promotionSource.promotionName.equals(currentPromotionName) 
}