0

I am configuring some tasks in Azure DevOps, My Tasks execution needs host entries to be added in Microsoft Hosted Agents. How can I achieve this Since I can access the Microsoft Hosted Agents.

Ganesh H
  • 1,649
  • 3
  • 14
  • 20

2 Answers2

1

I don't think you have the ability to edit anything on the MS Hosted agents. You will probably need to setup your own agent and customise it, by adding the host entries.

Gareth Oates
  • 399
  • 4
  • 14
  • This turns out to be incorrect. You can also do the same on GitHub but simply using echo which doesn't seem to work on the DevOp hosted build agents. See my answer below. – Michael K. May 28 '22 at 12:30
  • 1
    3 years later, I'm sure there's many things that have changed – Gareth Oates Jun 01 '22 at 12:02
0

This is how to do it. Seems to work and the Windows hosted agents allow it (for now).

steps:
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: 'Add-Content -Path $env:windir\System32\drivers\etc\hosts -Value "`nXX.XX.XX.XX`tHOSTNAME.com" -Force' 
Michael K.
  • 555
  • 2
  • 15
  • You need admin access for editing the /etc/hosts file. I am getting error "Access to the path '/etc/hosts' is denied." – Gunjan Shah Sep 09 '22 at 13:37