0

I have an Android library project with two Unit test, and those tasks defined in the Gradle:

task("cleanProject", dependsOn: "clean", group: "myGroup")

task("generateAAR", dependsOn: "assembleRelease", group: "myGroup")

task("copyAAR", type: Copy, group: "myGroup") {
    from "${project.rootDir}/project/build/outputs/aar"
    into "${project.rootDir}/mydir/aar"
}

and I tried to use Azure pipelines by adding the following .yml:

    - task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    tasks: 'cleanProject'
  displayName: Clean Project

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    tasks: 'testReleaseUnitTest'
  displayName: Release Unit Test

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    tasks: 'generateAAR'
  displayName: Generate AAR Lib

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    tasks: 'copyAAR'
  displayName: Copy AAR Lib

It works nicely, but I noticed that the test are performed also on generateAAR and copyAAR tasks, resulting in 6 total test passed. Is there a way to exclude the tests from a specific task or pipeline?

Thanks in advance.

2 Answers2

1

Is there a way to exclude the tests from a specific task or pipeline?

Azure devops service itself doesn't have the option to exclude tests from one task.(test level) Instead it supports disabling/skipping task in pipeline.(task level)

Check gradle's skipping the tests and skipping the tasks, I think that's what you're looking for.

LoLance
  • 25,666
  • 1
  • 39
  • 73
0

I know it has been a while, but maybe somebody find my answer useful, because there is a way to do it, at least it works for us in the project. Gradle Task for azure has an "options" argument, see the official docs:

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/gradle?view=azure-devops

enter image description here

This means that your final solution will look sth like this:

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    tasks: 'generateAAR'
    options: '-x test -x integrationTest' // exclude both test and IT
  displayName: Generate AAR Lib
gajo
  • 729
  • 3
  • 10
  • 19