androidjava-8gitlabjava-11gitlab-autodevops

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)


I'm utilizing the gitlab auto devops android template Android.gitlab-ci.yml here but it's using a java 8 image (whereas I want to use java 11). Also, it has ANDROID_COMPILE_SDK set to "29" and I want to compile my app with the latest version - currently 31.


Solution

  • There is another "latest" template file named Android.latest.gitlab-ci.yml which can be found on gitlab here . At time of writing it sets image to "openjdk:11-jdk" and COMPILE_SDK to "30". See relevant gitlab MR/discussion for more context.

    So, if you just want to use whatever is in the template, your .gitlab-ci.yml just needs to look like this:

    include:
      - template: Android.latest.gitlab-ci.yml
    

    That's all you need.

    At time of writing that sets ANDROID_COMPLE_SDK to "30". So, if you want to bump that up and set it yourself, it's as simple as adding it to that file. For instance:

    include:
      # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Android.latest.gitlab-ci.yml
      - template: Android.latest.gitlab-ci.yml
    
    variables:
      ANDROID_COMPILE_SDK: "31"
      ANDROID_BUILD_TOOLS: "31.0.0"
    

    Just remember that if/when someone updates the template to say, "32", you'll still be using "31". The choice is yours: