我有一个带有两个单元测试的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次测试。有没有一种方法可以将测试从特定任务或管道中排除?
谢谢。
答案 0 :(得分:1)
是否可以将测试从特定任务或管道中排除?
Azure devops服务本身不能选择从一项任务中排除测试。(测试级别)而是支持在管道中禁用/跳过任务。(任务级别)
检查gradle的skipping the tests和skipping the tasks,我认为这就是您想要的。
答案 1 :(得分:0)
我知道已经有一段时间了,但是也许有人觉得我的答案很有用,因为有一种方法可以做到,至少在项目中它对我们有用。 Graz Task for 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