0
votes

I have a problem with building Android with jenkins on ubuntu. The application build.gradle contains debug and release. When I try to build with gradlew assembleDebug or assembleRelease I get "task not foundTask 'assembleRelease' not found in root project 'My Application'" (instead clean and assemble work fine)

Same error if I try to manually gradlew assembleDebug on jenkis workspace folder, instead I can build on my laptop where I cloned the repo.

Build.gradle contains debug and release:

buildTypes {
    debug{
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),    'proguard-rules.pro'
    }
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android- optimize.txt'), 'proguard-rules.pro'
    }
}

This is the folder ls -latr:

drwxr-xr-x  4 jenkins jenkins 4096 Nov  6 22:31 ..
drwxr-xr-x  3 jenkins jenkins 4096 Nov  6 22:31 .idea
-rw-r--r--  1 jenkins jenkins  222 Nov  6 22:31 .gitignore
- rw-r--r--  1 jenkins jenkins 1184 Nov  6 22:31 gradle.properties
drwxr-xr-x  3 jenkins jenkins 4096 Nov  6 22:31 gradle
-rw-r--r--  1 jenkins jenkins  689 Nov  6 22:31 build.gradle
-rw-r--r--  1 jenkins jenkins   51 Nov  6 22:31 settings.gradle
-rw-r--r--  1 jenkins jenkins 2260 Nov  6 22:31 gradlew.bat
drwxr-xr-x  3 jenkins jenkins 4096 Nov  6 22:31 wrapper
drwxr-xr-x  4 jenkins jenkins 4096 Nov  6 22:32 native
drwxr-xr-x  3 jenkins jenkins 4096 Nov  6 22:32 notifications
drwxr-xr-x  3 jenkins jenkins 4096 Nov  6 22:32 daemon
drwxr-xr-x  3 jenkins jenkins 4096 Nov  6 22:33 build-scan-data
drwx------  7 jenkins jenkins 4096 Nov  6 22:33 caches
drwx------  5 jenkins jenkins 4096 Nov  6 22:33 .gradle
-rwxr-xr-x  1 jenkins jenkins 5296 Nov  6 22:41 gradlew
drwxr-xr-x 13 jenkins jenkins 4096 Nov  6 22:41 .
 drwxr-xr-x  8 jenkins jenkins 4096 Nov  6 22:41 .git
 drwxr-xr-x  3 jenkins jenkins 4096 Nov  6 22:48 app

What can I do?

1
Can you manually build the package, right after checking out from SCM? - Martin Zeitler
hi @MartinZeitler do you mean building using jenkins file? (sorry I'm new to jenkins) - gianpaolo
It's a nightmare. Task 'compileDebugSources' not found in root project 'My Application'. I pasted the jenkins file here: pastebin.com/TbW9xWFQ - gianpaolo

1 Answers

0
votes

in my opinion this is a bit crazy. I created a jenkins file as per @Martin suggestion b anyway, found out that setting ANDROID_HOME in the jenkins env is not enough and I don't know why. So I ended up adding ANDROID_HOME at every stage: If anyone knows a better solution, add a comment.

stage('Compile') {
  environment {
       ANDROID_HOME="/home/jenkins-bot/androis-sdk"
       //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
  }
  steps {
    // Compile the app and its dependencies
    sh './gradlew compileDebugSources --scan'
  }
}