<%# Copyright 2013-2019 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 http://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 (buildTool === 'gradle') { _%> cache: key: "$CI_COMMIT_REF_NAME" paths: - .gradle/ <%_ } _%> <%_ if (buildTool === 'maven') { _%> cache: key: "$CI_COMMIT_REF_NAME" paths: - .maven/ <%_ } _%> stages: - build - test - analyze - package - release - deploy <%_ if (buildTool === 'gradle') { _%> before_script: - export GRADLE_USER_HOME=`pwd`/.gradle <%_ if (!skipClient) { _%> - ./gradlew <%= clientPackageManager %>_install -PnodeInstall --no-daemon <%_ } _%> 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 <%_ if (!skipClient) { _%> frontend-test: stage: test script: - ./gradlew <%= clientPackageManager %>_run_<%= frontTestCommand %> -PnodeInstall --no-daemon artifacts: reports: junit: build/test-results/TESTS-*.xml paths: - build/test-results/ - build/jacoco/ expire_in: 1 day <%_ } _%> <%_ if (cicdIntegrations.includes('sonar')) { _%> sonar-analyze: stage: analyze dependencies: - gradle-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 bootWar -Pprod -x check --no-daemon artifacts: paths: - build/libs/*.war expire_in: 1 day # Uncomment the following line to use gitlabs container registry. You need to adapt the REGISTRY_URL in case you are not using gitlab.com #docker-push: # image: docker:latest # services: # - docker:dind # variables: # REGISTRY_URL: registry.gitlab.com # DOCKER_HOST: tcp://docker:2375 # DOCKER_DRIVER: overlay2 # IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG # stage: release # dependencies: # - gradle-package # before_script: # - docker info # - cp build/libs/*.war src/main/docker # script: # - docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $REGISTRY_URL # - docker build -f src/main/docker/Dockerfile -t $IMAGE_TAG src/main/docker # - docker push $IMAGE_TAG <%_ if (cicdIntegrations.includes('heroku')) { _%> deploy-to-production: stage: deploy script: - ./gradlew deployHeroku --no-daemon environment: name: production when: manual <%_ } _%> <%_ } _%> <%_ if (buildTool === 'maven') { _%> before_script: - export MAVEN_USER_HOME=`pwd`/.maven <%_ if (!skipClient) { _%> <%_ if (clientPackageManager === 'yarn') { _%> - ./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-yarn -DnodeVersion=v<%= NODE_VERSION %> -DyarnVersion=v<%= YARN_VERSION %> -Dmaven.repo.local=$MAVEN_USER_HOME <%_ } else if (clientPackageManager === 'npm') { _%> - ./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-npm -DnodeVersion=v<%= NODE_VERSION %> -DnpmVersion=<%= NPM_VERSION %> -Dmaven.repo.local=$MAVEN_USER_HOME <%_ } _%> - ./mvnw com.github.eirslett:frontend-maven-plugin:<%= clientPackageManager %> -Dmaven.repo.local=$MAVEN_USER_HOME <%_ } _%> maven-compile: stage: build script: - ./mvnw compile -Dmaven.repo.local=$MAVEN_USER_HOME artifacts: paths: - target/classes/ - target/generated-sources/ expire_in: 1 day maven-test: stage: test script: - ./mvnw test -Dmaven.repo.local=$MAVEN_USER_HOME artifacts: reports: junit: target/surefire-reports/TEST-*.xml paths: - target/test-results expire_in: 1 day <%_ if (!skipClient) { _%> frontend-test: stage: test script: - ./mvnw com.github.eirslett:frontend-maven-plugin:<%= clientPackageManager %> -Dfrontend.<%= clientPackageManager %>.arguments='<%= frontTestCommand %>' -Dmaven.repo.local=$MAVEN_USER_HOME artifacts: reports: junit: target/test-results/TESTS-*.xml paths: - target/test-results expire_in: 1 day <%_ } _%> <%_ if (cicdIntegrations.includes('sonar')) { _%> sonar-analyze: stage: analyze dependencies: - maven-test <%_ if (!skipClient) { _%> - frontend-test <%_ } _%> script: - ./mvnw compile -Dmaven.repo.local=$MAVEN_USER_HOME - ./mvnw org.jacoco:jacoco-maven-plugin:prepare-agent 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 verify <% if (cicdIntegrations.includes('deploy')) { %>deploy <% } %>-Pprod -DskipTests -Dmaven.repo.local=$MAVEN_USER_HOME artifacts: paths: - target/*.war expire_in: 1 day # Uncomment the following line to use gitlabs container registry. You need to adapt the REGISTRY_URL in case you are not using gitlab.com #docker-push: # image: docker:latest # services: # - docker:dind # variables: # REGISTRY_URL: registry.gitlab.com # DOCKER_HOST: tcp://docker:2375 # DOCKER_DRIVER: overlay2 # IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG # stage: release # dependencies: # - maven-package # before_script: # - docker info # - cp target/*.war src/main/docker # script: # - docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $REGISTRY_URL # - docker build -f src/main/docker/Dockerfile -t $IMAGE_TAG src/main/docker # - docker push $IMAGE_TAG <%_ if (cicdIntegrations.includes('heroku')) { _%> deploy-to-production: stage: deploy script: - ./mvnw com.heroku.sdk:heroku-maven-plugin:2.0.5:deploy -DskipTests -Pprod -Dheroku.buildpacks=heroku/jvm -Dheroku.appName=<%= herokuAppName %> -Dmaven.repo.local=$MAVEN_USER_HOME environment: name: production when: manual <%_ } _%> <%_ } _%>