# Bitbucket Integration https://api-docs.lumar.io/docs/protect/ci/ci-bitbucket-integration In order to integrate with Bitbucket, you can either use our [CLI Tools](/docs/protect/ci/ci-cli-tools.md) or our [Shell Scripts](/docs/protect/ci/ci-shell-scripts.md): ## Prerequisites - Create a [Pipeline](https://support.atlassian.com/bitbucket-cloud/docs/configure-your-first-pipeline) for your Bitbucket repository. - Create a Test Suite on https://protect.lumar.io - Generate Lumar API key and secret on https://accounts.lumar.io/api-access ## How to Use (Shell Script) In the Bitbucket Pipeline editor, add the following environment variables: - `TEST_SUITE_ID`: The ID of your Test Suite - `AUTOMATOR_USER_KEY_ID`: The key for Lumar API access - `AUTOMATOR_USER_KEY_SECRET`: The secret for Lumar API access Then add the following step to the pipeline `yaml` file: ```yaml - step: name: "Lumar Protect" script: - curl -L -o ./lumar-protect.sh https://raw.githubusercontent.com/deepcrawl/automator-sdk/master/ci.sh - chmod +x lumar-protect.sh - ./lumar-protect.sh $TEST_SUITE_ID false bitbucket-build-$BITBUCKET_BUILD_NUMBER ``` The pipeline step will wait for all tests to complete and succeed if all tests passed. #### Additional Shell Script Options **Lumar Protect** shell script accepts the following input arguments:
`lumar-protect.sh TEST_SUITE_ID START_ONLY CI_BUILD_ID` To make the Bitbucket pipeline trigger your **Lumar Protect** Test Suite without waiting for all tests to complete, set the `START_ONLY` argument to `true`: ```yaml - step: name: "Lumar Protect" script: - curl -L -o ./lumar-protect.sh https://raw.githubusercontent.com/deepcrawl/automator-sdk/master/ci.sh - chmod +x lumar-protect.sh - ./lumar-protect.sh $TEST_SUITE_ID true bitbucket-build-$BITBUCKET_BUILD_NUMBER ``` ## How to Use (CLI Tool) In the Bitbucket Pipeline editor, add the following environment variables: - `TEST_SUITE_ID`: The ID of your Test Suite - `DEEPCRAWL_TEST_USER_KEY_ID`: The key for Lumar API access - `DEEPCRAWL_TEST_USER_KEY_SECRET`: The secret for Lumar API access Then add the following step to the pipeline `yaml` file: ```yaml - step: name: "Lumar Protect" script: - curl -L -o ./lumar-protect https://github.com/deepcrawl/deepcrawl-test/releases/download/v1.1.3/deepcrawl-test-linux - chmod +x ./lumar-protect - ./lumar-protect --testSuiteId=$TEST_SUITE_ID --ciBuildId=bitbucket-build-$BITBUCKET_BUILD_NUMBER | grep -i "tests passed" - if [[ $? -ne 0 ]]; then echo "Tests Failed"; exit 1; fi ``` The pipeline step will wait for all tests to complete and succeed if all tests passed. #### Additional CLI Tool Options **Lumar Protect** CLI tool accepts the following input parameters: - `--testSuiteId [string]` The **Lumar Protect** Test Suite ID. - `--ciBuildId [string] (OPTIONAL)` The corresponding build ID in your CI/CD pipeline. - `--startOnly [boolean] (OPTIONAL)` Start the Test Suite without waiting for all tests to finish. To make the Bitbucket pipeline trigger your **Lumar Protect** Test Suite without waiting for all tests to complete, set the `startOnly` parameter to `true`: ```yaml - step: name: "Lumar Protect" script: - curl -L -o ./lumar-protect https://github.com/deepcrawl/deepcrawl-test/releases/download/v1.1.3/deepcrawl-test-linux - chmod +x ./lumar-protect - ./lumar-protect --testSuiteId=$TEST_SUITE_ID --ciBuildId=bitbucket-build- --startOnly=true ``` See the official [Lumar Protect CLI reference](https://github.com/deepcrawl/deepcrawl-test/tree/main/packages/test-cli#readme/) for the full list of parameters.