<%# Copyright 2013-2025 the original author or authors from the JHipster project. This file is part of the JHipster project, see https://www.jhipster.tech/ for more information. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -%> <%_ if (insideDocker) { _%> image: jhipster/jhipster:v<%= jhipsterVersion %> <%_ } _%> <%_ if (buildToolGradle && !skipServer) { _%> cache: key: "$CI_COMMIT_REF_NAME" paths: - .gradle/ <%_ } _%> <%_ if (buildToolMaven && !skipServer) { _%> cache: key: "$CI_COMMIT_REF_NAME" paths: - .maven/ <%_ } _%> <%_ if (!skipServer) { _%> stages: - check - build - test - analyze - package - release - deploy <%_ } _%> <%_ if (buildToolGradle) { _%> before_script: <%_ if (clientFrameworkAngular) { _%> - export NG_CLI_ANALYTICS="false" <%_ } _%> - export GRADLE_USER_HOME=`pwd`/.gradle <%_ if (!skipClient) { _%> - ./gradlew <%= clientPackageManager %>_install -PnodeInstall --no-daemon <%_ } _%> nohttp: stage: check script: - ./gradlew checkstyleNohttp --no-daemon <%_ if (ciCdIntegrationsSnyk) { _%> dependency-scanning: stage: check script: - curl -Lo ./snyk $(curl -s https://api.github.com/repos/snyk/snyk/releases/latest | grep "browser_download_url.*snyk-linux" | cut -d ':' -f 2,3 | tr -d \" | tr -d ' ') - chmod +x snyk - ./snyk test --all-projects - ./snyk monitor --all-projects allow_failure: true <%_ } _%> gradle-compile: stage: build script: - ./gradlew compileJava -x check -PnodeInstall --no-daemon artifacts: paths: - build/classes/ - build/generated/ expire_in: 1 day gradle-test: stage: test script: - ./gradlew test -PnodeInstall --no-daemon artifacts: reports: junit: build/test-results/test/TEST-*.xml paths: - build/test-results/ - build/jacoco/ expire_in: 1 day gradle-integration-test: <%_ if (insideDocker) { _%> <%_ if (cacheProviderRedis || databaseTypeSql || databaseTypeCassandra || databaseTypeCouchbase || databaseTypeNeo4j) { _%> # DinD service is required for Testcontainers services: - docker:dind variables: # Instruct Testcontainers to use the daemon of DinD. DOCKER_HOST: 'tcp://docker:2375' # Improve performance with overlayfs. DOCKER_DRIVER: overlay2 <%_ } _%> <%_ } _%> stage: test script: - ./gradlew integrationTest -PnodeInstall --no-daemon artifacts: reports: junit: build/test-results/integrationTest/TEST-*.xml paths: - build/test-results/ - build/jacoco/ expire_in: 1 day <%_ if (!skipClient) { _%> frontend-test: stage: test script: - ./gradlew <%= clientPackageManager %>_run_<%= frontTestCommand %> -PnodeInstall --no-daemon artifacts: reports: junit: build/test-results/TESTS-results-jest.xml paths: - build/test-results/ - build/jacoco/ expire_in: 1 day <%_ } _%> <%_ if (ciCdIntegrationsSonar) { _%> sonar-analyze: stage: analyze except: - merge_requests dependencies: - gradle-test - gradle-integration-test <%_ if (!skipClient) { _%> - frontend-test <%_ } _%> script: - ./gradlew sonarqube --no-daemon <% if (sonarOrga) { %>-Dsonar.organization=<%= sonarOrga %> <% } %>-Dsonar.host.url=<%= sonarUrl %> -Dsonar.login=$SONAR_TOKEN allow_failure: true <%_ } _%> gradle-package: stage: package script: - ./gradlew bootJar -Pprod -PnodeInstall -x check --no-daemon artifacts: paths: - build/libs/*.jar - build/classes expire_in: 1 day # Uncomment the following section to enable pushing the Docker image to the GitLab Container Registry #docker-push: # stage: release # variables: # IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHA # dependencies: # - gradle-package # script: # - ./gradlew jib -Pprod -PnodeInstall -Djib.to.image=$IMAGE_TAG -Djib.to.auth.username=$CI_REGISTRY_USER -Djib.to.auth.password=$CI_REGISTRY_PASSWORD <%_ if (ciCdIntegrationsHeroku) { _%> deploy-to-production: stage: deploy script: - ./gradlew deployHeroku --no-daemon environment: name: production when: manual <%_ } _%> <%_ } _%> <%_ if (buildToolMaven) { _%> before_script: <%_ if (clientFrameworkAngular) { _%> - export NG_CLI_ANALYTICS="false" <%_ } _%> - export MAVEN_USER_HOME=`pwd`/.maven <%_ if (!skipClient) { _%> <%_ if (!insideDocker) { _%> - ./mvnw -ntp com.github.eirslett:frontend-maven-plugin:install-node-and-npm@install-node-and-npm -Dmaven.repo.local=$MAVEN_USER_HOME - ./mvnw -ntp com.github.eirslett:frontend-maven-plugin:<%= clientPackageManager %> -Dmaven.repo.local=$MAVEN_USER_HOME <%_ } _%> <%_ } _%> nohttp: stage: check script: - ./mvnw -ntp checkstyle:check -Dmaven.repo.local=$MAVEN_USER_HOME <%_ if (ciCdIntegrationsSnyk) { _%> dependency-scanning: stage: check script: - curl -Lo ./snyk $(curl -s https://api.github.com/repos/snyk/snyk/releases/latest | grep "browser_download_url.*snyk-linux" | cut -d ':' -f 2,3 | tr -d \" | tr -d ' ') - chmod +x snyk - ./snyk test --all-projects - ./snyk monitor --all-projects allow_failure: true <%_ } _%> maven-compile: stage: build script: - ./mvnw -ntp compile -P-webapp -Dmaven.repo.local=$MAVEN_USER_HOME artifacts: paths: - target/classes/ - target/generated-sources/ expire_in: 1 day maven-test: <%_ if (insideDocker) { _%> <%_ if (cacheProviderRedis || databaseTypeSql || databaseTypeCassandra || databaseTypeCouchbase || databaseTypeNeo4j) { _%> services: - docker:dind variables: # Instruct Testcontainers to use the daemon of DinD. DOCKER_HOST: 'tcp://docker:2375' # Improve performance with overlayfs. DOCKER_DRIVER: overlay2 <%_ } _%> <%_ } _%> stage: test script: - ./mvnw -ntp verify -P-webapp -Dmaven.repo.local=$MAVEN_USER_HOME artifacts: reports: junit: - target/surefire-reports/TEST-*.xml - target/failsafe-reports/TEST-*.xml paths: - target/surefire-reports - target/failsafe-reports - target/site expire_in: 1 day <%_ if (!skipClient) { _%> frontend-test: stage: test script: <%_ if (insideDocker) { _%> - npm install - npm test <%_ } else { _%> - ./mvnw -ntp com.github.eirslett:frontend-maven-plugin:<%= clientPackageManager %> -Dfrontend.<%= clientPackageManager %>.arguments='run <%= frontTestCommand %>' -Dmaven.repo.local=$MAVEN_USER_HOME <%_ } _%> artifacts: reports: junit: target/test-results/TESTS-results-jest.xml paths: - target/test-results - target/jacoco expire_in: 1 day <%_ } _%> <%_ if (ciCdIntegrationsSonar) { _%> sonar-analyze: stage: analyze dependencies: - maven-test <%_ if (!skipClient) { _%> - frontend-test <%_ } _%> script: - ./mvnw -ntp org.jacoco:jacoco-maven-plugin:prepare-agent initialize sonar:sonar <% if (sonarOrga) { %>-Dsonar.organization=<%= sonarOrga %> <% } %>-Dsonar.host.url=<%= sonarUrl %> -Dsonar.login=$SONAR_TOKEN -Dmaven.repo.local=$MAVEN_USER_HOME allow_failure: true <%_ } _%> maven-package: stage: package script: - ./mvnw -ntp verify <% if (ciCdIntegrationsDeploy) { %>deploy <% } %>-Pprod -DskipTests -Dmaven.repo.local=$MAVEN_USER_HOME artifacts: paths: - target/*.jar - target/classes expire_in: 1 day # Uncomment the following section to enable pushing the Docker image to the GitLab Container Registry #docker-push: # stage: release # variables: # IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHA # dependencies: # - maven-package # script: # - ./mvnw -ntp jib:build -Pprod -Djib.to.image=$IMAGE_TAG -Djib.to.auth.username=$CI_REGISTRY_USER -Djib.to.auth.password=$CI_REGISTRY_PASSWORD -Dmaven.repo.local=$MAVEN_USER_HOME <%_ if (ciCdIntegrationsHeroku) { _%> deploy-to-production: stage: deploy script: - ./mvnw -ntp com.heroku.sdk:heroku-maven-plugin:3.0.7:deploy -DskipTests -Pprod -Dheroku.buildpacks=heroku/jvm -Dheroku.appName=<%= herokuAppName %> -Dmaven.repo.local=$MAVEN_USER_HOME environment: name: production when: manual <%_ } _%> <%_ } _%> <%_ if (skipServer) { _%> cache: paths: - node_modules/ stages: - build - test <%_ if (ciCdIntegrationsSonar) { _%> - analyze <%_ } _%> - packaging webapp-build: stage: build script: - <%= clientPackageManager %> install - <%= clientPackageManager %> run webapp:build artifacts: paths: - build/ webapp-test: stage: test dependencies: - webapp-build script: - <%= clientPackageManager %> run webapp:test artifacts: reports: junit: build/test-results/TESTS-results-jest.xml paths: - build/test-results expire_in: 1 day <%_ if (ciCdIntegrationsSonar) { _%> sonar-analyze: stage: analyze dependencies: - webapp-test script: - npm run sonar artifacts: paths: - build/ - build/test-results <%_ } _%> webapp-prod: stage: packaging script: - <%= clientPackageManager %> run webapp:prod # - add cmd to zip the app folder build/resources/main/static artifacts: paths: - build/ <%_ } _%>