跳过对 Azure 管道特定任务的 android 测试
Skip test on android on specific task of Azure pipeline
我有一个带有两个单元测试的 Android 库项目,那些任务定义在 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"
}
我尝试通过添加以下 .yml 来使用 Azure 管道:
- 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
它运行良好,但我注意到测试也在 generateAAR 和 copyAAR 任务上执行,导致总共通过了 6 个测试。有没有办法从特定任务或管道中排除测试?
提前致谢。
Is there a way to exclude the tests from a specific task or pipeline?
Azure devops 服务本身没有从一项任务中排除测试的选项。(测试级别)相反,它支持管道中的 disabling/skipping 任务。(任务级别)
检查 gradle 的 skipping the tests and skipping the tasks,我想这就是您要找的。
我知道已经有一段时间了,但也许有人觉得我的回答有用,因为有一种方法可以做到,至少它对我们的项目有用。
Gradle Azure 的任务有一个“选项”参数,请参阅官方文档:
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/gradle?view=azure-devops
这意味着您的最终解决方案将如下所示:
- 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
我有一个带有两个单元测试的 Android 库项目,那些任务定义在 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"
}
我尝试通过添加以下 .yml 来使用 Azure 管道:
- 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
它运行良好,但我注意到测试也在 generateAAR 和 copyAAR 任务上执行,导致总共通过了 6 个测试。有没有办法从特定任务或管道中排除测试?
提前致谢。
Is there a way to exclude the tests from a specific task or pipeline?
Azure devops 服务本身没有从一项任务中排除测试的选项。(测试级别)相反,它支持管道中的 disabling/skipping 任务。(任务级别)
检查 gradle 的 skipping the tests and skipping the tasks,我想这就是您要找的。
我知道已经有一段时间了,但也许有人觉得我的回答有用,因为有一种方法可以做到,至少它对我们的项目有用。 Gradle Azure 的任务有一个“选项”参数,请参阅官方文档:
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/gradle?view=azure-devops
这意味着您的最终解决方案将如下所示:
- 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