0

I have a azure devops pipeline that runs 2 jobs - one on windows agent running a server, the other on Linux agent - running a client that connects to the server. These jobs run in parallel. Currently ip address and port are hard coded on client side repo. But I want to decouple this situation. is there a way in azure devops pipeline to get agent ip in the first job, store it in variable and use it as parameter to a step in the second job?

thanks a lot for all the help.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
strabo
  • 11
  • 1
  • 4
  • 1
    You could use `Powershell` or bash to get IP address, however it keeps changing. see this [SO answer](https://stackoverflow.com/questions/53422395/how-to-get-the-ip-address-for-azure-devops-hosted-agents-to-add-to-the-white-lis) – Anand Sowmithiran May 02 '22 at 14:06
  • Thank you! I’ll save that link answer for later. Currently we are not running on cloud. But we also do not have internet connection on build machines, will ipinfo work? – strabo May 02 '22 at 14:09
  • 1
    Without internet connection, you wouldn't be able to reach ipinfo.io, so need to use Powershell command, `Get-NetIPAddress`, see [this](https://www.delftstack.com/howto/powershell/powershell-get-ip-address/) for some ideas. – Anand Sowmithiran May 02 '22 at 14:18
  • If the jobs are running *in parallel*, no; you'd need to find some other way to let the client job know the ip address. But it might be possible, with a bit of restructuring. Could you have stage 1 where a small job runs on the server just to find out the ip address and port, then stage 2 (using those values) runs the two jobs (server and client)? – Vince Bowdren May 10 '22 at 16:07

0 Answers0