Hello HanShih,
When you run the build pipeline on Azure DevOps it's actually the build service account which is running the script. You should make sure the build service account have sufficient permission to Access: '//<hostnameIP>\c$\'
To change the identity of the build agent, just go into Windows Services and change the identity of related Build service (service name is " Azure Pipelines Agent") to an account that has that filesystem access
-In the Services pane, right-click Azure Pipelines Agent.
-Under Service Status, click Stop.
-Click the Log On tab.
-Specify the account you want to use for the service in the This account text box.
-Type the new password in the Password text box, and then type the new password again in the Confirm password text box.
-Under Service Status, click Start.
--If the reply is helpful, please Upvote and Accept as answer--