# Bitbucket Pipelines: Deploy and Test

Run your test suite against the deployed environment to validate changes.

```yaml title="bitbucket-pipelines.yml"
image: node:20

pipelines:
  default:
    - step:
        name: Deploy to Zuplo
        script:
          - npm install
          - npx zuplo deploy --api-key "$ZUPLO_API_KEY" 2>&1 | tee
            ./DEPLOYMENT_STDOUT
          - echo "DEPLOYMENT_URL=$(grep -oP 'Deployed to \K(https://[^ ]+)'
            ./DEPLOYMENT_STDOUT)" >> deployment.env
        artifacts:
          - deployment.env

    - step:
        name: Run Tests
        script:
          - source deployment.env
          - npm install
          - npx zuplo test --endpoint "$DEPLOYMENT_URL"
```

This pipeline:

1. Deploys to Zuplo and captures the output
2. Extracts the deployment URL and saves it as an artifact
3. Runs tests against the deployed environment

## Next Steps

- Add [PR preview environments](./pr-preview-environments.mdx) with cleanup
- Run [local tests](./local-testing.mdx) before deploying
