Sole
Sole

Reputation: 3340

Error on Azure YAML pipeline cannot complete deploy

In my YAML pipeline I get the error: ##[error]Error: No package found with specified pattern: /home/vsts/work/1/a/**/*.zip
Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.

It is a two stage build / deploy YAML pipeline.

My Pipeline is as follows:

trigger:
- master

pool:
  vmImage: ubuntu-latest

stages: 
- stage: BuildIt
  jobs:
  - job: BuildTheCode
    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: '10.x'
      displayName: 'Install Node.js'

    - script: |
        npm install
        npm run build
      displayName: 'npm install and build'

    - task: ArchiveFiles@2
      inputs:
        rootFolderOrFile: '$(Build.BinariesDirectory)'
        includeRootFolder: true
        archiveType: 'zip'
        archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
        replaceExistingArchive: true

    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'drop'
        publishLocation: 'Container'

- stage: Deploy
  jobs: 
    - job: PublishCode
      steps: 
      - task: AzureRmWebAppDeployment
        inputs:
          ConnectionType: 'AzureRM'
          azureSubscription: 'xxxxxx'
          appType: 'webAppLinux'
          WebAppName: 'xxxxxx'
          packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'

I am new to YAML Azure Pipelines.

Upvotes: 1

Views: 678

Answers (2)

Krzysztof Madej
Krzysztof Madej

Reputation: 40849

Another option would be deployment job which:

  • automatically download all available artifacts
  • gives you control via environment restrictions

In your case it would be like

- deployment: DeployWeb
  displayName: deploy Web App
  pool:
    vmImage: 'ubuntu-latest'
  environment: 'smarthotel-dev'
  strategy:
    # Default deployment strategy, more coming...
    runOnce:
      deploy:
        steps:
        - task: AzureRmWebAppDeployment
          inputs:
            ConnectionType: 'AzureRM'
            azureSubscription: 'xxxxxx'
            appType: 'webAppLinux'
            WebAppName: 'xxxxxx'
            packageForLinux: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

However, you may need to create first the environment smarthotel-dev.

Here is full yaml:

trigger:
- master

pool:
  vmImage: ubuntu-latest

stages: 
- stage: BuildIt
  jobs:
  - job: BuildTheCode
    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: '10.x'
      displayName: 'Install Node.js'

    - script: |
        npm install
        npm run build
      displayName: 'npm install and build'

    - task: ArchiveFiles@2
      inputs:
        rootFolderOrFile: '$(Build.BinariesDirectory)'
        includeRootFolder: true
        archiveType: 'zip'
        archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
        replaceExistingArchive: true

    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'drop'
        publishLocation: 'Container'

- stage: Deploy
  jobs: 
    - deployment: DeployWeb
      displayName: deploy Web App
      pool:
        vmImage: 'ubuntu-latest'
      environment: 'smarthotel-dev'
      strategy:
        # Default deployment strategy, more coming...
        runOnce:
          deploy:
            steps:
            - task: AzureRmWebAppDeployment
              inputs:
                ConnectionType: 'AzureRM'
                azureSubscription: 'xxxxxx'
                appType: 'webAppLinux'
                WebAppName: 'xxxxxx'
                packageForLinux: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

Upvotes: 1

Martin Brandl
Martin Brandl

Reputation: 59001

I think you have to download your artifact first:

- stage: Deploy
  jobs: 
    - job: PublishCode
      steps: 
      - download: current
        artifact: drop
      - task: AzureRmWebAppDeployment
        inputs:
          ConnectionType: 'AzureRM'
          azureSubscription: 'xxxxxx'
          appType: 'webAppLinux'
          WebAppName: 'xxxxxx'
          packageForLinux: '$(Pipeline.Workspace)/drop/**/*.zip'

Upvotes: 2

Related Questions