0
votes

We have our build running in Azure DevOps using Yaml file with multi staging template. What I observed is that after each stage the pipeline workspace is getting deleted and the next stage that is dependent on the files present in workspace is getting failed.

1
Yes, that's correct. That behavior is by design. Each job should be independent of the previous jobs; jobs can run on different agents.Daniel Mann
Thanks Daniel for explanationviswanath anand

1 Answers

0
votes

Multi Stage worksapce getting cleaned after each stage

As what the Daniel said, YES, this is by design.

For azure devops pipeline, as we designed, workspace exists for one agent job. That is, each agent job has a separate work space:

When you run an agent pool job, it creates a workspace on the agent. The workspace is a directory in which it downloads the source, runs steps, and produces outputs.

If you pay attention to the Hosted agents that different agent jobs used, you would found after one agent job finished, next one will using another new agents. This is the most obvious manifestation of my above words.

If what you are using is private agent, at this time, the workspace cache (like files, binaries and ect) of previous agent job can be kept until you clean them. But, you can not call them by some pre-define variables, e.g Build.SourcesDirectory.


In you scenario, you said the next stage has files dependency with the previous stage.

To avoid the issue which caused by this default limitation, you can make use of Publish artifact, and download artifact. This way can help you pass the files between stages. Publish and download artifacts.