Skip to content
← Back to activity

Solution skill

android environment using docker and bitbucket pipelines

Version 2Sign in to save

Complete solution

Guide android environment using docker and bitbucket pipelines: If I understand your question correctly: you technically don't even need to install Docker on your local machine in order to use it in your Bitbucket Pipelines (although it can be quite helpful for. Use this when you hit exactly this in android. Not for different errors or different tools.

TL;DR: If I understand your question correctly: you technically don't even need to install Docker on your local machine in order to use it in your Bitbucket Pipelines (although it can be quite helpful for debugging). Bitbucket Pipelines can be configured to use a Docker from Docker Hub , and the one you mentioned ( uber/android-build-environment ) worked well for me.

If I understand your question correctly: you technically don't even need to install Docker on your local machine in order to use it in your Bitbucket Pipelines (although it can be quite helpful for debugging).

Bitbucket Pipelines can be configured to use a Docker from Docker Hub , and the one you mentioned ( uber/android-build-environment ) worked well for me.

Simply add a bitbucket-pipelines.yml to the root of your project, for example:

[code: image: uber/android-build-environment:latest

pipelines: default:

  • step:

script:

  • build.sh ]

I like to organize my build process in it's own ash script file (build.sh) but that is optional (you could instead put multiple bulleted commands in the yaml file under the script directive). Examples of (and more details about) the bitbucket-pipelines.yml file can be found on the Language guides for Bitbucket Pipelines page.

My build.sh script (also in the root of the project, but could be placed in a subdirectory as long as you refer to it as such in your bitbucket-pipelines.yml, e.g. scripts/build.sh):

[code: #!/bin/sh

mkdir "${ANDROIDHOME}/licenses" || true echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROIDHOME}/licenses/android-sdk-license"

./gradlew assembleDebug ]

The licenses portion allows the Android Gradle process to automatically download Android dependencies for you, as mentioned in this answer .

For good measure, set the permissions on the build script accordingly:

[code: git update-index --chmod=+x build.sh ]

Make sure that you've enabled Bitbucket Pipelines (from your repo page: Settings -> Pipelines: Settings -> Enable Pipelines).

Then just commit the bitbucket-pipelines.yml and build.sh and push to your BitBucket repo. The Bitbucket Pipelines build for your project should begin shortly after your push. The Bitbucket Pipelines will download the uber/android-build-environment Docker from Docker Hub and checkout your project and run the build.sh script within the Docker.

The process you were describing of setting up the Docker on your local machine can be really helpful if your Bitbucket Pipelines build fails and you want to have the same environment running on your local machine so you can experiment with it and test changes to the build.sh script before actually committing and pushing to your repo.

Might also prove helpful

When to use

You hit exactly this: android environment using docker and bitbucket pipelines in android.

When not to use

A different error, or the same symptom in a different tool. This page only covers the failure above.

Compatibility

android.

Evidence

Asked on Stack Overflow so:39806261: Stack Overflow #39806261 (score 28, top-voted answer, 25 votes): I am very new to Bitbucket pipelines (Beta) and docker.No previous experience on CI integration

I followed this question , But no clear description for beginners

I am trying to set up Continuous Integration (CI) in Bitbucket Pipelines for Android Project using docker container

I want to use my previous android project with this container

Steps I followed

Step 1 . Installed Docker Software tools . Successfully installed.

Step 2 . Created Virtual Machine Successfully

Step 3 . Created container from Kitematic (B The verified fix/answer: If I understand your question correctly: you technically don't even need to install Docker on your local machine in order to use it in your Bitbucket Pipelines (although it can be quite helpful for debugging).

Bitbucket Pipelines can be configured to use a Docker from Docker Hub , and the one you mentioned ( uber/android-build-environment ) worked well for me.

Simply add a bitbucket-pipelines.yml to the root of your project, for example:

[code: image: uber/android-build-environment:latest

pipelines: default:

  • step:

script:

  • build.sh ]

I like to organize my build process in it's own ash script file (build.sh) but that is optional (you could instead put multiple bulleted commands in the yaml file under the script directive). Examples of (and more details about) the bitbucket-pipelines.yml file can be found on the Language guides for Bitbucket Pipelines page.

My build.sh script (also in the root of the project, but could be placed in a subdirectory as long as you refer to it as such in your bitbucket-pipelines.yml, e.g. scripts/build.sh):

[code: #!/bin/sh

mkdir "${ANDROIDHOME}/licenses" || true echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROIDHOME}/licenses/android-sdk-license"

./gradlew assembleDebug ]

The licenses portion allows the Android Gradle process to automatically download Android dependencies for you, as mentioned in this answer .

For good measure, set the permissions on the build script accordingly:

[code: git update-index --chmod=+x build.sh ]

Make sure that you've enabled Bitbucket Pipelines (from your repo page: Settings -> Pipelines: Settings -> Enable Pipelines).

Then just commit the bitbucket-pipelines.yml and build.sh and push to your BitBucket repo. The Bitbucket Pipelines build for your project should begin shortly after your push. The Bitbucket Pipelines will download the uber/android-build-environment Docker from Docker Hub and checkout your project and run the `buil Source: https://stackoverflow.com/questions/39806261/android-environment-using-docker-and-bitbucket-pipelines

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_QySovucaFQOC2TlB08QN7Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">android environment using docker and bitbucket pipelines <span>— Vectle</span></a>