Skip to content

Commit

Permalink
Update BASE_URL and REMOTE_WEBDRIVER_GRID_HOST_NAME if ipAddress is N…
Browse files Browse the repository at this point in the history
…OT NULL
  • Loading branch information
anandbagmar committed Nov 6, 2024
1 parent 4863025 commit bef0ec5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,13 @@ tasks.register('run', JavaExec) {
.find { it.hostAddress.startsWith("192") }
?.hostAddress
println "IP Address of this machine: $ipAddress"
environment "BASE_URL", "http://$ipAddress:3000"
environment "REMOTE_WEBDRIVER_GRID_HOST_NAME", "$ipAddress"
if (null == ipAddress) {
println "Unable to get local IP address. NOT updating BASE_URL and REMOTE_WEBDRIVER_GRID_HOST_NAME"
} else {
println "Updating BASE_URL ('http://$ipAddress:3000') and REMOTE_WEBDRIVER_GRID_HOST_NAME ('$ipAddress')"
environment "BASE_URL", "http://$ipAddress:3000"
environment "REMOTE_WEBDRIVER_GRID_HOST_NAME", "$ipAddress"
}

def configFile = System.getenv("CONFIG")
if (null == configFile || !file(configFile).exists()) {
Expand Down
9 changes: 7 additions & 2 deletions build.gradle.sample
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ tasks.register('run', JavaExec) {
.find { it.hostAddress.startsWith("192") }
?.hostAddress
println "IP Address of this machine: $ipAddress"
environment "BASE_URL", "http://$ipAddress:3000"
environment "REMOTE_WEBDRIVER_GRID_HOST_NAME", "$ipAddress"
if (null == ipAddress) {
println "Unable to get local IP address. NOT updating BASE_URL and REMOTE_WEBDRIVER_GRID_HOST_NAME"
} else {
println "Updating BASE_URL ('http://$ipAddress:3000') and REMOTE_WEBDRIVER_GRID_HOST_NAME ('$ipAddress')"
environment "BASE_URL", "http://$ipAddress:3000"
environment "REMOTE_WEBDRIVER_GRID_HOST_NAME", "$ipAddress"
}

// You can also specify which config file to use based on the value of RUN_IN_CI as shown below
//
Expand Down

0 comments on commit bef0ec5

Please sign in to comment.