HotCodePush
CI/CDProviders

Bitbucket Pipelines

A bitbucket-pipelines.yml with a step that releases every push to main to production with the HotCodePush CLI.

To ship every commit from Bitbucket Pipelines, a step under branches: main builds the app and runs npx hotcodepush release create with two secured repository variables in its environment. The CLI is pinned as a dev dependency, so the step needs nothing but a Node.js image.

Ship every commit has the prerequisites and the three disciplines. This page carries the bitbucket-pipelines.yml.

Secrets to set

All three live under the repository's settings, Repository variables, each marked Secured, which hides the value in the logs. The key goes in as its base64 body on one line: grep -v -- '-----' hotcodepush-private-key.pem | tr -d '\n'. The CLI reads it as it reads the file.

VariableHolds
HOTCODEPUSH_TOKENHolds an API token from the console's API tokens page.
HOTCODEPUSH_SIGNING_KEYHolds the base64 body of the private key file signing-key create wrote, on one line. Leave it out until the app has a key.
BITBUCKET_TOKENHolds a repository access token with the pullrequest:write scope, for the pull request comment. The preview step alone reads it.

The pipeline

bitbucket-pipelines.yml
image: node:22

pipelines:
  branches:
    main:
      - step:
          name: Release to production
          caches:
            - node
          script:
            - npm ci
            - npm run build
            - npx hotcodepush release create --channel production --bundle-version "$(git rev-parse --short HEAD)" --yes --json
  • The branches section runs the step for a push to main and for nothing else.
  • A React Native or Expo app drops the npm run build line: the CLI packages the bundle per platform inside the upload. A Cordova app whose www is written by hand drops it too.
  • The clone is on the branch, so the recorded ref is the branch. release lists every flag.

A failed command fails the step with the CLI's exit code and prints the error as JSON, and the error catalog names the fix. A green step and a device that did not take the release is the other case. See Troubleshooting.

A preview channel per pull request runs from a step under pull-requests. Test with preview channels has the commands. Bitbucket runs no pipeline when a pull request closes, so give the channel an expiry.

Next steps

  • Ship every commit names the three disciplines a pipeline that ships every commit keeps.
  • Test with preview channels builds the tester build that follows a preview channel from the QR code.
  • Roll out gradually puts --rollout-percent 10 --progression on the release line and explains the counters behind auto-pause.

Last updated on

On this page