azure-devopsazure-pipelinesazure-devops-self-hosted-agentazure-devops-server-2022

No PATH variable in system capabilities of a self-hosted Azure Pipelines Agent on Windows


The Issue

I am creating a self-hosted Windows agent on my on-premises server. After successfully installing and running the agent service, I noticed that I am unable to see the PATH variable in system capabilities of the newly created agent (see image below).

Missing PATH

I wish to have the PATH variable since the PATH variable contains the directories of certain batch files/programs that should run when my pipeline (which is using this agent) is triggered. Currently, when I trigger the pipeline, it tells me that my batch file is not recognised as an internal or external command, operable program or batch file. I think the error occurs because the PATH variable is not listed in the capabilities of the agent.

Steps I performed for the installation of the service

I followed the steps as outlined in this Microsoft page. I am wondering whether I made a mistake in the installation process, so I will outline the steps I took.

During the installation process, the following questions were prompted:

  1. Enter server URL:
  2. Enter authentication type (press enter for Integrated):
  3. Enter agent pool (press enter for default):
  4. Enter agent name (press enter for MY_SERVER):
  5. Enter work folder (press enter for _work):
  6. Enter run agent as a service? (Y/N) (press enter for N):
  7. Enter enable SERVICE_SID_TYPE_UNRESTRICTED for agent service (Y/N) (press enter for N):
  8. Enable User Account to use for the service (press enter for NT AUTHORITY\NETWORK SERVICE):
  9. Enter whether to prevent service starting immediately after configuration is finished (Y/N) (press enter for N):

to which I answered:

  1. (My server URL)
  2. Default (Integrated)
  3. Default (default)
  4. Default (MY_SERVER)
  5. Default (_work)
  6. Y
  7. Y
  8. Administrator
  9. Default (N)

Here is the information that I can provide about the Agent itself:
Agent.Version: 3.225.0
Agent.HomeDirectory: D:\BuildAgent
Agent.OS: Windows_NT
Agent.OSArchitecture: X64
Agent.OSVersion: 10.0.20348

Other things I have tried

1. Different configuration options
I tried with the following configuration options as well (after removing and re-installing).

  1. For question 8, I chose the default instead of specifying a user.
  2. For question 7, I chose the default instead of specifying Y.

The PATH variable still does not show up after this.

2. Different Agent Version
I did notice that the the agent version I am using is 3.225.0 but the one mentioned in the guide says 2.X. So, I went over to the Release Page for Azure Pipelines Agent and installed the older v2.220.0 version of the agent. But, I still do not see the PATH variable even after doing this.

3. Restarting the server
I came across this page where one of the suggested solution was to restart the machine. I tried that, but the problem still persists.

Lastly, I found this page where it is stated that variables stored inside the VSO_AGENT_IGNORE environment variable will not be added to the capabilities of the agent. I did not add PATH to this environment variable during the installation, but I am unsure if the PATH variable is inside by default. I am also unsure on how to check for the value of the VSO_AGENT_IGNORE environment variable.

In addition, in case it helps, here are the OS details of my server:
Edition: Windows Server 2022 Standard
Version: 21H2
OS build: 20348.587


Solution

  • Even if it's not being displayed in the agent capabilities, the PATH environment variable tells Windows where it can find specific directories that contain executable files.

    If the PATH is changed (e.g. when a new tool is installed) and an agent is already running, restart the agent to ensure that it can pickup all configuration changes.