Im developing a project using spring-cloud-contract and works perfect on local, however, when i run the project in jenkins on aws throw a UnknownHostException.
first show this:
[ERROR] Failed to execute goal org.springframework.cloud:spring-cloud-contract-maven-plugin:2.2.2.RELEASE:generateTests (default-generateTests) on project proxy-api: Execution default-generateTests of goal org.springframework.cloud:spring-cloud-contract-maven-plugin:2.2.2.RELEASE:generateTests failed: An API incompatibility was encountered while executing org.springframework.cloud:spring-cloud-contract-maven-plugin:2.2.2.RELEASE:generateTests: java.lang.ExceptionInInitializerError: null
review i found this:
Caused by: java.net.UnknownHostException: ip-10-151-82-104: ip-10-151-82-104: Name or service not known
at java.net.InetAddress.getLocalHost (InetAddress.java:1642)
at com.github.tomakehurst.wiremock.extension.responsetemplating.helpers.HostnameHelper.<clinit> (HostnameHelper.java:31)
at com.github.tomakehurst.wiremock.extension.responsetemplating.helpers.WireMockHelpers$5.<init> (WireMockHelpers.java:62)
at com.github.tomakehurst.wiremock.extension.responsetemplating.helpers.WireMockHelpers.<clinit> (WireMockHelpers.java:61)
i config the plugin to use Local, without result:
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>${spring-cloud-contract.version}</version>
<extensions>true</extensions>
<configuration>
<testFramework>JUNIT5</testFramework>
<testMode>WEBTESTCLIENT</testMode>
<packageWithBaseClasses>com.proxy.api</packageWithBaseClasses>
<contractsMode>LOCAL</contractsMode>
</configuration>
</plugin>
Update: I found an approach adding ip to /etc/hosts file like mention on this post ,however , first talking with devops team mention that this is not a good aproach since ip could change. And seccond and most important why is ip needed? since the only thing i want is do test.