I am trying to deploy my node.js code to Azure Function App using Azure DevOps. I have created the following Azure DevOps pipeline using YAML.
The problem I am facing is that on the deploy step, my pipeline is failing because it is not able to find the package
. When I look at the logs, I believe during the clean up activity between jobs/stages, the folders are cleaned. I have tried using other predefined variables like Build.ArtifactStagingDirectory
but none works.
trigger:
- master
variables:
azureServiceConnection: 'mySvcCon'
azureFuncApp: myFApp
stages:
- stage: Build_1
displayName: 'Build Stage'
jobs:
- job: build
displayName: 'Build Node.js app'
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: NodeTool@0
displayName: 'Install Node.js'
inputs:
versionSpec: '8.x'
- script: |
npm install
displayName: 'npm install and build'
- task: CopyFiles@2
displayName: 'Copy necessary files'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
Contents: |
**/*
!.vscode/**/*
TargetFolder: '$(System.DefaultWorkingDirectory)/copied'
- task: PublishBuildArtifacts@1
displayName: 'Publish artifact'
enabled: true
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/copied'
publishLocation: filePath
targetPath: '$(System.DefaultWorkingDirectory)/publish'
- stage: Deploy_2
displayName: 'Deploy Stage'
jobs:
- job: Deploy
displayName: 'Deploy to Function App'
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: AzureRMWebAppDeployment@4
displayName: 'AzureRM Function App deploy'
inputs:
ConnectionType: 'AzureRM'
ConnectedServiceName: $(azureServiceConnection)
WebAppKind: 'Function App'
WebAppName: $(azureFuncApp)
Package: '$(System.DefaultWorkingDirectory)/publish'
How do I share my artifact between the stages? The same pipeline works if I put all steps in the same job. But I want to separate them out.