blob: b145807399cef8e6201e127876445fc63e9b95fb [file] [log] [blame]
Marc Kupietzeed972d2025-09-19 08:52:24 +02001# GitLab CI/CD Pipeline for Kalamar-Plugin-Export
2# This pipeline runs tests on pushes and builds Docker containers on tag pushes and manual triggers
3
4stages:
Marc Kupietz717ded62025-09-19 12:20:42 +02005 - test-and-build
Marc Kupietzeed972d2025-09-19 08:52:24 +02006 - build
7 - deploy
8
9variables:
10 MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
11 MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version"
12 DOCKER_IMAGE_NAME: "korap/kalamar-plugin-export"
13
14# Cache Maven dependencies
15cache:
16 paths:
17 - .m2/repository/
18
Marc Kupietz717ded62025-09-19 12:20:42 +020019# Test and build stage - runs on all pushes
20test-and-build:
21 stage: test-and-build
Marc Kupietzeed972d2025-09-19 08:52:24 +020022 image: eclipse-temurin:22-jdk-alpine
23 before_script:
24 - apk add --no-cache maven
25 - export MAVEN_OPTS="$MAVEN_OPTS"
26 script:
Marc Kupietz717ded62025-09-19 12:20:42 +020027 - mvn $MAVEN_CLI_OPTS clean test package
Marc Kupietzeed972d2025-09-19 08:52:24 +020028 artifacts:
29 reports:
30 junit:
31 - target/surefire-reports/TEST-*.xml
32 paths:
33 - target/surefire-reports/
Marc Kupietz717ded62025-09-19 12:20:42 +020034 - target/*.jar
Marc Kupietzeed972d2025-09-19 08:52:24 +020035 expire_in: 1 week
36 only:
37 - pushes
38 - merge_requests
39
40# Build Docker image stage - available on all branches but only runs manually
41build-docker:
42 stage: build
43 image: docker:24.0.5
44 services:
45 - docker:24.0.5-dind
46 before_script:
47 - apk add --no-cache xz
48 script:
49 - export IMAGE_TAG=${CI_COMMIT_TAG:-latest}
50 - export ARTIFACT_NAME=kalamar-plugin-export-${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}.tar.xz
51 - docker build -t $DOCKER_IMAGE_NAME:$IMAGE_TAG .
52 - docker build -t $DOCKER_IMAGE_NAME:latest .
53 - docker save $DOCKER_IMAGE_NAME:$IMAGE_TAG | xz -c > $ARTIFACT_NAME
54 - ls -lh $ARTIFACT_NAME
55 artifacts:
56 name: "$ARTIFACT_NAME"
57 paths:
58 - "*.tar.xz"
59 expire_in: 30 days
60 when: manual
61 allow_failure: false
62
63# Security scan stage (optional)
64security-scan:
65 stage: build
66 image: eclipse-temurin:22-jdk-alpine
67 before_script:
68 - apk add --no-cache maven
69 script:
70 - mvn $MAVEN_CLI_OPTS clean compile
71 allow_failure: true
72 when: manual
73
74# Deploy stage (placeholder for actual deployment)
75deploy:
76 stage: deploy
77 image: alpine:latest
78 before_script:
79 - apk add --no-cache curl
80 script:
81 - curl --version
82 only:
83 - tags
84 when: manual
85 allow_failure: false