【问题标题】:Jenkins not recognising custom Gradle tasksJenkins 无法识别自定义 Gradle 任务
【发布时间】:2015-12-10 15:10:39
【问题描述】:

我一直在尝试使用 Jenkins 从我的 build.gradle 文件运行单元测试。如果我在 android studio 的终端中使用命令./gradlew tasks,我可以看到我设置的自定义任务。但是,如果我尝试通过 jenkins 运行相同的命令,我将无法在任务输出中看到它们。

我的 build.gradle 中的代码 sn-p

task runDataUnitTests(dependsOn: [':data:test']) {
    description 'Run unit tests for data layer.'
}

task runBusinessUnitTests(dependsOn: [':business:test']) {
    description 'Run unit tests for business layer.'
}

task runPresenterUnitTests(dependsOn: [':presenter:test']) {
    description 'Run unit tests for presenter layer.'
}

task runAllUnitTests(dependsOn: [runDataUnitTests, runBusinessUnitTests, runPresenterUnitTests]) << {
    group = 'My tasks'
    description 'Run unit tests for all layers.'
}

task testingTaskmma{
    group = 'My tasks'
    println 'is this task seen'
}

Android Studio 输出

Other tasks
-----------
assembleArtifacts - Builds the project artifacts
assembleDefault
crashlyticsUploadDistributionLiveDebug - Uploads an APK to Crashlytics for distribution.
crashlyticsUploadDistributionLiveRelease - Uploads an APK to Crashlytics for distribution.
crashlyticsUploadDistributionStagingDebug - Uploads an APK to Crashlytics for distribution.
crashlyticsUploadDistributionStagingRelease - Uploads an APK to Crashlytics for distribution.
hello
jarLiveDebugClasses
jarLiveReleaseClasses
jarStagingDebugClasses
jarStagingReleaseClasses
lintVitalLiveRelease - Runs lint on just the fatal issues in the LiveRelease build.
lintVitalStagingRelease - Runs lint on just the fatal issues in the StagingRelease build.
runAllUnitTests **<<< THIS DUDE HERE**
sonarqube - Analyzes project ':msmandroidapp' and its subprojects with SonarQube.
sonarRunner - Analyzes project ':msmandroidapp' and its subprojects with Sonar Runner.
testingTaskmsma

詹金斯输出

Other tasks
-----------
assembleArtifacts - Builds the project artifacts
assembleDefault
connectedInstrumentTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedLiveTest - Installs and runs the tests for LiveDebug flavor on connected devices.
connectedStagingTest - Installs and runs the tests for StagingDebug flavor on connected devices.
crashlyticsUploadDistributionLiveDebug - Uploads an APK to Crashlytics for distribution.
crashlyticsUploadDistributionLiveDebugAndroidTest - Uploads an APK to Crashlytics for distribution.
crashlyticsUploadDistributionLiveRelease - Uploads an APK to Crashlytics for distribution.
crashlyticsUploadDistributionStagingDebug - Uploads an APK to Crashlytics for distribution.
crashlyticsUploadDistributionStagingDebugAndroidTest - Uploads an APK to Crashlytics for distribution.
crashlyticsUploadDistributionStagingRelease - Uploads an APK to Crashlytics for distribution.
jarLiveDebugClasses
jarLiveReleaseClasses
jarStagingDebugClasses
jarStagingReleaseClasses
publishLive - Uploads a live-flavor specific APK to MobileAppStore
publishStaging - Uploads a staging-flavor specific APK to MobileAppStore
sonarRunner - Analyzes project ':msmandroidapp' and its subprojects with Sonar Runner.
uploadArtifacts - Builds the project artifacts and uploads them the to local maven repository.

如您所见,我创建的其他自定义任务也从 jenkins 输出中丢失(例如 testingTaskmsma、hello 等) 我已经尝试使用 gradle 包装器和调用等级选项(使用 jenkins 的等级插件)来设置我的 Jenkins,但都不起作用。

【问题讨论】:

  • 请发布您在本地环境和 Jenkins 上执行的 Gradle 任务。
  • 我想通了并发布了答案,感谢回复:)@Egor

标签: android android-studio jenkins build.gradle gradle-plugin


【解决方案1】:

问题是来自 Jenkins 服务器的路径不正确。重命名工作后,我没有意识到创建了一个全新的工作区,所以我指向了以前的工作区。此外,我发现最好使用 shell 命令而不是 Jenkins 的等级插件,因为这就是我能够追踪我的问题的方式。

【讨论】:

    猜你喜欢
    • 2021-08-06
    • 2020-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-27
    • 2016-01-30
    • 2012-08-04
    相关资源
    最近更新 更多