I created a build definition in vsts with npm build and then I copy the build folder to the drop location.
The build pipeline is working fine
Then I created
Per Azure official document for setting up Pipelines (YAML files) for Node.js, Javascript apps from this link https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/javascript?view=azure-devops&tabs=code
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
npm run build
displayName: 'npm install and build'
- task: CopyFiles@2
inputs:
Contents: 'build/**' # Pull the build directory (React)
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory) # dist or build files
ArtifactName: 'www' # output artifact named www
On the latest version of Azure Devops, edit Release under Pipeline. Note that Build section has been taken off in the latest version (as of June 2020), so some older answers/docs was not working.
Click on Deploy Azure App Services and on the right panel click on ...(Expand Folder) for Package or folder Option
Under Linked Artifacts => MyProject (Build) => www, select dist folder.
Save this and then create release, this should solve the error [error]Error: No package found with the specified pattern: D:\a\r1\a\**\*.zip<br/>
For anyone else experiencing this problem using Azure DevOps, it's useful to turn on debug mode. For your release, define the pipeline variable System.Debug with value true.
That gave me this output which was much more useful:
Now at least I know it's on my target VM and the path is probably wrong.
First i think you should add artifacts1 then attach it to the packages2
In my case (react app deployed as static content to app service) I needed to add a step to archive the build directory before publishing it:
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/build'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
- publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: '$(Build.BuildId)'
I used the below task in Azure DevOps release yaml pipeline for deployment of azure function app and set the package to $(System.DefaultWorkingDirectory) and it worked for me.
- task: AzureFunctionApp@1
inputs:
azureSubscription: XXXXXXXXX
appType: 'functionApp'
appName: 'funcapp-test'
package: '$(System.DefaultWorkingDirectory)'
appSettings:
deploymentMethod: 'auto'
In my case I use azure template but change vmImage: "windows-latest", When I check logs, find out build command didn't run so I figure out I should change default script of install and build to separate script
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
buildFolder: 'build'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
displayName: 'npm install'
- script: |
npm run build
displayName: 'npm build'
- task: CopyFiles@2
inputs:
contents: 'build/**'
targetFolder: '$(Build.ArtifactStagingDirectory)'
cleanTargetFolder: true
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(Build.ArtifactStagingDirectory)
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
includeRootFolder: false
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
artifactName: 'drop'
publishLocation: 'Container'