Controlling serial execution across your organization
Serial groups enable controlled, sequential execution of CircleCI jobs across your organization to prevent conflicts when multiple jobs need to access shared resources or when operation order is critical.
Introduction
Serial groups in CircleCI allow you to apply serial orchestration to jobs across your entire organization. This feature helps prevent conflicts when multiple jobs need to access shared resources or when the order of operations is critical for maintaining system integrity. By implementing serial groups, you can ensure that jobs run one after another rather than concurrently, even across different projects and workflows within your organization.
Some common use cases for serial groups are as follows:
-
Preventing deployment conflicts when multiple teams need to deploy to the same environment.
-
Ensuring database migrations run in the correct sequence across multiple services.
-
Controlling access to limited testing resources that can only handle one job at a time.
-
Preventing race conditions in stateful systems during continuous delivery.
-
Managing sequential execution of integration tests that affect shared environments.
-
Maintaining version integrity by preventing older code from deploying after newer versions.
Quickstart
Once you have identified jobs that need to run sequentially across your organization, you can set up a serial group by following these steps:
-
Choose a meaningful name for your serial group that represents the resource or process being controlled. Use pipeline values in your serial group name to create dynamic grouping patterns if needed.
-
Add the
serial-groupkey to each job across your organization that runs in sequence, using the same value for all related jobs:# Creating multiple pipelines at the same time with the below config will result in # all pipelines running test and build but only a single pipeline will run deploy at a time. workflows: main-workflow: jobs: - test - build - deploy: serial-group: << pipeline.project.slug >>/deploy-group requires: - test - build -
Run your pipelines and observe the sequential execution on the pipelines page in the CircleCI web app.
How serial groups work
When you configure a job with a serial-group key, CircleCI’s platform treats the job differently from non-sequential group jobs. The following sections outline what happens behind the scenes.
Job identification and queuing
CircleCI identifies jobs that belong to the same serial group by the string value you provide. When multiple jobs across your organization use identical serial group values, they enter a shared queue. This queue operates on a first-in, first-out basis but with special priority rules.
Lock mechanism
CircleCI uses a distributed locking system to control execution order. When a job with a serial group starts, it attempts to acquire a "lock" for that specific serial group value. If no other job holds the lock, the job proceeds. If another job already holds the lock, subsequent jobs must wait in the queue.
Pipeline number priority
CircleCI uses pipeline numbers to determine execution priority. Jobs from newer pipelines (higher pipeline numbers) take precedence over jobs from older pipelines within the same project. If a job from an older pipeline tries to run while a newer pipeline’s job is waiting or running, the older job is automatically skipped.
Job state transitions
Jobs in a serial group move through several states:
-
First, the job enters a "queued" state.
-
Once a job starts (reaches its place in the queue), it transitions to a "running" state.
-
Upon completion (whether successful, failed, canceled, unauthorized, or not run), the next job in the queue starts. The queue continues to process jobs even if some jobs fail.
Time limits
To prevent indefinite waits, jobs can remain in the queue for up to five hours. After this time, CircleCI automatically cancels the waiting job and removes it from the queue.
This architecture provides a robust system for coordinating work across your organization while maintaining execution order integrity and preventing deployment conflicts or race conditions in shared environments.
Serial groups in the CircleCI UI
When using serial groups in your CircleCI configuration, sequential group start and end blocks are visible when viewing your workflow graphs.
Identifying serial groups
Serial group jobs are displayed in the CircleCI web app in workflow graphs with the following visual elements:
-
A job in a serial group is preceded by a block with a key icon to show the start of the serial group. A serial group end block follows the job.
Hover over the serial group start block to view additional information about the serial group status and the serial-groupkey.
Figure 1. Screenshot showing a job in a serial group waiting for approval -
Waiting jobs display a queued status.
Figure 2. Screenshot showing a queued job in a serial group -
The serial group start and end block statuses indicate the status of the job’s place in the serial group. For example, if a job starts and is then canceled while running, either manually or due to waiting beyond the time limit, the group start block shows a "Completed" status because the job started.
Managing serial groups
From the CircleCI web app there are two ways to move a serial group along to the next job in the queue:
-
You can release a serial group so that the current workflow continues as normal while the next job in the serial group is allowed to run.
-
You can cancel a workflow containing a job in a serial group. In this case all jobs in the workflow are canceled and the next job in the serial group is allowed to start.
Each method is described in the following sections:
Release a serial group
You can manually release a serial group from the CircleCI web app to allow queuing jobs to start. To release a serial group is to allow the next job in the queue to start. The job you release from the queue will continue to run. To release a serial group, follow these steps:
-
In the CircleCI web app, select your org.
-
Select Pipelines in the sidebar and locate your pipeline with a serial group in action.
-
Select the workflow name to view the workflow graph.
-
Select the serial group start block (with the key icon). A modal appears with information on the consequences of releasing the group. If you are happy to release the group, select Release serial group.
Figure 3. Screenshot showing the serial group release modal
Cancel a workflow with a serial group job
You can cancel an entire workflow that contains serial group jobs. Canceling a workflow will cancel all of its jobs, and the next job in the serial group in the org will start:
-
In the CircleCI web app, select your org.
-
Select Pipelines in the sidebar and locate your pipeline with a serial group in action.
-
Select the "Cancel Workflow" button to the right of the pipeline (
).
-
Confirm the cancellation when prompted.
Job groups
Job groups let you define a named set of jobs and their internal dependencies under the top-level job-groups key. You can invoke a job group in a workflow just like a regular job, and optionally apply a serial-group to the invocation to serialize the entire group as an atomic unit.
Define a job group
Add a job-groups key at the top level of your config. Each group has a name and a jobs list that follows the same format as workflow job entries, including internal requires dependencies:
job-groups:
migrate-and-verify:
jobs:
- migrate
- verify:
requires:
- migrate
Use a job group in a workflow
Reference the group by name in a workflow’s jobs list, just like a regular job. Jobs downstream of the group can depend on it using requires:
# Use job-groups to define a reusable set of jobs.
# The group is expanded inline in the workflow without serialization.
job-groups:
deploy-and-release:
jobs:
- deploy
- release:
requires:
- deploy
workflows:
main-workflow:
jobs:
- build
- deploy-and-release:
requires:
- build
- notify:
requires:
- deploy-and-release
When invoked without serial-group, the compiler expands the group inline and wraps it with no-op boundary jobs.
Use serial-group with a job group
Add the serial-group key to a group invocation to serialize the entire group as an atomic unit. No other serial group with the same serial-group key across your organization can start until all jobs in the group complete:
# Use job-groups with serial-group to serialize an entire set of jobs as an
# atomic unit. Only one pipeline can execute the group at a time across your org.
job-groups:
deploy-and-release:
jobs:
- deploy
- release:
requires:
- deploy
workflows:
main-workflow:
jobs:
- build
- deploy-and-release:
serial-group: << pipeline.project.slug >>/deploy-group
requires:
- build
- notify:
requires:
- deploy-and-release
Invoke a job group multiple times
You can invoke the same job group more than once in a workflow by adding a name: attribute to each invocation. Each name: value must be unique within the workflow and is used as a prefix for the expanded job names:
# Invoke the same job group twice using distinct name: values.
# Each invocation can have its own serial-group and requires.
job-groups:
deploy:
jobs:
- deploy-service
- run-smoke-tests:
requires:
- deploy-service
workflows:
main-workflow:
jobs:
- build
- deploy:
name: deploy-staging
serial-group: << pipeline.project.slug >>/staging-deploy
requires:
- build
- deploy:
name: deploy-production
serial-group: << pipeline.project.slug >>/production-deploy
requires:
- deploy-staging
How job group expansion works
When CircleCI processes a job group invocation, it inlines all jobs from the group definition and adds synthetic boundary jobs at each end:
-
Entry job: Inserted before the root jobs (jobs in the group with no internal
requiresdependencies). Withserial-group, this is a serial group start job. Without it, this is a no-op group-start job. -
Exit job: Inserted after the leaf jobs (jobs in the group that no other group job depends on). With
serial-group, this is a serial group end job. Without it, this is a no-op group-end job.
The group invocation’s requires and branch/tag filters are applied to the entry job. Jobs in the workflow that depend on the group invocation using requires are rewired to depend on the exit job.
Troubleshooting serial groups
Job skipped unexpectedly?
If your job is skipped with a "not run" status, check the following:
-
Check if another job from a newer pipeline (higher pipeline number) is currently running or waiting in the same serial group.
-
Verify your pipeline number is not lower than a currently active pipeline using the same serial group.
-
Remember that the order protection mechanism automatically skips jobs from older pipelines to maintain queue integrity.
Jobs not running sequentially?
If jobs are running concurrently when you expected them to run in sequence, check the following:
-
Confirm all jobs have the same
serial-groupvalue, including case sensitivity.-
Check for typos or whitespace differences in your serial group values.
-
Verify that pipeline parameters are resolving to the expected values in your
serial-groupkey. -
Ensure your serial group value meets the character requirements (alphanumeric plus
.,-,_,/).
-
Jobs canceled after waiting?
If your jobs are being canceled after waiting in the queue, check the following:
-
Check if any of your jobs are exceeding the five-hour maximum wait time.
-
Investigate if upstream dependencies in your workflow are failing or taking too long.
-
Look for deadlock situations where jobs are waiting for each other to complete.
Deployment order appears incorrect?
If you are experiencing deployment order problems, check the following:
-
Review the configuration for each job in your serial group to check they are assigned the correct
serial-groupkey. -
Check the pipeline numbers of recent deployments to understand execution order.
-
Consider using more specific serial group naming conventions that include branch or environment information.
Job group compile errors
If your pipeline fails to compile after adding a job group, check for the following configuration errors:
-
A name appears in both
jobsandjob-groups. -
A job inside a
job-groupsdefinition references another job group. Nesting is not supported. -
A job group invocation includes
matrix,override-with,context,pre-steps, orpost-stepsattributes. -
A job group definition includes a
parameterskey. -
A job group is invoked more than once in a workflow without distinct
name:values. -
A workflow job uses
requiresto depend on an individual job inside a group, rather than on the group invocation. -
A job inside a group uses
requiresto depend on a job that belongs to a different group.
Failure-handling job not triggering for a job group?
If a downstream job configured to run on failure does not trigger after a job group fails, it may be waiting on the group’s exit job rather than the individual job that failed. Downstream jobs that depend on a job group invocation observe the exit job’s status, not the status of individual jobs inside the group.
To react to a failure inside the group, add a failure-handling job inside the group definition itself.
Still experiencing resource conflicts?
If you are still experiencing resource conflicts despite using serial groups, check the following:
-
Make your serial group values more specific by adding project or environment identifiers.
-
Verify that all projects accessing the shared resource are properly configured with the same serial group.
-
Check for jobs outside your serial group that might be accessing the same resources.
Limitations of serial groups
Serial groups provide powerful orchestration capabilities, but they do have limitations. Understanding these constraints will help you plan your CI/CD strategy more effectively.
No workflow-level configuration
Serial groups can be applied at the job or job group invocation level. You cannot configure an entire workflow to run as a serial group. To serialize a collection of jobs as an atomic unit using a single serial-group declaration, see Job groups.
No multiple keys in a single workflow
Using identical serial group values multiple times within the same workflow can result in unexpected behavior due to the way the jobs join the queue. Each serial group key within a workflow must be unique to prevent conflicts in the execution order.
No selective lock release
Serial groups always release their lock upon job completion, regardless of the outcome. You cannot configure a serial group to maintain its lock if a job fails. This means you cannot prevent subsequent jobs from running if a critical job fails without implementing additional control mechanisms.
Timeout
Jobs waiting in the queue longer than five hours will be automatically canceled. This five-hour wait limit for serial groups is fixed and cannot be adjusted.
No cross-organization serialization
Serial groups work within a single organization only. You cannot use them to orchestrate jobs across different CircleCI organizations, even if they belong to the same company.