Operations 4 min read

Configuring Eureka Server with Jenkins: Deployment Scripts and Setup Guide

This article provides a step‑by‑step guide on configuring a Eureka service registry on a Linux server, creating deployment scripts, setting up Jenkins to pull the Eureka JAR from Git, and editing the Spring Cloud configuration file for proper operation.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Configuring Eureka Server with Jenkins: Deployment Scripts and Setup Guide

Step 1 – Prepare the Eureka server directory

Create the base directory and a configuration sub‑directory on the target host.

[root@hd01 eureka]# mkdir /usr/local/eureka
[root@hd01 eureka]# mkdir config

Step 2 – Create a simple run script (run.sh)

The script changes to the Eureka directory and starts the JAR in the background.

cd /usr/local/eureka && nohup java -jar eureka.jar >>nohup.out &

Step 3 – Prepare the Jenkins build environment

Navigate to the Jenkins workspace, list the generated artifacts and verify the JAR file.

[root@jenkins ~]# cd /var/lib/jenkins/workspace/eureka/target/
[root@jenkins target]# ll
# (output shows eureka.jar, eureka.jar.original, etc.)

Step 4 – Write the eureka.sh deployment script

This script backs up previous versions, kills any running Eureka process, and launches the new JAR with the test profile.

#!/bin/bash
DATE=$(date +%Y%m%d)
DIR=/usr/local/eureka
JARFILE=eureka.jar
if [ ! -d $DIR/backup ]; then
    mkdir -p $DIR/backup
fi
cd $DIR
sleep 2
ps -ef | grep $JARFILE | grep -v grep | awk '{print $2}' | xargs kill -9
java -jar $JARFILE --spring.profiles.active=test > nohup.out &

Step 5 – Configure Eureka with Spring Cloud

Edit application-test.yml under /usr/local/eureka/config to set server port, service name, network preferences and Eureka client URLs.

server:
  port: 9762
spring:
  application:
    name: eureka-server
  cloud:
    inetutils:
      preferred-networks: 192.168.40.24
    eureka:
      client:
        service-url:
          defaultZone: http://192.168.40.24:${server.port}/eureka/
        register-with-eureka: true
        fetch-registry: true
      instance:
        prefer-ip-address: true

After saving the configuration, restart the Eureka service using the eureka.sh script, then trigger a Jenkins build to pull the latest JAR from Git and deploy it.

The article concludes with a reminder to like, share, and follow for more technical tutorials.

DeploymentEurekaSpring CloudService RegistryJenkinsshell script
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.