HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Configuration of AWS CodePipeline for Android CI/CD

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
androidcodepipelineforawsconfiguration

Problem

I'm trying to set up a basic CI/CD pipeline for an Android project using AWS CodePipeline and I have 3 steps in the pipeline as follows:

  • Source: Pull project from GitHub repo



  • Build: Build the android app using a Docker image (futurenda/ android-sdk)



  • Test: Run instrumentation tests (Espresso tests)



Currently the Source and Build steps work fine (both are successful). From my understanding of running tests in CodePipeline, you can use CodeBuild and simply invoke the tests as you normally would from the command line. In this case, to invoke Espresso tests I can run sh gradlew connectedAndroidTest on my local machine.

I've set the pipeline up with the Build and Test steps being 2 separate CodeBuild projects, each with their own buildspec.yml file. For the Build step (which is working), the file is named buildspec-build.yml, and is found by CodeBuild without issue. However, for the Test step (not working) my buildspec.yml file is not found. They are both located in the root of my project (and confirmed to be pushed to my remote GitHub repo).

The error I receive is: stat /codebuild/output/src712781592/src/buildspec.yml: no such file or directory. This happens during the DOWNLOAD_SOURCE step in the CodeBuild project. I've checked to CodeBuild project to ensure it is indeed expecting a file named buildspec.yml.

Any ideas?

Here are both of my buildspec.yml files, if it matters:

buildspec-test.yml (found by CodeBuild):

version: 0.2
phases:
    build:
        commands:
          - $ANDROID_HOME/tools/bin/sdkmanager "build-tools;27.0.3" "platforms;android-27"
          - sh gradlew assembleDebug
    artifacts:
         files:
             - app/build/outputs/apk/debug/app-debug.apk
             #some other stuff here.


tester-buildspec.yml (not found by codebuild):

version: 0.2
phases:
  build:
    commands:
      - sh gradlew connectedAndroidTest
artifacts:
  files:
    #other stuff that doesn't really matter here


Just to rec

Solution

The indentation looks incorrect for the artifacts section in your buildspec-test.yml file. It is nested under the phases section. That way it is not being output properly and can't be picked up by the next build.

It should be the same as in your second file.

version: 0.2
phases:
  build:
    commands:
      - $ANDROID_HOME/tools/bin/sdkmanager "build-tools;27.0.3" "platforms;android-27"
      - sh gradlew assembleDebug
artifacts:
  files:
    - app/build/outputs/apk/debug/app-debug.apk
  #some other stuff here.

Code Snippets

version: 0.2
phases:
  build:
    commands:
      - $ANDROID_HOME/tools/bin/sdkmanager "build-tools;27.0.3" "platforms;android-27"
      - sh gradlew assembleDebug
artifacts:
  files:
    - app/build/outputs/apk/debug/app-debug.apk
  #some other stuff here.

Context

StackExchange DevOps Q#3965, answer score: 3

Revisions (0)

No revisions yet.