0

I am using self hosted and microsoft hosted agent to run the pipeline.

One of the pipeline steps is to install certain python packages on the agent so that the project unit tests can be then executed.

Does the agent retain the installed packages or a clean slate is given to each pipeline?

silent
  • 14,494
  • 4
  • 46
  • 86
variable
  • 8,262
  • 9
  • 95
  • 215

1 Answers1

1

Microsoft-hosted agent: No, it's a clean slate for every job.

Self-hosted: That depends on how you configure your agent. But assuming it's just a single VM, then yes, what you install/cache/etc on that agent, will still be available for the next job to use.

Be careful, however, as this can of course also have unintended consequences if left-over files mess up a subsequent job.

silent
  • 14,494
  • 4
  • 46
  • 86
  • Is there any way to ensure that the self-hosted agent gets a clean slate. For example - I can create a new python virtual env and install the packages into the virtual environment, then later delete the virtual env at the end of pipeline. But is there any other way to achieve this? – variable Jun 13 '22 at 08:25
  • @variable yes, indeed. I usually recommend to use VMSS-agents. We actually published a blog post how to do this using VMSS and cloud-init to get fresh agents on every run https://medium.com/microsoftazure/custom-azure-vm-scale-sets-with-terraform-and-cloud-init-6a592dc41523 – silent Jun 13 '22 at 13:12
  • I actually just noticed that in the blog post the check box “tear down agents after every use” is not shown checked. You want to enable that :) – silent Jun 13 '22 at 15:33