Commit 8fc359e7 authored by Abhishek's avatar Abhishek
Browse files

Update .gitlab-ci.yml file

parent 005ef717
Pipeline #11986 failed with stages
in 35 seconds
...@@ -5,9 +5,56 @@ ...@@ -5,9 +5,56 @@
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings # 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 # Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence # See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
image: maven:3.9.0-jdk-21
services:
- docker:20.10.16-dind
stages: stages:
- test - build
sast: - docker
stage: test
include: variables:
- template: Security/SAST.gitlab-ci.yml 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..."
- 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
# ----------------------------
# Stage 1: Build Maven project
# ----------------------------
build_backend:
stage: build
script:
- echo "⚙️ Building backend with Maven..."
- mvn clean install -DskipTests=true -B
- echo "✅ Maven build complete. JARs generated in target/."
artifacts:
paths:
- target/*.jar
expire_in: 1 hour
# ----------------------------
# Stage 2: Build Docker image (no push)
# ----------------------------
docker_build_test:
stage: docker
needs: [build_backend]
script:
- 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)
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