shayki5 / azure-devops-create-pr-task

Azure Pipelines task to create PR in Azure DevOps or GitHub during a build or release pipeline
https://marketplace.visualstudio.com/items?itemName=ShaykiAbramczyk.CreatePullRequest
MIT License
58 stars 35 forks source link

Running Task in self-managed agent behind a Proxy #153

Open omaraladin opened 1 year ago

omaraladin commented 1 year ago

Hi,

Description: when running the task in a self-managed agent that is behind a proxy, it throws an error: ##[error]The remote name could not be resolved: 'dev.azure.com'

Environment: OS: Windows Server 2019 Standard Proxxy settings: the domain "dev.azure.com" is actually bypassed through the proxy that is configured on the self-managed VM-level

>> netsh winhttp show proxy ` Current WinHTTP proxy settings: Proxy Server(s): proxy.company.com Bypass List: *.dev.azure.com; ....`

How to reproduce: Include the task in a pipeline and specify demands to make the job run in a self-managed agent that is running behind a proxy

Possible fixes: Include an optional proxy-Parameter in the task that, if added, proxy-settings will be loaded in the task runtime

shayki5 commented 1 year ago

Hi @omaraladin, is it similar to #72? If yes, can you provide me which details need to add? (I just not familiar with proxy...)

omaraladin commented 1 year ago

Hi @omaraladin, is it similar to #72? If yes, can you provide me which details need to add? (I just not familiar with proxy...)

Yeah it is similar to 72

you need to load the proxy details, in the code at runtime, because in proxy-environments if proxy is not loaded, Internet URLs will not be reached from the Request origin (the self-managed agent running your PRCreate task in my case)

how I think you could resolve it, as PS is used to code the task:

shayki5 commented 1 year ago

@omaraladin I using Invoke-RestMethod so I think -Proxy and -ProxyCredential parameters will do the job, no?

See here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.3

omaraladin commented 1 year ago

yeah, should do the job, but make sure to add this flag only when the user specifies that a proxy is actually being used. see the first point in what I recommended here

Hi @omaraladin, is it similar to #72? If yes, can you provide me which details need to add? (I just not familiar with proxy...)

Yeah it is similar to 72

you need to load the proxy details, in the code at runtime, because in proxy-environments if proxy is not loaded, Internet URLs will not be reached from the Request origin (the self-managed agent running your PRCreate task in my case)

how I think you could resolve it, as PS is used to code the task:

spaasis commented 1 year ago

Any progress or workarounds for this?

shayki5 commented 1 year ago

@omaraladin @spaasis can you try to run a simple Azure DevOps Rest API with Powershell and add the proxy param, for check if it will work?