buildshare.in
CI / CD

GitLab CI / CD

Distribute mobile builds directly from your GitLab CI/CD pipelines using the BuildShare CLI.

Integrate BuildShare with GitLab CI/CD to distribute test builds whenever changes are pushed to your repository or merge requests are created.


Prerequisites

  1. Add your BuildShare personal access token to your GitLab project:
    • Navigate to Settings → CI/CD → Variables.
    • Add a variable named BUILDSHARE_TOKEN (mark as Masked).
  2. Add your target Project ID as a CI/CD variable:
    • Add a variable named BUILDSHARE_PROJECT_ID (mark as Masked).
    • Alternatively, commit a buildshare.json or .buildshare.yaml to your project repository root.

Integration Steps

Add a deployment job to your .gitlab-ci.yml file after your build stage:

upload_buildshare:
  stage: deploy
  script:
    - curl -fsSL https://raw.githubusercontent.com/vishalkumardev/cli/main/install.sh | sh
    - export PATH="$HOME/.local/bin:$PATH"
    - buildshare login --token "$BUILDSHARE_TOKEN"
    - |
      buildshare upload ./android/app/build/outputs/apk/release/app-release.apk \
        --app "$BUILDSHARE_PROJECT_ID" \
        --notes "GitLab CI build $CI_COMMIT_SHORT_SHA"
  variables:
    BUILDSHARE_TOKEN: $BUILDSHARE_TOKEN
    BUILDSHARE_PROJECT_ID: $BUILDSHARE_PROJECT_ID

Adding CLI to PATH

Running export PATH="$HOME/.local/bin:$PATH" ensures the shell session can immediately invoke the installed buildshare binary in non-root CI runner environments.


Complete Pipeline Examples

A complete .gitlab-ci.yml configuration for React Native projects building an Android Release APK and distributing it via BuildShare:

image: node:24-bookworm

stages:
  - build
  - deploy

before_script:
  - apt-get update && apt-get install -y openjdk-17-jdk curl jq
  - export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64

build_apk:
  stage: build
  script:
    - npm install
    - chmod +x android/gradlew
    - cd android && ./gradlew assembleRelease
  artifacts:
    paths:
      - android/app/build/outputs/apk/release/app-release.apk
    expire_in: 1 week

deploy_to_buildshare:
  stage: deploy
  dependencies:
    - build_apk
  script:
    - curl -fsSL https://raw.githubusercontent.com/vishalkumardev/cli/main/install.sh | sh
    - export PATH="$HOME/.local/bin:$PATH"
    - buildshare login --token "$BUILDSHARE_TOKEN"
    - |
      buildshare upload ./android/app/build/outputs/apk/release/app-release.apk \
        --app "$BUILDSHARE_PROJECT_ID" \
        --notes "GitLab CI build $CI_COMMIT_SHORT_SHA on branch $CI_COMMIT_REF_NAME"
  variables:
    BUILDSHARE_TOKEN: $BUILDSHARE_TOKEN
    BUILDSHARE_PROJECT_ID: $BUILDSHARE_PROJECT_ID
  only:
    - main
    - master

On this page