Jenkins build and deployment of spring boot client microservice fails because of config-server at https://localhost:8888 not present on maven build

Viewed 25

My goal is to deploy 1 spring-config-server application AND 1 spring-boot-client application to the same Linux server machine.

spring-boot-client application port is 8081 spring-config-server application port is 8888

In Jenkins I created 2 jobs. First job is to build and deploy the spring-config-server application and start the jar. Second job is is to build and deploy the spring-boot-client application and start the jar.

I was able to build and deploy the spring-config-server application to the Linux machine. I can see it running at localhost:8888

enter image description here

Problem : Build task/job for spring-boot-client application in Jenkins is failing because when maven clean install is run, I believe that it tries to locate presence of a config server running at localhost:8888. I don't know if it's because of actuator dependency I added.

In Jenkins build console, this is what I get

Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8888/application/dev": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:602) at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.getRemoteEnvironment(ConfigServerConfigDataLoader.java:303) at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.doLoad(ConfigServerConfigDataLoader.java:118) ... 94 common frames omitted Caused by: java.net.ConnectException: Connection refused (Connection refused)

In the spring-boot-client app's application.properties, the only setting I have are these :

# ANT_PATH_MATCHER is added to avoid NULL error in SwaggerConfig
spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER

server.port=8081

# Spring Config Server URL of Config Server Microservice :
spring.config.import=configserver:http://localhost:8888

# Environment configuration which you want to load :
spring.profiles.active=dev

In spring-boot-client's jenkins build job, this is what I have :

enter image description here

Now, theoretically, I believe that deploying 1 config-server and 1 client-app in the same linux machine should be possible. I just don't know how to properly configure it in Jenkins.

I have this spring cloud config client in pom.xml

<dependency>
    <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-client</artifactId>
    <version>3.1.3</version>
</dependency>

I have a copy of the spring-config-server app and spring-boot-client app in my local machine. I just start/run both and it works.

I am a beginner in Jenkins and I do everything in UI. This is just a build task with scp and ssh commands executed in shell to deploy.

I'd appreciate any help or comment.

Thank you.

0 Answers
Related