I just wanted to know can we run wiremock on local...
# wiremock-java
I just wanted to know can we run wiremock on local machine instead of running it on a server. currently we are running wiremocks to automate different security tools on jenkins server. but we are not able to run the same setup on our local machine.
You'll need a JRE installed, but then you should just be able to follow this: https://wiremock.org/docs/running-standalone/
can the same code work on both jenkins as well as local?
I don't really understand the question - in principal yes? But it depends what code you mean.
I mean the code I used for running it on jenkins can the same code be used to run it on local?? or do I need some changes
Copy code
org.eclipse.jetty.util.log.StdErrLog logger = new org.eclipse.jetty.util.log.StdErrLog();

        wireMockServer = new WireMockServer(options().usingFilesUnderDirectory(getDirectoryLocation(toolName)).port(randomWiremockPort())); //No-args constructor will start on port 8080, no HTTPS 
Yes, you can run that code locally. I think most people run tests that start and stop WireMock locally.
ok thanks
and what will be the api endpoint when running locally. we also run that using ssh where the endpoint is the server IP and when we run on jenkins the endpoint is the jenkins endpoint, but what will be the endpoint when we run on local?
It will be
because you are using
- I think
must be your own logic, it's not a WireMock function.
The WireMock equivalent is
. You can get the port from WireMock -
will return it so you can print it.
Are you able to share more details about the use case? We'd love to go on a short call to understand what you are doing.
we use it to test the security tools that are integrated into our platform, our test cases run fine on Jenkins but somehow not able to run on http://localhost:<random_port>.