From f85ea568dfa17889e0df5293cdab5382d6e56e4a Mon Sep 17 00:00:00 2001 From: Brian Krische <1189328+krische@users.noreply.github.com> Date: Wed, 28 Jun 2023 08:35:42 -0500 Subject: [PATCH] Check for JENKINS_DIRECT_CONNECTION value This fixes #358 by only requiring `JENKINS_URL` have a value when `JENKINS_DIRECT_CONNECTION` is not set as well. --- jenkins-agent.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins-agent.ps1 b/jenkins-agent.ps1 index 2f354c2e..c37ccb37 100644 --- a/jenkins-agent.ps1 +++ b/jenkins-agent.ps1 @@ -23,7 +23,7 @@ [CmdletBinding()] Param( $Cmd = '', # this must be specified explicitly - $Url = $( if([System.String]::IsNullOrWhiteSpace($Cmd) -and [System.String]::IsNullOrWhiteSpace($env:JENKINS_URL)) { throw ("Url is required") } else { '' } ), + $Url = $( if([System.String]::IsNullOrWhiteSpace($Cmd) -and [System.String]::IsNullOrWhiteSpace($env:JENKINS_URL) -and [System.String]::IsNullOrWhiteSpace($env:JENKINS_DIRECT_CONNECTION)) { throw ("Url is required") } else { '' } ), [Parameter(Position=0)]$Secret = $( if([System.String]::IsNullOrWhiteSpace($Cmd) -and [System.String]::IsNullOrWhiteSpace($env:JENKINS_SECRET)) { throw ("Secret is required") } else { '' } ), [Parameter(Position=1)]$Name = $( if([System.String]::IsNullOrWhiteSpace($Cmd) -and [System.String]::IsNullOrWhiteSpace($env:JENKINS_AGENT_NAME)) { throw ("Name is required") } else { '' } ), $Tunnel = '',