HotCodePush
CI/CDProviders

Azure DevOps

An azure-pipelines.yml with a job that releases every push to main to production with the HotCodePush CLI.

To ship every commit from Azure DevOps, a job that runs for main builds the app and runs npx hotcodepush release create with two secret variables mapped into its environment. The CLI is pinned as a dev dependency, so the job needs nothing but the UseNode@1 task.

Ship every commit has the prerequisites and the three disciplines. This page carries the azure-pipelines.yml for a repository in Azure Repos.

Secrets to set

Both live in the pipeline's Variables with "Keep this value secret" on, or in a variable group of the Library. A secret variable is not an environment variable on its own: each script step that needs one maps it under env:, as the file below does. The key goes in as its base64 body on one line: grep -v -- '-----' hotcodepush-private-key.pem | tr -d '\n'.

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.

A preview job comments through the pipeline's own System.AccessToken, so the project's build service identity needs "Contribute to pull requests" on the repository.

The pipeline

azure-pipelines.yml
trigger:
  branches:
    include: [main]

pool:
  vmImage: ubuntu-latest

jobs:
  - job: release
    displayName: Release to production
    condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
    steps:
      - task: UseNode@1
        displayName: Use Node.js 22
        inputs:
          version: '22.x'
      - script: npm ci && npm run build
        displayName: Build the web app
      - script: npx hotcodepush release create --channel production --bundle-version "$(git rev-parse --short HEAD)" --git-ref "$BUILD_SOURCEBRANCHNAME" --yes --json
        displayName: Release to production
        env:
          HOTCODEPUSH_TOKEN: $(HOTCODEPUSH_TOKEN)
          HOTCODEPUSH_SIGNING_KEY: $(HOTCODEPUSH_SIGNING_KEY)
  • The trigger queues the pipeline for a push to main. The condition keeps the job off the pull request builds that a branch policy queues from the same file.
  • A React Native or Expo app replaces the build script with npm ci alone: the CLI packages the bundle per platform inside the upload. A Cordova app whose www is written by hand does the same.
  • The agent checks out the commit rather than the branch, so --git-ref "$BUILD_SOURCEBRANCHNAME" records 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 job and a device that did not take the release is the other case. See Troubleshooting.

A preview channel per pull request runs from a second job on the condition eq(variables['Build.Reason'], 'PullRequest'). Test with preview channels has the commands. Azure Pipelines runs no job when a pull request completes, so give the channel an expiry. A GitHub repository built by Azure Pipelines takes the pr trigger, System.PullRequest.PullRequestNumber and GitHub's comment API instead.

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