0

我正在尝试在 PowerShell 脚本中绑定一个地址,以便我的测试人员可以运行wiremocks,并且在运行它时它会自动指向正确的环境。

echo "Running WireMock"

$WiremockFileName = "wiremock-standalone-2.1.12.jar"
$Port = 8050
$Address = "my.integration.address"

if (-not(Test-Path "./$WiremockFileName")) {
    echo "Going to download wiremock";
    Invoke-WebRequest "http://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.1.12/$WiremockFileName" -OutFile $WiremockFileName
    echo "Finished"
}

echo "Looking for JRE"
$JAVA = ""

if ($JAVA -eq "") {
    # In case a specific version of Java is in the path already
    $JavaExe = Get-Command "java" -ErrorAction SilentlyContinue
    if ($JavaExe) {
        $JAVA = JavaExe.Definition
    }
}

if ($JAVA -eq "") {
    # This seems to work on RBI machines
    $jre7Path = "C:\Program Files (x86)\Java\jre7\bin\java.exe"
    $testJre7 = Test-Path $jre7Path -ErrorAction SilentlyContinue
    if ($testJre7) {
        $JAVA = $jre7Path
    }
}

if ($JAVA -eq "") {
    # Nope - I give up
    echo "I give up! I can't find JAVA anywhere"
    echo "Put it in your path and stop giving me a hard time or send a pull request"

    exit 1
    # echo "Press any key to continue"
    # $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}

& $JAVA -jar $WiremockFileName --bind-address $Address --https-port $Port --verbose
exit $LASTEXITCODE

我试图让这部分工作:

& $JAVA -jar $WiremockFileName --bind-address $Address --https-port $Port --verbose

--bind-address $Address似乎不起作用。

4

1 回答 1

0

在地址绑定旁边......在第 20 行我很确定它应该是

$JAVA = $JavaExe.Definition

代替

$JAVA = JavaExe.Definition

于 2016-10-11T14:42:59.120 回答