# Codemagic

Store `APPBARN_TOKEN` in a protected Codemagic variable group and run the CLI after the artifact is produced.

```yaml
scripts:
  - name: Upload to AppBarn
    script: |
      npm install --global appbarn-cli
      appbarn config set api https://api.app-barn.com
      appbarn config set app "$APPBARN_APP_ID"
      appbarn config set environment "$APPBARN_ENVIRONMENT_ID"
      appbarn upload ./build/app.apk --app-identifier "$APPBARN_APP_IDENTIFIER" --version "$APPBARN_VERSION" --build-number "$APPBARN_BUILD_NUMBER"
```

AppBarn detects Codemagic provenance from standard environment variables.

::: details AI prompt — Add a Codemagic upload (Copilot, Codex, Cursor)

```text
Inspect codemagic.yaml and mobile artifact output. Add an AppBarn CLI script after the selected IPA/APK/AAB is built. Configure the API and real App/Environment UUIDs, read APPBARN_TOKEN from a protected Codemagic variable group and use non-secret variables for Android identity. Preserve existing stages and native provenance. Ask about missing targets, groups or artifact paths, never log credentials, and validate YAML.
```

:::

## Common failures

Confirm the variable group is attached to the workflow and the artifact path matches the platform build output. Do not include bearer values in build logs.

## Related

- [Upload](/cli/upload)
- [Provenance](/reference/provenance)
