Skip to main content

Gitlab CI/CD

Integrate Low Code Automation API with GitLab CI/CD to automate test suite execution and monitor build status using a simple script.

Insert the provided script into your GitLab CI/CD YAML file within a job, ensure to replace placeholders with actual BrowserStack credentials.

Yaml
Copy icon Copy
stages:
  - test
test_job:
  stage: test
  before_script:
    - apt-get update && apt-get install -y jq
  script:
    - |
      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"
    - |
      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