Skip to main content

CircleCI

Integrate BrowserStack with CircleCI to automate test suites and manage build status effectively using simple scripts.

Integrate the provided script into your CircleCI configuration file within a job, make sure to replace placeholders with actual BrowserStack credentials.

Yaml
Copy icon Copy
version: 2.1
jobs:
 build:
   docker:
     - image: circleci/python:3.8
   steps:
     - run:
         name: Trigger Test Suite
         command: |
           response=$(curl -u YOUR_USERNAME:YOUR_ACCESS_KEY -X POST https://lcnc-api.browserstack.com/api/v1/test-suite/${TEST_SUITE_ID}/run)
           BUILD_ID=$(echo $response | jq -r '.build_id')
           echo "Build ID: $BUILD_ID"
     - run:
         name: Check Build Status
         command: |
           buildStatus=""
           retryInterval=30
           while [[ ("$buildStatus" != "passed" && "$buildStatus" != "failed") ]]; do
             response=$(curl -u YOUR_USERNAME:YOUR_ACCESS_KEY -s https://lcnc-api.browserstack.com/api/v1/builds/${BUILD_ID}/status)
             buildStatus=$(echo $response | jq -r '.build_status')
             sleep $retryInterval
           done
           if [[ "$buildStatus" == "passed" ]]; then
             echo "Build passed"
             # Add further steps for actions to be taken if build passed
           elif [[ "$buildStatus" == "failed" ]]; then
             echo "Build failed"
             exit 1
           else
             echo "Build status unstable"
             exit 1
           fi

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle