0

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):

  1. /etc/profile.d/polyspace_path.sh

    • Adds PATH using export, but only works for interactive shells — not for the Azure DevOps agent service.
  2. Modifying /etc/environment

    • Changes show up for new users but not for already-running services like the agent.
  3. 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.

  1. Used ##vso[task.setvariable] in YAML pipeline.

Works only at runtime. Doesn’t make polyspace-* tools globally available.

  1. 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?

1 Answer 1

0

Microsoft has the source code for generating their azure devops custom packer images in the actions-runner repository.

They have a ubuntu helpers/etc-environment.sh script for setting up path variables (append_etc_environment_path + prepend_etc_environment_path).

Microsoft is setting the PATH in the following install scripts:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.