Generating release outputs for Cordova

Create your bitrise project

On the bitrise.io website add your cordova project. Once the scanner finished, you have to select which platform(s) to build.

If your project contains either jasmin or karma-jasmine test, the scanner generates two workflows for you.

The primary is a ci like workflow it contains the test step:

  primary:
    steps:
    - activate-ssh-key:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone: {}
    - script:
        title: Do anything with Script step
    - npm:
        inputs:
        - command: install
    - karma-jasmine-runner: {}
    - deploy-to-bitrise-io: {}

The another workflow is called deploy, it is a workflow to achieve cd, by default it builds for emulator:

  deploy:
    steps:
    - activate-ssh-key:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone: {}
    - script:
        title: Do anything with Script step
    - npm:
        inputs:
        - command: install
    - karma-jasmine-runner: {}
    - generate-cordova-build-configuration: {}
    - cordova-archive:
        inputs:
        - platform: "$CORDOVA_PLATFORM"
        - target: emulator
    - deploy-to-bitrise-io: {}

If your project does not contain jasmin or karma-jasmine test the scanner generates only one workflow (primary) which is prepared to build for emulator:

  primary:
    steps:
    - activate-ssh-key:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone: {}
    - script:
        title: Do anything with Script step
    - npm:
        inputs:
        - command: install
    - generate-cordova-build-configuration: {}
    - cordova-archive:
        inputs:
        - platform: "$CORDOVA_PLATFORM"
        - target: emulator
    - deploy-to-bitrise-io: {}

Build for device

To build for device you would need to upload your code signing files per platform. After that, update the Generate cordova build configuration step, this step will generate a build.json file which controls the cordova-cli’s code singing. Then update the Cordova archive step to target to device.

  1. Upload your code signing files
  • Upload your ios provisioning profile and code sign identity to Bitrise (Workflow/Code Signing tab), if you want to build for ios.
  • Upload your android keystore to bitrise (Workflow/Code Signing tab), if you want to build for android.
  1. Update the Generate cordova build configuration step
  • Navigate to the Workflow Editor/Workflows tab and select Generate cordova build configuration step
  • Set the Build configuration input as desired
  • For ios code signing fill: Development Team, Code Sign Identity, Provisioning Profile and Packaging Type
  • For android code singing: the required inputs (Keystore, Keystore password, Alias and Password) are fulfilled with the default env vars generated when you uploaded your keystore ($BITRISEIO_ANDROID_KEYSTORE_URL, BITRISEIO_ANDROID_KEYSTORE_PASSWORD, BITRISEIO_ANDROID_KEYSTORE_ALIAS, BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD)
  1. Update the Cordova archive step
  • Navigate to the Workflow Editor/Workflows tab and select Cordova archive step
  • Set the Build command target input’s value to device

Run a new build, once it finishes you can test the signed ipa and apk files.

1 Like