Nilesh Chaturvedi
Nilesh Chaturvedi

Reputation: 51

How to make a copy file succeed even if files are not present in TFS?

Need your help on TFS build for one of my apps I have a copy file task in my build which copies the file from SourceFolder$(Build.SourceDirectory)/DataBase/Scripts to targetFolder $(Build.ArtifactStagingDirectory)/DataBase/Scripts.

This works fine if scripts are present in the Source location but fails when there are no files. I need my build to succeed in any case, even if files are not present.

Upvotes: 2

Views: 1564

Answers (2)

4c74356b41
4c74356b41

Reputation: 72191

You could use continueOnError on that particular build step and set it to true, so it doesn't cause the job to be reported as failed, if it fails.

Reference: https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-task?view=azure-pipelines#properties

Upvotes: 3

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31083

If no files in Source Folder Scripts, the task will still report success. If the Source Folder Scripts doesn't exist, the task will report fail as build agent can not find the folder. This is an expected behavior, if the source folder doesn't exist and it reports success, you'll get incorrect result if you type wrong folder name.

Upvotes: 2

Related Questions