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

执行action/download-artifact@v2时无法找到关联工作流工件的问题求助

解决GitHub Actions中download-artifact找不到工件的问题

可能原因及解决步骤

1. Maven未生成WAR包

  • 排查:查看Build with Maven步骤的日志,确认是否有Building war: .../target/xxx.war的输出。如果没有,说明打包配置存在问题:
    • 检查项目pom.xml,确保<packaging>标签设置为war(默认是jar类型)。
    • 将maven命令从mvn clean install改为mvn clean package,优先确保打包流程完成,避免install阶段的额外操作干扰。

2. 上传工件的路径配置错误

  • 排查:查看Upload artifact for deployment job步骤的日志,如果显示No files were found with the provided path,说明路径配置有误:
    • 去掉路径中的${{ github.workspace }}和引号,直接使用相对路径target/*.war(GitHub Actions的工作目录默认就是仓库根目录,相对路径更可靠)。
    • 如果是多模块Maven项目,路径需调整为子模块名称/target/*.war。

3. 验证工件是否真的被上传

  • 在上传工件前添加一个步骤,列出target目录内容,确认WAR包存在:
    - name: Check target files
      run: dir target
    
    查看该步骤日志,确认*.war文件存在后再执行上传操作。

修改后的示例配置

Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy WAR app to Azure Web App - xxx

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Java version
        uses: actions/setup-java@v1
        with:
          java-version: '17'

      - name: Check target directory before build
        run: if exist target dir target

      - name: Build with Maven
        run: mvn clean package

      - name: Check target directory after build
        run: dir target

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v2
        with:
          name: java-app
          path: target/*.war

  deploy:
    runs-on: windows-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v2
        with:
          name: java-app

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: 'xxx'
          slot-name: 'Production'
          publish-profile: ${{ secrets.xxxxxx }}
          package: '*.war'

内容的提问来源于stack exchange,提问作者Explain Down Vote

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 14:53:41