Package builds on Appflow using the Ionic CLI


This feature is only available on our Scale plan. Please contact us to enable this feature.

It is possible to trigger Package builds on Appflow directly from the CLI. This is extremely useful if you need to integrate the Package build step as part of an existing external CI/CD process.


Upgrade the Ionic CLI to at least version 4.7.0.

To trigger Package builds on Appflow from the Ionic CLI, a proper subscription to run Package builds is needed.

To use Environments, a proper subscription that allows the usage of Automations is needed.


The Ionic CLI has to be authenticated on Appflow to be able to trigger a Package build.

To login type:

$ ionic login <email> <password>

This will prompt for the Appflow username/password.

The CLI can also be authenticated via an environment variable (for example, if it is used during a CI/CD task).

To set up the authentication via environment variable, first login via the CLI with an Appflow user who has access to the app you want to trigger Deploy builds for:

$ ionic login <email> <password>

Then, export the authentication token:

$ ionic config get -g tokens.user

Prevent the CLI from invalidating the token:

ionic config unset -g tokens.refresh
ionic config unset -g tokens.user

Finally, export the token in an environment variable of your shell or your CI/CD service.

$ export IONIC_TOKEN=<your token>

Link the app#

Your app must be linked to the remote app on Appflow. If the app is not linked yet, run:

$ ionic link <app id>

and commit the changes to ionic.config.json.

Trigger a package build#

Currently, Package builds can only be triggered from the root project directory:

$ cd /path/to/your/app

Assuming the CLI is authenticated, to trigger a Package build, run:

$ ionic package build

This will prompt for the desired platform (ios/android) and build type for the platform.

For iOS or Android release builds, a valid signing certificate is required and can be specified using the --signing-certificate=<name> option.

For information on setting up signing certificates, see here.

The previous commands can be executed in a single step:

$ ionic package build ios development --signing-certificate="My Signing Certificate"

Once the build is successfully triggered, the CLI will automatically start tailing the logs from Appflow and, if the build is successful, download the apk/ipa file in the current directory.

Customize the package build with Options#

The Options available to customize the build include:

  • --environment=<name> to specify the group of environment variables to be exposed to the build (available only with Automation; more info about environments are available here)
  • --native-config=<name> to specify the group of native config variables to be exposed to your build (more info about native configs are available here)

Customize the package build with Advanced Options#

The Advanced Options available to customize the build include:

  • --commit=<sha1> The commit defaults to HEAD; to use a different commit you can use this option with the full SHA1 of the commit
  • --build-stack=<name> This option is mostly useful for iOS builds if for any reason a package build with a specific version of Xcode is needed. If this is omitted the preferred version is used.
  • --artifact-type Specify which artifacts to download after a successful build. Options are apk, ipa, aab and dsym. Note: If this option is specified, unavailable artifacts will trigger an error code from the CLI.
  • --build-file-name=<name> (Deprecated v6.13) To override the downloaded file name use this option. This might be useful, for instance, in a CI build to have a consistent name for the produced artifact. Note: This will override only apk or ipa on Android and iOS respectively.
  • --apk-name=<name> To override the Android apk downloaded file name
  • --aab-name=<name> To override the Android aab downloaded file
  • --ipa-name=<name> To override the iOS ipa downloaded file
  • --dsym-name=<name> To override the iOS dsym downloaded file

Note about referencing Options values by name#

Names are case sensitive and need to be specified including spaces, for instance:

$ ionic package build ios development --signing-certificate="iOS Dev"

Apart from the --commit option, all others require the full name setup within the Appflow Dashboard.

Look for the name on the signing certificate, Environments and Native Configs pages in Appflow:

Signing Certificates Environments Native Configs

For the build stack, use one of the strings identifying the platform in the Applflow Package Build form:

Target Platform