State of the cordova scanner

We decided to use the cordova-cli to build cordova projects, instead of solving the build with our existing step.

We started to solve the automation using our existing build steps (xcode-archive for ios and gradle-runer for android). But during the implementation we faced with a several edge case, which is handled in cordova cli.

For example:

  • install gradle wrapper for the generated android project, with desired gradle version
  • properly configure the xcodebuild tool for ios builds

The scanner

The scanner tries to create an initial config for a cordova project with a ci and cd workflows.

The CI workflow

Currently the scanner is able to detect jasmine and karma-jasmine test frameworks.

When the scanner is looking for karma-jasmine tests:

  • it parses the package.json file and looks for karma-jasmine in dependencies and devDependencies

If package.json does not exist or does not have karma-jasmine dependencies or devDependencies, the scanner will not add karma-jasmine-runner step to your workflow.

  • search for karma.conf.js config file in the same directory where your cordova project’s config.xml exist.

If karma.conf.js does not exist (in the same directory where your cordova project’s config.xml exist), the scanner will not add karma-jasmine-runner step to your workflow.

karma-jasmine-runner step’s main command: karma "start" "--single-run"

When the scanner is looking for jasmine tests:

  • it parses the package.json file and look for jasmine in dependencies and devDependencies

If package.json does not exist or does not have jasmine dependencies or devDependencies, the scanner will not add jasmine-runner step to your workflow.

  • search for jasmine.json config file in CORDOVA_PROJECT_ROOT/spec/support/jasmine.json.

If jasmine.json does not exist (in CORDOVA_PROJECT_ROOT/spec/support/jasmine.json), the scanner will not add jasmine-runner step to your workflow.

jasmine-runner step’s main command: jasmine

If the scanner does not detect jasmine or karma-jasmine tests, your config will contain only a release workflow with cordova-archive step.

The Test workflow will contains:

  • activate-ssh-key + git-clone + script steps (just like all of our initial workflow)
  • test step
  • deploy-to-bitrise-io step to attach the generated artifacts to your build

The CD workflow

The deploy workflow will contain:

  • activate-ssh-key + git-clone + script steps (just like all of our initial workflow)
  • test step (if the scanner contains either jasmine or karma-jasmine tests)
  • certificate-and-profile-installer step (to install your ios code sign files)
  • generate-cordova-build-configuration step to apply your ios and/or android code sign settings (by generating the build.json file)
  • cordova-archive step to build your cordova project
  • deploy-to-bitrise-io step to attach the generated artifacts to your build

cordova archive step’s commands:

  • cordova "platform" "rm" "<platform>"
  • cordova "platform" "add" "<platform>"
  • cordova "build" "--debug|--release" "--device|--emulator" "<platform>" "--buildConfig=$BITRISE_CORDOVA_BUILD_CONFIGURATION"
1 Like

@godreikrisztian i think the scanner cover the use cases I have, with just a small question on getting the keystore for signing the android apk. Am I correct in assuming the generate-cordova-build-configuration will handle downloading the .keystore file into the project, or does a file downloader step need to be added too?

1 Like

Hi @nhammond,
thanks for your response!

The Generate cordova build configuration step has an input: keystore_url, you can pass remote keystore URL or local file path as well

For remote keystores you can provide any download location (ex: https://URL/TO/keystore.jks). For local keystores, provide file path url. (ex: file://PATH/TO/keystore.jks).

In case of remote URL, the step manages to download your keystore and pass the downloaded file’s path to the build.json file.

So no download step will be required.

Today i will share the cordova steps, publish the new scanner and write a topic about cordova code signing on Bitrise as well.

1 Like

excellent! covers everything on my end

1 Like

@godreikrisztian should we mark this thread as “solved”?

why the cordova-archive step add or remove/add the platforms before running the build command??

Adding the platform again makes cordova to resolve again the platform version, instead of using the one already declared in the config.xml and package.json

Wouldn’t be better to run cordova prepare, or cordova prepare <platform> ?? this way the platform used is the one already “locked” in the config files…

1 Like

I believe there’s a technical reason for this, related to older cordova CLI version, but will check it with the tooling team :slight_smile:

Hi @blackjid,
the cordova-archive v1.0.0 has an input (Should remove platforms as prepare step?) which you can use to control if the step should remove the platforms or not.

1 Like

hey @godreikrisztian

I’m using that input right now, and it’s working ok for me. I guess the cordova prepare command also triggers platform add if no platforms are installed which made more sense for me to use. But I’m ok with the way the steps works now.

thanks

1 Like