I have a multi-stage azure build pipeline for a nodejs application.
In the first stage, I'm building the source code and copying the artifacts to the staging directory (Build.ArtifactStagingDirectory
) and in the third stage of the azure build pipeline, I'm trying to publish artifacts using PublishBuildArtifacts@1 task.
But I'm getting the following warning:
Directory '/home/vsts/work/1/a' is empty. Nothing will be added to build artifact 'drop'.
I have tried the PipelineArtifacts task also.
Below is the build pipeline overview.
azure-pipelines.yml
trigger:
- master
- feature
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: BuildApplication
jobs:
- job: InstallNodejs
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Step for installing Node.js'
- job: PrepareSonarCloud
steps:
- task: SonarCloudPrepare@1
inputs:
SonarCloud: ******
organization: ****
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: ******
cliProjectName: ******
cliSources: '.'
condition: |
and
(
succeeded(),
eq(variables['Build.Reason'], 'Pull Request'),
eq(variables['System.PullRequest.TargetBranch'], 'master')
)
- job: BuildNodejs
steps:
- script: |
npm install
npm run build
displayName: 'npm install and build'
- job: CopyFiles
steps:
- task: CopyFiles@2
inputs:
sourceFolder: $(Build.SourcesDirectory)
targetFolder: $(Build.ArtifactStagingDirectory)
displayName: Copy Files to Staging Directory
- stage: StaticCodeAnalysis
jobs:
- job: AnalyzeSonarcloud
steps:
- task: SonarCloudAnalyze@1
displayName: 'Run SonarCloud code analysis'
condition: |
and
(
succeeded(),
eq(variables['Build.Reason'], 'Pull Request'),
eq(variables['System.PullRequest.TargetBranch'], 'master')
)
- job: PublishCodeAnalysisReport
steps:
- task: SonarCloudPublish@1
displayName: 'Publish SonarCloud quality gate results'
inputs:
pollingTimeoutSec: '300'
condition: |
and
(
succeeded(),
eq(variables['Build.Reason'], 'Pull Request'),
eq(variables['System.PullRequest.TargetReason'], 'master')
)
- stage: UploadArtifact
jobs:
- job: PublishBuildArtifact
steps:
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: drop
Here is the log for copy files task. It's copying the files from source directory to staging directory
Below image shows the log for PublishBuildArtifact task