{
  "doc": {
    "id": "app/continuous-integration/aws-codebuild",
    "title": "Run Cypress tests in AWS CodeBuild: Step-by-Step Guide",
    "description": "Learn how to set up and run Cypress tests in AWS CodeBuild, cache dependencies and build artifacts, run tests in parallel, and use Cypress Cloud with AWS CodeBuild.",
    "section": "app",
    "source_path": "/llm/markdown/app/continuous-integration/aws-codebuild.md",
    "version": "e6988a974973e9090ce70406c38cb2b9e0eac9fa",
    "updated_at": "2026-05-15T15:50:22.536Z",
    "headings": [
      {
        "id": "app/continuous-integration/aws-codebuild#run-cypress-in-aws-codebuild",
        "text": "Run Cypress in AWS CodeBuild",
        "level": 1
      },
      {
        "id": "app/continuous-integration/aws-codebuild#what-youll-learn",
        "text": "What you'll learn",
        "level": 5
      },
      {
        "id": "app/continuous-integration/aws-codebuild#basic-setup",
        "text": "Basic Setup",
        "level": 2
      },
      {
        "id": "app/continuous-integration/aws-codebuild#testing-with-cypress-docker-images",
        "text": "Testing with Cypress Docker Images",
        "level": 2
      },
      {
        "id": "app/continuous-integration/aws-codebuild#enabling-batch-builds",
        "text": "Enabling batch builds",
        "level": 3
      },
      {
        "id": "app/continuous-integration/aws-codebuild#cypress-amazon-public-ecr",
        "text": "Cypress Amazon Public ECR",
        "level": 3
      },
      {
        "id": "app/continuous-integration/aws-codebuild#caching-dependencies-and-build-artifacts",
        "text": "Caching Dependencies and Build Artifacts",
        "level": 2
      },
      {
        "id": "app/continuous-integration/aws-codebuild#parallelization",
        "text": "Parallelization",
        "level": 2
      },
      {
        "id": "app/continuous-integration/aws-codebuild#parallelizing-the-build",
        "text": "Parallelizing the build",
        "level": 3
      },
      {
        "id": "app/continuous-integration/aws-codebuild#using-cypress-cloud-with-aws-codebuild",
        "text": "Using Cypress Cloud with AWS CodeBuild",
        "level": 2
      }
    ]
  },
  "content": {
    "type": "root",
    "children": [
      {
        "type": "heading",
        "depth": 1,
        "children": [
          {
            "type": "text",
            "value": "Run Cypress in AWS CodeBuild"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 5,
        "children": [
          {
            "type": "text",
            "value": "What you'll learn"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "How to set up Cypress tests in AWS CodeBuild"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "How to cache dependencies and build artifacts"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "How to run Cypress tests in parallel with AWS CodeBuild"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "How to use Cypress Cloud with AWS CodeBuild"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Basic Setup"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The example below is a basic CI setup and job using the "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://aws.amazon.com/codebuild/",
            "children": [
              {
                "type": "text",
                "value": "AWS CodeBuild"
              }
            ]
          },
          {
            "type": "text",
            "value": " to run Cypress tests within the Electron browser. This AWS CodeBuild configuration is placed within `buildspec.yml`."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Detailed documentation is available in the "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/",
            "children": [
              {
                "type": "text",
                "value": "AWS CodeBuild Documentation"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "buildspec.yml"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "version: 0.2phases:  install:    runtime-versions:      nodejs: latest    commands:      # Set COMMIT_INFO variables to send Git specifics to Cypress Cloud when recording      # https://docs.cypress.io/app/continuous-integration/overview#Git-information      - export COMMIT_INFO_BRANCH=\"$(git rev-parse HEAD | xargs git name-rev |        cut -d' ' -f2 | sed 's/remotes\\/origin\\///g')\"      - export COMMIT_INFO_MESSAGE=\"$(git log -1 --pretty=%B)\"      - export COMMIT_INFO_EMAIL=\"$(git log -1 --pretty=%ae)\"      - export COMMIT_INFO_AUTHOR=\"$(git log -1 --pretty=%an)\"      - export COMMIT_INFO_SHA=\"$(git log -1 --pretty=%H)\"      - export COMMIT_INFO_REMOTE=\"$(git config --get remote.origin.url)\"      - npm ci  pre_build:    commands:      - npm run cy:verify      - npm run cy:info  build:    commands:      - npm run start:ci &      - npx cypress run --record"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "How this buildspec works:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "On push to this repository, this job will provision and start AWS-hosted Amazon Linux instance with Node.js for running the outlined `pre_build` and `build` for the declared commands within the `commands` section of the configuration."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "https://aws.amazon.com/codebuild/",
                    "children": [
                      {
                        "type": "text",
                        "value": "AWS CodeBuild"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " will checkout our code from our GitHub repository."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Finally, our `buildspec.yml` configuration will:"
                  }
                ]
              },
              {
                "type": "list",
                "ordered": false,
                "start": null,
                "spread": false,
                "children": [
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "Install npm dependencies"
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "Start the project web server (`npm start:ci`)"
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "Run the Cypress tests within our GitHub repository within Electron."
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Try it out"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "To try out the example above yourself, fork the "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://github.com/cypress-io/cypress-example-kitchensink",
            "children": [
              {
                "type": "text",
                "value": "Cypress Kitchen Sink"
              }
            ]
          },
          {
            "type": "text",
            "value": " example project and place the above "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://aws.amazon.com/codebuild/",
            "children": [
              {
                "type": "text",
                "value": "AWS CodeBuild"
              }
            ]
          },
          {
            "type": "text",
            "value": " configuration in `buildspec.yml`."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Testing with Cypress Docker Images"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "As of version 0.2, CodeBuild does not provide a way to specify a custom image for single build configurations. One way to solve this is using an "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html#build-spec.batch.build-list",
            "children": [
              {
                "type": "text",
                "value": "AWS CodeBuild batch build-list strategy"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Enabling batch builds"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Per the "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html",
            "children": [
              {
                "type": "text",
                "value": "AWS CodeBuild batch build documentation"
              }
            ]
          },
          {
            "type": "text",
            "value": ", AWS CodeBuild creates a separate build for each possible configuration combination for a "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html#build-spec.batch.build-list",
            "children": [
              {
                "type": "text",
                "value": "batch build-list strategy"
              }
            ]
          },
          {
            "type": "text",
            "value": ". Therefore, AWS CodeBuild projects must be created or updated to run batch configuration."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Follow these steps to enable batch configuration for existing AWS CodeBuild projects:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Navigate to the AWS CodeBuild Console"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Select the project"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Click \"Edit\" --> \"Batch Configuration\""
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Create \"New service Role\" and enter the name of the role"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Leave all other options as optional"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Click \"Update batch configuration\""
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Start the Build"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Cypress Amazon Public ECR"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "AWS CodeBuild offers a "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html#build-spec.batch.build-list",
            "children": [
              {
                "type": "text",
                "value": "build-list strategy"
              }
            ]
          },
          {
            "type": "text",
            "value": " of different job configurations for a single job definition."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html#build-spec.batch.build-list",
            "children": [
              {
                "type": "text",
                "value": "build-list strategy"
              }
            ]
          },
          {
            "type": "text",
            "value": " offers a way to specify an image hosted on "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://hub.docker.com/",
            "children": [
              {
                "type": "text",
                "value": "Docker Hub"
              }
            ]
          },
          {
            "type": "text",
            "value": " or the "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://aws.amazon.com/ecr/",
            "children": [
              {
                "type": "text",
                "value": "Amazon Elastic Container Registry (ECR)"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "link",
            "title": null,
            "url": "https://github.com/cypress-io/cypress-docker-images",
            "children": [
              {
                "type": "text",
                "value": "Docker Images"
              }
            ]
          },
          {
            "type": "text",
            "value": " for running Cypress locally and in CI are published to the "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://gallery.ecr.aws",
            "children": [
              {
                "type": "text",
                "value": "Amazon ECR Public Gallery"
              }
            ]
          },
          {
            "type": "text",
            "value": ".:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "https://gallery.ecr.aws/cypress-io/cypress/base",
                    "children": [
                      {
                        "type": "text",
                        "value": "Cypress 'base' Amazon ECR Public Gallery"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "https://gallery.ecr.aws/cypress-io/cypress/browsers",
                    "children": [
                      {
                        "type": "text",
                        "value": "Cypress 'browsers' Amazon ECR Public Gallery"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "https://gallery.ecr.aws/cypress-io/cypress/included",
                    "children": [
                      {
                        "type": "text",
                        "value": "Cypress 'included' Amazon ECR Public Gallery"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Read about "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/continuous-integration/overview.md#Cypress-Docker-variants",
            "children": [
              {
                "type": "text",
                "value": "Cypress docker variants"
              }
            ]
          },
          {
            "type": "text",
            "value": " to decide which image is best for your project."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "buildspec.yml"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "version: 0.2## AWS CodeBuild Batch configuration## https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html## Define build to run using the## \"cypress/browsers:22.15.0\" image## from the Cypress Amazon ECR Public Gallerybatch:  fast-fail: false  build-list:    - identifier: cypress-e2e-tests      env:        image: public.ecr.aws/cypress-io/cypress/browsers:22.15.0phases:  install:    runtime-versions:      nodejs: latest    commands:      # Set COMMIT_INFO variables to send Git specifics to Cypress Cloud when recording      # https://docs.cypress.io/app/continuous-integration/overview#Git-information      - export COMMIT_INFO_BRANCH=\"$(git rev-parse HEAD | xargs git name-rev |        cut -d' ' -f2 | sed 's/remotes\\/origin\\///g')\"      - export COMMIT_INFO_MESSAGE=\"$(git log -1 --pretty=%B)\"      - export COMMIT_INFO_EMAIL=\"$(git log -1 --pretty=%ae)\"      - export COMMIT_INFO_AUTHOR=\"$(git log -1 --pretty=%an)\"      - export COMMIT_INFO_SHA=\"$(git log -1 --pretty=%H)\"      - export COMMIT_INFO_REMOTE=\"$(git config --get remote.origin.url)\"      - npm ci  pre_build:    commands:      - npm run cy:verify      - npm run cy:info  build:    commands:      - npm run start:ci &      - npx cypress run --record --browser firefox"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Caching Dependencies and Build Artifacts"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Caching with "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://aws.amazon.com/codebuild/",
            "children": [
              {
                "type": "text",
                "value": "AWS CodeBuild"
              }
            ]
          },
          {
            "type": "text",
            "value": " directly can be challenging. The "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/build-caching.html",
            "children": [
              {
                "type": "text",
                "value": "Build caching in AWS CodeBuild"
              }
            ]
          },
          {
            "type": "text",
            "value": " document offers details on local or Amazon S3 caching."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Per the documentation, \"Local caching stores a cache locally on a build host that is available to that build host only\". This will not be useful during parallel test runs."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The \"Amazon S3 caching stores the cache in an Amazon S3 bucket that is available across multiple build hosts\". While this may sound useful, in practice the upload of cached dependencies can take some time. Furthermore, each worker will attempt to save it's dependency cache to Amazon S3, which increases build time significantly."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Beyond the scope of this guide, but "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://aws.amazon.com/codepipeline",
            "children": [
              {
                "type": "text",
                "value": "AWS CodePipeline"
              }
            ]
          },
          {
            "type": "text",
            "value": " may be of use to cache the initial source, dependencies and build output for use in AWS CodeBuild jobs using "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome-introducing-artifacts.html",
            "children": [
              {
                "type": "text",
                "value": "AWS CodePipeline Input and Output Artifacts"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Reference the "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/sample-pipeline-multi-input-output.html",
            "children": [
              {
                "type": "text",
                "value": "AWS CodePipeline integration with CodeBuild and multiple input sources and output artifacts sample"
              }
            ]
          },
          {
            "type": "text",
            "value": " example for details on how to configure a CodePipeline with an output artifact."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Parallelization"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/cloud/get-started/introduction.md",
            "children": [
              {
                "type": "text",
                "value": "Cypress Cloud"
              }
            ]
          },
          {
            "type": "text",
            "value": " offers the ability to "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/cloud/features/smart-orchestration/parallelization.md",
            "children": [
              {
                "type": "text",
                "value": "parallelize and group test runs"
              }
            ]
          },
          {
            "type": "text",
            "value": " along with additional insights and "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/cloud/features/analytics/overview.md",
            "children": [
              {
                "type": "text",
                "value": "analytics"
              }
            ]
          },
          {
            "type": "text",
            "value": " for Cypress tests."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "AWS CodeBuild offers a "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html#build-spec.batch.build-matrix",
            "children": [
              {
                "type": "text",
                "value": "batch build-matrix strategy"
              }
            ]
          },
          {
            "type": "text",
            "value": " for declaring different job configurations for a single job definition. The "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html#build-spec.batch.build-matrix",
            "children": [
              {
                "type": "text",
                "value": "batch build-matrix strategy"
              }
            ]
          },
          {
            "type": "text",
            "value": " provides an option to specify a container image for the job. Jobs declared within a build-matrix strategy can run in parallel which enables us run multiples instances of Cypress at same time as we will see later in this section."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Enabling-batch-builds",
            "children": [
              {
                "type": "text",
                "value": "Enabling batch builds"
              }
            ]
          },
          {
            "type": "text",
            "value": " for instructions on how to enable batch builds."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The following configuration using the `--parallel` and `--record` flags to "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown//app//app/command-line.md#cypress-run",
            "children": [
              {
                "type": "text",
                "value": "cypress run"
              }
            ]
          },
          {
            "type": "text",
            "value": " requires setting up recording test results to "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/cloud/get-started/introduction.md",
            "children": [
              {
                "type": "text",
                "value": "Cypress Cloud"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Parallelizing the build"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "To setup multiple containers to run in parallel, the `build-matrix` configuration uses a set of variables (`CY_GROUP_SPEC` and `WORKERS`) with a list of items specific to each group for the build."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The fields are delimited by a pipe (`|`) character as follows:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "## Group Name | Browser | Specs | Cypress Configuration options (optional)'UI-Chrome-Mobile|chrome|cypress/tests/ui/*|viewportWidth=375,viewportHeight=667'"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The `build-matrix` will run all permutations delimited items."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "buildspec.yml"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "batch:  fast-fail: false  build-matrix:    # ...    dynamic:      env:        # ...        variables:          CY_GROUP_SPEC:            - 'UI-Chrome|chrome|cypress/tests/ui/*'            - 'UI-Chrome-Mobile|chrome|cypress/tests/ui/*|viewportWidth=375,viewportHeight=667'            - 'API|chrome|cypress/tests/api/*'            - 'UI-Firefox|firefox|cypress/tests/ui/*'            - 'UI-Firefox-Mobile|firefox|cypress/tests/ui/*|viewportWidth=375,viewportHeight=667'"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "During the install phase, we utilize shell scripting with the "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://en.wikipedia.org/wiki/Cut_(Unix)",
            "children": [
              {
                "type": "text",
                "value": "cut command"
              }
            ]
          },
          {
            "type": "text",
            "value": " to assign values from the delimited `CY_GROUP_SPEC` passed to the worker into shell variables that will be used in the `build` phase when running `cypress run`."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "buildspec.yml"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "batch:  # ...phases:  install:    commands:      # Set COMMIT_INFO variables to send Git specifics to Cypress Cloud when recording      # https://docs.cypress.io//app/continuous-integration/overview#Git-information      - export COMMIT_INFO_BRANCH=\"$(git rev-parse HEAD | xargs git name-rev |        cut -d' ' -f2 | sed 's/remotes\\/origin\\///g')\"      - export COMMIT_INFO_MESSAGE=\"$(git log -1 --pretty=%B)\"      - export COMMIT_INFO_EMAIL=\"$(git log -1 --pretty=%ae)\"      - export COMMIT_INFO_AUTHOR=\"$(git log -1 --pretty=%an)\"      - export COMMIT_INFO_SHA=\"$(git log -1 --pretty=%H)\"      - export COMMIT_INFO_REMOTE=\"$(git config --get remote.origin.url)\"      - CY_GROUP=$(echo $CY_GROUP_SPEC | cut -d'|' -f1)      - CY_BROWSER=$(echo $CY_GROUP_SPEC | cut -d'|' -f2)      - CY_SPEC=$(echo $CY_GROUP_SPEC | cut -d'|' -f3)      - CY_CONFIG=$(echo $CY_GROUP_SPEC | cut -d'|' -f4)      - npm ci## ..."
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "To parallelize the runs, we need to add an additional variable to the "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html#build-spec.batch.build-matrix",
            "children": [
              {
                "type": "text",
                "value": "build-matrix strategy"
              }
            ]
          },
          {
            "type": "text",
            "value": ", `WORKERS`."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "buildspec.yml"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "batch:  fast-fail: false  build-matrix:    # ...    dynamic:      env:        # ...        variables:          CY_GROUP_SPEC:            # ...          WORKERS:            - 1            - 2            - 3            - 4            - 5"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Note"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The `WORKERS` array is filled with filler (or dummy) items to provision the desired number of CI machine instances within the "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html#build-spec.batch.build-matrix",
            "children": [
              {
                "type": "text",
                "value": "batch build-matrix strategy"
              }
            ]
          },
          {
            "type": "text",
            "value": " and will provide 5 workers to each group defined in the `CY_GROUP_SPEC`."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Finally, the script variables are passed to the call to `cypress run`."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "buildspec.yml"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "phases:  install:    # ...  build:    commands:      - npm start:ci &      - npx cypress run --record --parallel --browser $CY_BROWSER --ci-build-id        $CODEBUILD_INITIATOR --group \"$CY_GROUP\" --spec \"$CY_SPEC\" --config        \"$CY_CONFIG\""
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Using Cypress Cloud with AWS CodeBuild"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Dashboard analytics are dependent on your CI environment reliably providing commit SHA data (typically via a system environment variable) which is not always present by default. This is not a problem for most users, but if you are facing integration issues with your CodeBuild setup, please make sure the git information is being sent properly by following "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown//app/continuous-integration/overview.md#Git-information",
            "children": [
              {
                "type": "text",
                "value": "these guidelines"
              }
            ]
          },
          {
            "type": "text",
            "value": ", or just see "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Basic-Setup",
            "children": [
              {
                "type": "text",
                "value": "the example `codebuild.yml` file at the top of this page"
              }
            ]
          },
          {
            "type": "text",
            "value": ". If you are still facing issues after this, please "
          },
          {
            "type": "link",
            "title": null,
            "url": "mailto:hello@cypress.io",
            "children": [
              {
                "type": "text",
                "value": "contact us"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "In the AWS CodeBuild configuration we have defined in the previous section, we are leveraging three useful features of "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/cloud/get-started/introduction.md",
            "children": [
              {
                "type": "text",
                "value": "Cypress Cloud"
              }
            ]
          },
          {
            "type": "text",
            "value": ":"
          }
        ]
      },
      {
        "type": "list",
        "ordered": true,
        "start": 1,
        "spread": true,
        "children": [
          {
            "type": "listItem",
            "spread": true,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/cloud/get-started/setup.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "Recording test results with the `--record` flag"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " to Cypress Cloud."
                  }
                ]
              },
              {
                "type": "list",
                "ordered": false,
                "start": null,
                "spread": false,
                "children": [
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "In-depth and shareable "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "/llm/markdown/cloud/features/recorded-runs.md#Latest-Runs",
                            "children": [
                              {
                                "type": "text",
                                "value": "test reports"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": "."
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "Visibility into test failures via quick access to "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "/llm/markdown/cloud/features/test-replay.md",
                            "children": [
                              {
                                "type": "text",
                                "value": "Test Replay"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": ", error messages, stack traces, screenshots, videos, and contextual details."
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "link",
                            "title": null,
                            "url": "/llm/markdown/cloud/integrations/github.md",
                            "children": [
                              {
                                "type": "text",
                                "value": "Integrating testing with the pull-request (PR) process"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": " via "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "/llm/markdown/cloud/integrations/github.md#Status-checks",
                            "children": [
                              {
                                "type": "text",
                                "value": "commit status check guards"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": " and convenient "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "/llm/markdown/cloud/integrations/github.md#Pull-request-comments",
                            "children": [
                              {
                                "type": "text",
                                "value": "test report comments"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": "."
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "link",
                            "title": null,
                            "url": "/llm/markdown/cloud/features/flaky-test-management.md",
                            "children": [
                              {
                                "type": "text",
                                "value": "Detecting flaky tests"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": " and surfacing them via "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "/llm/markdown/cloud/features/flaky-test-management.md#Slack",
                            "children": [
                              {
                                "type": "text",
                                "value": "Slack alerts"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": " or "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "/llm/markdown/cloud/features/flaky-test-management.md#GitHub",
                            "children": [
                              {
                                "type": "text",
                                "value": "GitHub PR status checks"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": "."
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/cloud/features/smart-orchestration/parallelization.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "Parallelizing test runs"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " and optimizing their execution via "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/cloud/features/smart-orchestration/load-balancing.md#Balance-strategy",
                    "children": [
                      {
                        "type": "text",
                        "value": "intelligent load-balancing"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " of test specs across CI machines with the `--parallel` flag."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Organizing and consolidating multiple `cypress run` calls by labeled groups into a single report within "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "https://on.cypress.io/cloud",
                    "children": [
                      {
                        "type": "text",
                        "value": "Cypress Cloud"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ". In the example above we use the `--group UI-Chrome` flag to organize all UI tests for the Chrome browser into a group labeled \"UI-Chrome\" inside the Cypress Cloud report."
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "token_estimate": 2059
}