PowerShell スクリプトでアドレスをバインドしようとしています。これにより、テスターはワイヤーモックを実行でき、実行時に正しい環境を自動的に指すようになります。
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
、うまくいかないようです。