Run Builds Sequentially trigger at the same time.
Asked by Ankush Das:

When a Jira status change occurs, it triggers a Bamboo pipeline. However, in the current scenario, if two users simultaneously change the Jira status, only one build is executed, and the other is not.

What I desire is for the first build to run immediately, while the second build enters a queue and runs after the completion of the first build.

Is there any way to do the same? I do not want to run builds in parallel.


Answers:
author: alok m
body: Ensuring that builds triggered by Jira status changes are queued sequentially in Bamboo, especially when multiple status changes occur simultaneously, requires configuring Bamboo's build queue and possibly using additional scripting or plugins to manage the build triggers more effectively. Here's a general approach to achieving this:

Step 1: Configure Bamboo Build Plans  
Concurrency Settings: Check the plan configuration in Bamboo. Ensure that the plan is set not to run concurrent builds. This setting ensures that if a build is triggered while another is running, it will be queued.

Navigate to your plan configuration in Bamboo.  
Look for settings related to Concurrency or Queueing.  
Ensure the configuration is set to avoid parallel executions of the same plan.  
Throttling Triggers: If Bamboo's built-in settings don't provide the level of control you need, consider adding a throttling mechanism to your build trigger process. This might involve custom scripting or using an intermediary service to manage the triggers.

Step 2: Use an Intermediary Script or Service  
If direct configuration in Bamboo is insufficient, you can use an intermediary script or service that receives the Jira webhook notifications and then triggers the Bamboo builds. This script can implement logic to check if a build is currently running and queue requests accordingly.

Webhook Receiver: Create a simple web service or script that listens for Jira webhook events.  
Check Bamboo's Build Status: Before triggering a new build, check if there is already a build running for the plan. Bamboo's REST API can be used to query the current status of builds.  
Queue Management: If a build is already running, your script can wait (polling at regular intervals) until the current build completes before triggering the next build.  
Step 3: Utilize Bamboo's REST API  
Bamboo's REST API can be leveraged to check the status of a build plan and trigger builds. This can be integrated into your intermediary service:

Query Plan Status: Use the REST API to check if the plan is currently building.  
Trigger Build: If no builds are currently running, use the API to trigger a new build. If a build is running, queue the request.  
Step 4: Jira Integration  
Configure Jira to send status change events to your intermediary service instead of directly to Bamboo. This setup allows your service to manage the build triggers.  
Step 5: Implement Queue Logic  
In your service, implement logic to manage a queue of build requests. When a build completes, the service should automatically trigger the next build in the queue, if any.  
Step 6: Monitoring and Error Handling  
Ensure that your intermediary service includes robust logging, monitoring, and error handling. This is crucial for diagnosing issues and ensuring the reliability of the build process.  
Alternative: Explore Bamboo Plugins  
Explore Bamboo Marketplace: Check the Atlassian Marketplace for Bamboo plugins that might offer enhanced queue management or build trigger controls. Some plugins might provide the functionality you need out of the box.  
This approach requires additional infrastructure and setup but offers a flexible solution to precisely manage how and when builds are triggered from Jira status changes.