GitLab CI/CD
A .gitlab-ci.yml with a job that releases every push to the default branch to production with the HotCodePush CLI.
To ship every commit from GitLab CI/CD, a job on the default branch builds the app and runs npx hotcodepush release create with two masked CI/CD variables. The CLI is pinned as a dev dependency, so the job needs nothing but a Node.js image.
Ship every commit has the prerequisites and the three disciplines. This page carries the .gitlab-ci.yml.
Secrets to set
All three live under the project's Settings › CI/CD › Variables, each marked Masked. A masked value is a single line without spaces, so the key goes in as its base64 body: grep -v -- '-----' hotcodepush-private-key.pem | tr -d '\n'. The CLI reads it as it reads the file.
| Variable | Holds |
|---|---|
HOTCODEPUSH_TOKEN | Holds an API token from the console's API tokens page. |
HOTCODEPUSH_SIGNING_KEY | Holds the base64 body of the private key file signing-key create wrote, on one line. Leave it out until the app has a key. |
GITLAB_TOKEN | Holds a project access token with the api scope, for the merge request note. The preview job alone reads it. |
Leave Protected off while a preview job runs on merge requests, since a protected variable reaches only pipelines on protected branches.
The pipeline
image: node:22
release:
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- npm ci
- npm run build
- npx hotcodepush release create --channel production --bundle-version "$(git rev-parse --short HEAD)" --git-ref "$CI_COMMIT_REF_NAME" --yes --json- The rule runs the job for a push to the default branch and for nothing else.
- A React Native or Expo app drops the
npm run buildline: the CLI packages the bundle per platform inside the upload. A Cordova app whosewwwis written by hand drops it too. - The runner checks out the commit rather than the branch, so
--git-ref "$CI_COMMIT_REF_NAME"records the branch. release lists every flag.
A failed command fails the job with the CLI's exit code and prints the error as JSON, and the error catalog names the fix. A green job and a device that did not take the release is the other case. See Troubleshooting.
A preview channel per merge request runs from a second job in merge request pipelines. Test with preview channels has the commands. GitLab runs no pipeline when a merge 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 --progressionon the release line and explains the counters behind auto-pause.
Last updated on
GitHub Actions
A release.yml that releases every merge to production with the HotCodePush release action, with the bare CLI line beside it.
Xcode Cloud
An archive workflow with HOTCODEPUSH_TOKEN as a secret, the post-clone script that installs Node.js, and the check that confirms the store build is registered.