I have added variables in azure pipeline but its not attached in copy files in last step of copy
Below yml script:
trigger:
- branch name
pool:
vmImage: 'windows-latest'
variables:
projectFolder: '.'
steps:
- task: NodeTool@0
displayName: 'Use Node 14.17.0'
inputs:
versionSpec: 14.17.0
- script: 'npm i'
displayName: 'Install Dependencies'
- task: DownloadSecureFile@1
inputs:
secureFile: 'Constants.json'
- task: CopyFiles@2
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: '**/*Constants.json'
TargetFolder: '$(projectFolder)'
- script: 'npm run build'
displayName: 'build app'
- task: CopyFiles@2
displayName: 'Copy Files'
inputs:
SourceFolder: build
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: ArchiveFiles@2
displayName: 'Archive $(Build.ArtifactStagingDirectory)'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
how to add download file in build zip.
2
Answers
You need to modify the Yaml script so it includes the downloaded file in the build artifact.
Try this code:
In your last
CopyFiles@2
task, you copy files frombuild
folder, which actually is$(Build.SourcesDirectory)build
. So if you wantConstants.json
to be added to the .zip file, you need to copy it into$(Build.SourcesDirectory)build
.In the first
CopyFiles@2
task, you copyConstants.json
to$(projectFolder)
. I’m not sure about the actual value of$(projectFolder)
. According to the current information, it should be$(Build.SourcesDirectory)build
.Try the scripts below and check if it helps.