| # GitLab CI/CD Pipeline for Kalamar-Plugin-Export |
| # This pipeline runs tests on pushes and builds Docker containers on tag pushes and manual triggers |
| |
| stages: |
| - test-and-build |
| - build |
| - deploy |
| |
| variables: |
| MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" |
| MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version" |
| DOCKER_IMAGE_NAME: "korap/kalamar-plugin-export" |
| |
| # Cache Maven dependencies |
| cache: |
| paths: |
| - .m2/repository/ |
| |
| # Test and build stage - runs on all pushes |
| test-and-build: |
| stage: test-and-build |
| image: eclipse-temurin:22-jdk-alpine |
| before_script: |
| - apk add --no-cache maven |
| - export MAVEN_OPTS="$MAVEN_OPTS" |
| script: |
| - mvn $MAVEN_CLI_OPTS clean test package |
| artifacts: |
| reports: |
| junit: |
| - target/surefire-reports/TEST-*.xml |
| paths: |
| - target/surefire-reports/ |
| - target/*.jar |
| expire_in: 1 week |
| only: |
| - pushes |
| - merge_requests |
| |
| # Build Docker image stage - available on all branches but only runs manually |
| build-docker: |
| stage: build |
| image: docker:24.0.5 |
| services: |
| - docker:24.0.5-dind |
| before_script: |
| - apk add --no-cache xz |
| script: |
| - export IMAGE_TAG=${CI_COMMIT_TAG:-latest} |
| - export ARTIFACT_NAME=kalamar-plugin-export-${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}.tar.xz |
| - docker build -t $DOCKER_IMAGE_NAME:$IMAGE_TAG . |
| - docker build -t $DOCKER_IMAGE_NAME:latest . |
| - docker save $DOCKER_IMAGE_NAME:$IMAGE_TAG | xz -c > $ARTIFACT_NAME |
| - ls -lh $ARTIFACT_NAME |
| artifacts: |
| name: "$ARTIFACT_NAME" |
| paths: |
| - "*.tar.xz" |
| expire_in: 30 days |
| when: manual |
| allow_failure: false |
| |
| # Security scan stage (optional) |
| security-scan: |
| stage: build |
| image: eclipse-temurin:22-jdk-alpine |
| before_script: |
| - apk add --no-cache maven |
| script: |
| - mvn $MAVEN_CLI_OPTS clean compile |
| allow_failure: true |
| when: manual |
| |
| # Deploy stage (placeholder for actual deployment) |
| deploy: |
| stage: deploy |
| image: alpine:latest |
| before_script: |
| - apk add --no-cache curl |
| script: |
| - curl --version |
| only: |
| - tags |
| when: manual |
| allow_failure: false |