I'm running an Azure DevOps pipeline using agents deployed via a VMSS (Virtual Machine Scale Set) based on a custom Packer image. This image includes Polyspace tools (like Code Prover and Bug Finder), installed at:
/usr/local/MATLAB/R2025a/polyspace/bin
I need to ensure this path is added to the agent's environment $PATH persistently, so that tools like polyspace-bug-finder are available during pipeline execution.
What I've tried (but didn't persist correctly in agent context):
/etc/profile.d/polyspace_path.sh- Adds
PATHusingexport, but only works for interactive shells — not for the Azure DevOps agent service.
- Adds
Modifying
/etc/environment- Changes show up for new users but not for already-running services like the agent.
Global systemd config via
/etc/systemd/system.conf.d/path.conf:[Manager] DefaultEnvironment="PATH=/usr/local/MATLAB/R2025a/polyspace/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Applied before image capture, but the agent service still doesn't pick it up consistently on VMSS instances.
- Used ##vso[task.setvariable] in YAML pipeline.
Works only at runtime. Doesn’t make polyspace-* tools globally available.
- Cron @reboot job with a 5-minute delay waits for the agent to start and then tries to apply a systemd override at /etc/systemd/system/.service.d/override.conf.
- However, the script fails to detect the agent service reliably, so the PATH override isn’t applied.
What I need A reliable way to persistently set PATH so that any Azure DevOps agent service launched from the VMSS image always sees this:
/usr/local/MATLAB/R2025a/polyspace/bin ...in its $PATH, without needing to inject it during the pipeline YAML.
Question What is the most reliable and image-safe method to persist custom PATH values for the Azure DevOps agent service in a VMSS-based self-hosted agent pool?
Are there image prep steps or systemd overrides that Azure DevOps agents ignore or override during scale-out?