Search code examples
flutterazure-devopspipeline

Azure DevOps Pipeline - Flutter - Directory '/home/vsts/work/1/a' is empty. Nothing will be added to build artifact 'drop'


I've been trying to publish a flutter artefact for a while, but keep getting the same error. A lot of the StackOverflow solutions seem to work for .NET, but not in my case. I'm using Flutter Tasks extension to build.

Thanks for the help. Here's the solution if someone needs it for later. https://gist.github.com/OriginalMHV/bca27623c32dc04a311f6dff837e2d42

stages:
- stage: Build
  jobs:
  - job: iOSBuild
    pool:
      vmImage: 'macOS-latest'
    steps:
    - task: FlutterInstall@0
      inputs:
        channel: 'stable'
        version: 'latest'
    - task: FlutterBuild@0
      inputs:
        target: ios
        projectDirectory: $(projectDirectory)
        iosCodesign: false
        iosTargetPlatform: device

  - job: AndroidBuild
    pool:
      vmImage: 'macOS-latest'
    steps:
    - task: FlutterInstall@0
      inputs:
        channel: 'stable'
        version: 'latest'
    - task: FlutterBuild@0
      inputs:
        target: apk
        projectDirectory: $(projectDirectory)

- stage: CopyAndPublishArtifact
  jobs: 
    - job: CopyArtifactFiles
      steps:
      - task: CopyFiles@2
        inputs:
          SourceFolder: $(Build.SourcesDirectory)
          TargetFolder: $(Build.ArtifactStagingDirectory)
    - job: PublishArtifact
      steps:
      - task: PublishBuildArtifacts@1
        inputs:
          PathtoPublish: $(Build.ArtifactStagingDirectory)
          ArtifactName: drop

Solution

  • Make sure you copy the artifacts in the job that creates them.

    Each job (and thus every stage) runs on an agent and the job's directories are cleaned at the start of each job.

    So both your build jobs must publish their own artifact and use a unique name. And then you don't need the last stage.

    If you want a single artifact with both files, you need to either build both artifacts in a single job, or have the publish job download the 2 artifacts and then create a new, single, artifact with both iOS and Android packages.