Help us understand the problem. What is going on with this article?

CircleCI 2.0の新しいDocker imageを利用して、Androidのビルドとdangerの実行を行う

More than 1 year has passed since last update.

CircleCI 2.0でAndroid関連の静的解析結果をPullRequestで指摘する - Qiita で、CircleCI側が用意したdockerイメージにRubyの実行環境が入っていなかったため、回りくどいことをしていました。
(workflowsを利用して、コードをattachしつつ、別のdockerイメージを動かす)

その記事をベトナムの子会社に共有して数時間後、 https://github.com/circleci/circleci-images/pull/75/files というPRを教えてもらいました。
CircleCIの提供しているdockerイメージに、Rubyの実行環境が入ったようです。
これを使うことで、Rubyのコンテナは必要なくなりそうです。

ということで、やってみました。

変更点例

https://github.com/noboru-i/SlideViewer/pull/79/files

一部消しすぎてたので、追加修正。
https://github.com/noboru-i/SlideViewer/pull/80/files

変更後の .circleci/config.yml

固有の部分や、重要じゃない部分などを省くと、下記のようなイメージになります。

version: 2

defaults: &defaults
  working_directory: ~/code
  docker:
    - image: circleci/android:api-26-alpha
  environment:
    JVM_OPTS: -Xmx3200m

jobs:
  build:
    <<: *defaults
    steps:
      - checkout
      - restore_cache:
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
      - run:
          name: Download Dependencies
          command: ./gradlew androidDependencies
      - save_cache:
          paths:
            - ~/.gradle
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}

      - restore_cache:
          key: gems-{{ checksum "Gemfile.lock" }}
      - run: bundle install --path vendor/bundle
      - save_cache:
          paths:
            - vendor/bundle
          key: gems-{{ checksum "Gemfile.lock" }}

      - run:
          name: Check lint
          command: ./gradlew :app:check -x test
      - run:
          name: Run danger
          command: bundle exec danger

      - run:
          name: Build apk
          command: ./gradlew :app:assembleDebug
      - store_artifacts:
          path: app/build/outputs/apk/app-debug.apk
          destination: app-debug.apk
      - persist_to_workspace:
          root: ~/code
          paths:
            - .

  deploy:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/code
      - run:
          name: Build apk
          command: ./gradlew :app:assembleRelease
      - store_artifacts:
          path: app/build/outputs/apk/app-release.apk
          destination: app-release.apk
workflows:
  version: 2
  build_and_deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master

これで、前回と同じようなdangerの実行を、CircleCI 2.0のスピードで実行できるようになりました。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away