You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub CI执行失败:根项目中未找到uploadToAppSweepRelease任务

解决Task 'uploadToAppSweepRelease' not found的问题

出现这个错误的核心原因是你的Gradle项目未配置AppSweep的Gradle插件,导致执行uploadToAppSweepRelease任务时找不到对应定义。按以下步骤修复:

1. 在Gradle项目中添加AppSweep插件配置

步骤1:配置根目录的build.gradle文件

在项目根目录的build.gradle(或build.gradle.kts)中添加AppSweep的插件仓库和类路径:

// build.gradle (Groovy)
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "com.mend:appscan-sweep-gradle-plugin:2.+"
    }
}

如果使用Kotlin DSL:

// build.gradle.kts
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("com.mend:appscan-sweep-gradle-plugin:2.+")
    }
}

步骤2:在App模块中应用插件并配置

在app模块的build.gradle(或build.gradle.kts)中应用插件,并指定AppSweep的API密钥(与你GitHub Action中的环境变量配置对应):

// build.gradle (Groovy)
plugins {
    id 'com.android.application'
    id 'com.mend.appscan.sweep' // 应用AppSweep插件
}

appscanSweep {
    apiKey = System.getenv("APPSWEEP_API_KEY") // 从环境变量读取密钥
}

Kotlin DSL版本:

// build.gradle.kts
plugins {
    id("com.android.application")
    id("com.mend.appscan.sweep")
}

appscanSweep {
    apiKey.set(System.getenv("APPSWEEP_API_KEY"))
}

2. 验证Gradle任务是否存在

在本地项目根目录执行以下命令,确认uploadToAppSweepRelease任务是否存在:

./gradlew tasks --group 'AppSweep'

如果能看到该任务,说明配置生效。

3. 调整GitHub Action中的冗余步骤

你的Action里的Update Username from Secrets步骤与AppSweep上传无关,可删除避免混淆。同时建议先构建Release版本再执行上传,修改后的Action文件如下:

name: AppSweep mobile application security testing
on: [pull_request_target]
jobs:
  upload-app-to-appsweep:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v2
        
      - name: Make gradlew executable
        run: chmod +x ./gradlew

      - name: Upload app to AppSweep with Gradle
        env:
          APPSWEEP_API_KEY: ${{ secrets.APPSWEEP_API_KEY }}
        run: ./gradlew assembleRelease uploadToAppSweepRelease

4. 额外检查点

  • 确认GitHub仓库Secrets中已正确设置APPSWEEP_API_KEY,密钥可从AppSweep控制台获取
  • 确保Gradle版本与AppSweep插件版本兼容,建议使用插件最新稳定版
  • 若项目为多模块结构,需确保插件应用在包含Android应用的模块上,而非根项目

内容的提问来源于stack exchange,提问作者Hossam Sadekk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 10:51:15