5

I'm trying to test and build my android app using Jenkins locally on my machine. I'm on Linux and I launched Jenkins through docker by running the following command:

docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins

Then I opened up my browser and fired Jenkins from localhost:8080. After the initial setup, I added the environment variable with following steps:

  1. Go to Manage Jenkins
  2. Configure System
  3. Go to Global Properties
  4. Check Environment variables
  5. Add ANDROID_SDK_ROOT and ANDROID_HOME environment variables in there
  6. Click Apply and Save

Here's how it looks in Jenkins on my machine: enter image description here

Basically followed steps from this answer: https://stackoverflow.com/a/29231580/4954322

I also added the same environment variables in my ~/.zshrc file too:

export ANDROID_SDK_ROOT=/home/harry/Android/Sdk/
export ANDROID_HOME=/home/harry/Android/Sdk/

I'm using Use Gradle Wrapper in the Build section of the project configuration with the following commands:

clean
testDebugUnitTes
assembleDebugBuild

After following all of these steps, my build is still failing with message:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable
or by setting the sdk.dir path in your project's local properties 
file at '/var/jenkins_home/workspace/MeteorDebugBuild/local.properties'.

My question is how can I fix this error and why the build is still failing with all of this setup?

Harry
  • 1,151
  • 11
  • 27

1 Answers1

0

I think docker containers are isolated from your Jenkins, which means that inside the container there are no environment variables ANDROID_SDK_ROOT and ANDROID_HOME. What you want is:

docker run -e ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT} -e ANDROID_HOME=${ANDROID_HOME} -p 8080:8080 -p 50000:50000 jenkins/jenkins

I have not checked whether it works, but I hope it may be the solution to your problem

sharkzeeh
  • 59
  • 1
  • 4