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 forkarma-jasmine
independencies
anddevDependencies
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 forjasmine
independencies
anddevDependencies
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 inCORDOVA_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"