Commit 75d46d80 authored by Abhishek's avatar Abhishek
Browse files

Update .gitlab-ci.yml file

parent 021c4df0
Pipeline #11988 failed with stages
in 16 seconds
......@@ -5,57 +5,44 @@
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
image: eclipse-temurin:21-jdk
services:
- docker:20.10.16-dind
stages:
- build
- docker
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_IMAGE: hftstuttgart/cota-backend
DOCKER_TAG: test
BUILD_NUMBER: "$CI_PIPELINE_ID"
before_script:
- echo "🔍 Checking Docker setup..."
- apt-get update && apt-get install -y maven curl jq git
- docker version
- until docker info > /dev/null 2>&1; do echo "Waiting for Docker daemon..."; sleep 3; done
- echo "🧱 Maven and Java versions:"
- mvn -v
- java -version
BUILD_NUMBER: "${CI_PIPELINE_ID:-1}"
DOCKER_IMAGE: "cota-backend"
DOCKER_TAG: "test"
# ----------------------------
# Stage 1: Build Maven project
# ----------------------------
build_backend:
image: maven:3.9.9-eclipse-temurin-17
stage: build
script:
- echo "⚙️ Building backend with Maven..."
- mvn clean install -DskipTests=true -B
- echo "✅ Maven build complete. JARs generated in target/."
- echo "🔧 Building backend JAR with Maven..."
- mvn -B clean install
- echo "✅ Maven build done."
artifacts:
paths:
- target/*.jar
expire_in: 1 hour
# ----------------------------
# Stage 2: Build Docker image (no push)
# ----------------------------
docker_build_test:
image: docker:24.0.5
stage: docker
services:
- docker:24.0.5-dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
needs: [build_backend]
script:
- echo "🐳 Waiting for Docker daemon..."
- until docker info > /dev/null 2>&1; do echo "⏳ Waiting..."; sleep 3; done
- echo "🐳 Building Docker image locally..."
- docker build --build-arg BUILD_NUMBER=$BUILD_NUMBER -t $DOCKER_IMAGE:$DOCKER_TAG .
- echo "✅ Docker image build complete."
- echo "🔍 Listing local Docker images:"
- docker images | grep cota-backend || (echo "❌ Image not found, build failed." && exit 1)
- docker images | grep $DOCKER_IMAGE || (echo "❌ Image not found, build failed." && exit 1)
only:
changes:
- '**/*'
\ No newline at end of file
- '**/*'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment