Documentation

Go to Portal Website

CI/CD Integration - CircleCI

Overview

The apptego/mobile-protect CircleCI orb protects Android and iOS build artifacts inside your CircleCI workflow. It uploads your Android APK or iOS IPA to AppTego, waits for protection to complete, and returns the protected artifact for signing, testing, storage, or release.

The orb validates Android inputs as .apk files and iOS inputs as .ipa files. For Android App Bundle (.aab) workflows, use the Automation API or the AppTego Portal upload flow.

Use this integration when CircleCI is already the place where your release candidates are built and stored. The orb uses standard CircleCI primitives and requires curl, jq, bc, and standard shell utilities in the execution image.

Quick Start

Store your AppTego automation key in CircleCI as APPTEGO_API_KEY, persist the mobile artifact from your build job, then add the orb to .circleci/config.yml:

version: 2.1

orbs:
  apptego: apptego/mobile-protect@1.0.0

jobs:
  build:
    docker:
      - image: cimg/android:2024.10.1
    steps:
      - checkout
      - run:
          name: Build APK
          command: ./gradlew assembleRelease
      - persist_to_workspace:
          root: .
          paths:
            - app/build/outputs/apk/release/

workflows:
  build-and-protect:
    jobs:
      - build
      - apptego/protect:
          requires:
            - build
          file-path: app/build/outputs/apk/release/app-release.apk
          platform: android
          version: prod

Authentication

  1. Sign in to the AppTego Portal.
  2. Open Automation Keys.
  3. Create a key and copy the full value in key_id:key_secret format.
  4. In CircleCI, open Project Settings -> Environment Variables.
  5. Add APPTEGO_API_KEY with the full key as the value.

For organization-wide reuse, store the same variable in a CircleCI Context and attach that context only to workflows allowed to protect mobile artifacts.

Protect Job

The orb provides a convenience job named apptego/protect. It attaches a workspace from upstream jobs and runs the protect command against the configured mobile artifact. Use output-path when you need a predictable protected filename; use the command form inside your own job when you need precise control over artifact storage, signing, or downstream handoff.

ParameterRequiredDefaultDescription
file-pathYes-Path to the .apk or .ipa file.
platformYes-android or ios.
api-keyNoAPPTEGO_API_KEYName of the environment variable holding the automation key.
api-urlNohttps://api.apptego.comAppTego API base URL.
versionNoprodConfiguration version: dev, staging, or prod.
output-pathNoInput file with -protected suffixOutput path for the protected binary.
poll-intervalNo15Seconds between status checks.
timeoutNo1800Maximum seconds to wait for completion.
workspace-pathNo.Path where the upstream workspace is attached.
persist-outputNotruePersist root-level *.apk and *.ipa files for downstream jobs.

The convenience job's persist-output behavior is based on root-level APK/IPA glob patterns. If downstream jobs need the protected output, set output-path to a root-level file such as app-protected.apk, or use the protect command in your own job and explicitly store or persist the configured output-path.

Protect Command

Use the protect command inside your own job when you need full control over workspace attachment, signing, test execution, artifact naming, or release gates:

version: 2.1

orbs:
  apptego: apptego/mobile-protect@1.0.0

jobs:
  build-and-protect:
    docker:
      - image: cimg/android:2024.10.1
    steps:
      - checkout
      - run: ./gradlew assembleRelease
      - apptego/protect:
          file-path: app/build/outputs/apk/release/app-release.apk
          platform: android
          version: staging
          output-path: output/app-staging-protected.apk
          timeout: 3600
      - store_artifacts:
          path: output/app-staging-protected.apk
          destination: protected-apk

workflows:
  main:
    jobs:
      - build-and-protect

Examples

Android APK

workflows:
  protect_android:
    jobs:
      - apptego/protect:
          file-path: app/build/outputs/apk/release/app-release.apk
          platform: android
          version: prod

Android App Bundle

The CircleCI orb does not accept .aab files because its Android input validation requires .apk. Use the Automation API for App Bundle workflows.

iOS IPA

workflows:
  protect_ios:
    jobs:
      - apptego/protect:
          file-path: build/MyApp.ipa
          platform: ios
          version: prod

Outputs

After a successful protect step, the orb exports these variables through $BASH_ENV for later steps in the same job:

VariableDescription
AF_JOB_IDAppTego protection job ID.
AF_STATUSFinal status, normally completed.
AF_OUTPUT_FILEPath to the downloaded protected file.
AF_DURATIONTotal protection time in seconds.

Large File Support

Files 100 MB or larger use AppTego multipart upload automatically. No workflow changes are required.

Release Workflow Tips

TipWhy it helps
Persist the exact mobile artifact path from the build job.The protection job can only upload files available in its workspace.
Use CircleCI Contexts for production secrets.Limits who and what can access automation keys.
Keep Android and iOS jobs separate.Lets each platform use the right image, runner, and timeout.
Store the protected artifact and AppTego job ID.Makes support and release audit easier.
Run downstream tests against the protected output.Confirms the artifact you plan to ship.

Troubleshooting

ErrorLikely causeFix
401 - Invalid API keyKey is missing, expired, or malformedRecreate the automation key and update APPTEGO_API_KEY.
400 - Missing required fieldRequired parameter missing, invalid, or using an unsupported extensionCheck file-path, platform, version, and the file extension.
Timed outProtection did not finish within timeoutIncrease timeout or inspect the build in AppTego.
File not foundThe artifact path is wrong or the workspace was not attachedConfirm the upstream build persisted the exact file path.
jq: command not found or bc: command not foundExecution image does not include a required utilityUse a CircleCI image with curl, jq, and bc, or install them before the protect step.
Orb command not foundOrb import missing or misspelledConfirm apptego: apptego/mobile-protect@1.0.0 is declared under orbs.
429 build limit errorConcurrent build limit reachedWait for in-progress protection jobs to finish or adjust workflow parallelism.