Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Caching on Bitrise Android

Caching on Bitrise Android

When using caching on Bitrise, you would use cache-pull&csche-push steps. In this talk I talked about how to use them and how we can customize to enable/disable caching using git command and envman tool.

Shohei Kawano

August 16, 2018
Tweet

More Decks by Shohei Kawano

Other Decks in Technology

Transcript

  1. •Stored securely in Amazon S3 •Per specific branches •By default:

    will be deleted after 7 days without any build Caching on Bitrise
  2. •cache-pull •Pull cache from remote server if available •cache-push •Check

    if cache needs to be updated •Upload the caching content if required Caching Steps
  3. cache-pull _prepare: title: Prepare fastlane steps: - script: inputs: -

    content: |- bundle install --path vendor/bundle - cache-pull: {}
  4. cache-pull _prepare: title: Prepare fastlane steps: - script: inputs: -

    content: |- bundle install --path vendor/bundle - cache-pull: {}
  5. cache-push _cache: title: Cache gradle and maven dependencies steps: -

    cache-push: inputs: - cache_paths: |- $HOME/.gradle ./.gradle $HOME/.m2 - ignore_check_on_paths: |- $HOME/.gradle/caches/*.lock ./.gradle/*.lock ./.gradle/*.bin
  6. cache-push _cache: title: Cache gradle and maven dependencies steps: -

    cache-push: inputs: - cache_paths: |- $HOME/.gradle ./.gradle $HOME/.m2 - ignore_check_on_paths: |- $HOME/.gradle/caches/*.lock ./.gradle/*.lock ./.gradle/*.bin
  7. Workflow test: title: Run unit test before_run: - _prepare after_run:

    - _cache steps: - script: inputs: - content: |- bundle exec fastlane test
  8. Workflow test: title: Run unit test before_run: - _prepare after_run:

    - _cache steps: - script: inputs: - content: |- bundle exec fastlane test
  9. _parepareCacheEnv: title: Set environment variable if we can use cache

    or not steps: - script: inputs: - content: |- if [[ -n $(git diff-tree --no-commit-id —name-only -r $GIT_CLONE_COMMIT_HASH -- find -name 'versions.gradle' ‘app/build.gradle') ]] then envman add --key USE_CACHE --value "false" echo "_parepareCacheEnv result: USE_CACHE == false" else envman add --key USE_CACHE --value "true" echo "_parepareCacheEnv result: USE_CACHE == true" fi
  10. _parepareCacheEnv: title: Set environment variable if we can use cache

    or not steps: - script: inputs: - content: |- if [[ -n $(git diff-tree --no-commit-id —name-only -r $GIT_CLONE_COMMIT_HASH -- find -name 'versions.gradle' ‘app/build.gradle') ]] then envman add --key USE_CACHE --value "false" echo "_parepareCacheEnv result: USE_CACHE == false" else envman add --key USE_CACHE --value "true" echo "_parepareCacheEnv result: USE_CACHE == true" fi
  11. _parepareCacheEnv: title: Set environment variable if we can use cache

    or not steps: - script: inputs: - content: |- if [[ -n $(git diff-tree --no-commit-id —name-only -r $GIT_CLONE_COMMIT_HASH -- find -name 'versions.gradle' ‘app/build.gradle') ]] then envman add --key USE_CACHE --value "false" echo "_parepareCacheEnv result: USE_CACHE == false" else envman add --key USE_CACHE --value "true" echo "_parepareCacheEnv result: USE_CACHE == true" fi
  12. _parepareCacheEnv: title: Set environment variable if we can use cache

    or not steps: - script: inputs: - content: |- if [[ -n $(git diff-tree --no-commit-id —name-only -r $GIT_CLONE_COMMIT_HASH -- find -name 'versions.gradle' ‘app/build.gradle') ]] then envman add --key USE_CACHE --value "false" echo "_parepareCacheEnv result: USE_CACHE == false" else envman add --key USE_CACHE --value "true" echo "_parepareCacheEnv result: USE_CACHE == true" fi
  13. _parepareCacheEnv: title: Set environment variable if we can use cache

    or not steps: - script: inputs: - content: |- if [[ -n $(git diff-tree --no-commit-id —name-only -r $GIT_CLONE_COMMIT_HASH -- find -name 'versions.gradle' ‘app/build.gradle') ]] then envman add --key USE_CACHE --value "false" echo "_parepareCacheEnv result: USE_CACHE == false" else envman add --key USE_CACHE --value "true" echo "_parepareCacheEnv result: USE_CACHE == true" fi
  14. test: title: Run unit test before_run: - _parepareCacheEnv - _prepare

    after_run: - _cache steps: - script: inputs: - content: |- bundle exec fastlane test
  15. test: title: Run unit test before_run: - _parepareCacheEnv - _prepare

    after_run: - _cache steps: - script: inputs: - content: |- bundle exec fastlane test
  16. test: title: Run unit test before_run: - _parepareCacheEnv - _prepare

    after_run: - _cache steps: - script: inputs: - content: |- bundle exec fastlane test
  17. _prepare: title: Prepare fastlane steps: - script: inputs: - content:

    |- bundle install --path vendor/bundle - cache-pull: run_if: '{{getenv "USE_CACHE" | eq "true"}}'
  18. _prepare: title: Prepare fastlane steps: - script: inputs: - content:

    |- bundle install --path vendor/bundle - cache-pull: run_if: '{{getenv "USE_CACHE" | eq "true"}}'
  19. •Use cache-pull & cache-push steps for enabling caching on Bitrise

    •Configuration may be required •Ask Bitrise team for help :) Summary