Commit 17bb1560 authored by LAVENIER's avatar LAVENIER
Browse files

Merge branch 'develop' into feature/imagine

parents c71d399a 9ef711bc
# ---------------------------------------------------------------
# Global
# ---------------------------------------------------------------
# default image
image: jlrigau/maven-git
# stages (main steps of pipeline)
stages:
- build
- alt_build
- test
- docs
- release
- docker
- docs
# ---------------------------------------------------------------
# Global variables
# ---------------------------------------------------------------
variables:
DOCKER_DRIVER: overlay2
ANSIBLE_FORCE_COLOR: '1'
CI_BUILD_IMAGE: $CI_REGISTRY_IMAGE/build:develop
#CONTAINER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE:develop
MAVEN_LOCAL_REPO: /root/.m2/repository/
MAVEN_REPO_URL: https://gitlab.ifremer.fr/api/v4/projects/1272/packages/maven
APP_CORE_MODULE: sumaris-core
APP_DB_MODULE: sumaris-db
APP_WAR_MODULE: sumaris-server
ARTIFACT_WAR_FILE: "${APP_WAR_MODULE}/target/*.war"
ARTIFACT_CONFIG_FILES: "${APP_WAR_MODULE}/target/classes/*.properties"
ENV_FILE: target/variables.env
# ---------------------------------------------------------------
# Jobs templates
# ---------------------------------------------------------------
.docker:
image: docker:latest
tags: [sih_public_runner]
services:
- docker:dind
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
after_script:
- docker logout ${CI_REGISTRY}
allow_failure: false
# ---------------------------------------------------------------
# Build jobs
# ---------------------------------------------------------------
.build:
stage: build
tags:
- sih_public_runner
tags: [sih_public_runner]
script:
- echo "Test dev build in progress"
- mvn -s ./ci_settings.xml -q clean install -DskipTests
- echo "Building from sources..."
- mvn clean install -s ./ci_settings.xml -q -DskipTests
after_script:
# Get project version
- mkdir -p target
- APP_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout --non-recursive)
- echo "APP_VERSION=${APP_VERSION}" > ${ENV_FILE}
environment:
name: test
artifacts:
paths:
- ${ARTIFACT_WAR_FILE}
- ${ARTIFACT_CONFIG_FILES}
reports:
dotenv: ${ENV_FILE}
expire_in: 60 minutes
build_auto:
build:
extends: .build
image: ${CI_BUILD_IMAGE}
only:
- develop
- feature/imagine
except:
- schedules
schedule_build:
failsafe-build:
extends: .build
stage: alt_build
when: on_failure
only:
- schedules
- develop
build_registry:
extends: .build
after_script:
- echo "Deploy Snapshot in progress"
- SNAPSHOT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
- echo $SNAPSHOT_VERSION
- mvn -s ./ci_settings.xml deploy:deploy-file -DgroupId=fr.ifremer -DartifactId=imagine-pod -Dversion=$SNAPSHOT_VERSION -Dfile=sumaris-server/target/sumaris-server-$SNAPSHOT_VERSION.war -DrepositoryId=job-maven -Durl=https://gitlab.ifremer.fr/api/v4/projects/1272/packages/maven
docker:ci:
extends: .docker
stage: alt_build
when: on_failure
allow_failure: true
script:
# Create the target directory
- mkdir -p target/ci && cd target/ci
# Create the Dockerfile
- echo 'FROM jlrigau/maven-git' > Dockerfile
- echo 'WORKDIR /tmp/.build-cache' >> Dockerfile
- echo 'COPY ./ ./' >> Dockerfile
- echo "ENV MAVEN_LOCAL_REPO=${MAVEN_LOCAL_REPO}" >> Dockerfile
- echo 'RUN du -s `find ${MAVEN_LOCAL_REPO} -maxdepth 1 | egrep -v "^\.$"` > /tmp/before.txt' >> Dockerfile
- echo 'RUN mvn install -s ./ci_settings.xml -q -DskipTests' >> Dockerfile
- echo 'RUN mvn clean -s ./ci_settings.xml -q' >> Dockerfile
- echo 'RUN du -s `find ${MAVEN_LOCAL_REPO} -maxdepth 1 | egrep -v "^\.$"` > /tmp/after.txt' >> Dockerfile
- echo "RUN diff /tmp/before.txt /tmp/after.txt || true" >> Dockerfile
- echo 'WORKDIR /build' >> Dockerfile
# Build and push the CI image
- docker build --pull -t ${CI_BUILD_IMAGE} .
- docker push ${CI_BUILD_IMAGE}
only:
- develop
- feature/imagine
artifacts:
paths:
- sumaris-server/target/*.war
when: manual
- target/ci/Dockerfile
expire_in: 60 minutes
# ---------------------------------------------------------------
# Test jobs
# ---------------------------------------------------------------
sonarqube:
stage: test
......@@ -50,7 +126,7 @@ sonarqube:
- sih_public_runner
variables:
SONAR_TOKEN: "e6f816eee72d3d5c03319ec74b468157b9164d12"
SONAR_HOST_URL: "http://visi-common-sonar.ifremer.fr:9000"
SONAR_HOST_URL: http://visi-common-sonar.ifremer.fr:9000
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
......@@ -65,61 +141,82 @@ sonarqube:
-Dsonar.java.libraries=.
only:
- develop
- feature/imagine
when: manual
# ---------------------------------------------------------------
# Deploy jobs
# ---------------------------------------------------------------
pages:
stage: docs
tags:
- sih_public_runner
image: python:3.7-alpine
script:
- mvn -s ./ci_settings.xml -q site
after_script:
- mv target/site public
artifacts:
paths:
- public
only:
- develop
- feature/imagine
when: manual
#.deploy-file:
# stage: deploy
# tags: [sih_public_runner]
# script:
# - APP_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
# - APP_GROUP_ID=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.groupId -q -DforceStdout)
# - mvn -s ./ci_settings.xml deploy:deploy-file -DgroupId=${APP_GROUP_ID} -DartifactId=${APP_WAR_MODULE} -Dversion=${APP_VERSION} -Dfile=${APP_WAR_MODULE}/target/${APP_WAR_MODULE}-${APP_VERSION}.war -DrepositoryId=job-maven -Durl=$MAVEN_REPO_URL
# only:
# - develop
#
#fast-deploy-file:
# extends: .deploy-file
# needs: [fast-build]
#
#failsafe-deploy-file:
# extends: .deploy-file
# needs: [failsafe-build]
# ---------------------------------------------------------------
# Release jobs
# ---------------------------------------------------------------
release:
.release:
stage: release
tags:
- sih_public_runner
tags: [sih_public_runner]
before_script:
- git checkout -B "$CI_BUILD_REF_NAME"
- git remote set-url origin ${CI_REPOSITORY_URL}
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git config --global user.name "${GITLAB_USER_NAME}"
- echo "RELEASE_VERSION=${RELEASE_VERSION}" >> variables.env
- test "_" = "_$RELEASE_VERSION" && echo "ERROR: missing Pipeline variable 'RELEASE_VERSION'" && exit 1
- git reset --hard develop
- git fetch origin
script:
- echo "Preparing release"
- echo "Preparing release..."
- git branch -D release/$RELEASE_VERSION || true
- git pull origin develop && git checkout develop && git status
- mvn -s ./ci_settings.xml -B gitflow:release-start --batch-mode -DreleaseVersion="$RELEASE_VERSION"
- echo "Performing release"
- mvn -s ./ci_settings.xml clean deploy --batch-mode -DperformRelease -DskipTests -Dspring.datasource.platform=hsqldb
- echo "Creating test DB"
- mvn -pl sumaris-core -Prun,hsqldb -DskipTests --batch-mode
- cd sumaris-core/target && zip -q -r "sumaris-db-$RELEASE_VERSION.zip" db && cd ../..
- echo "Performing release..."
- mvn clean install -s ./ci_settings.xml --batch-mode -DperformRelease -DskipTests
- echo "Creating test DB..."
- mvn -pl ${APP_CORE_MODULE} -q -Prun,hsqldb -DskipTests --batch-mode
- cd ${APP_CORE_MODULE}/target && tar -cf "${APP_DB_MODULE}-${RELEASE_VERSION}.tar.gz" db && cd ../..
- echo "Pushing changes to upstream"
- git commit -a -m "Release $RELEASE_VERSION"
- git status
- mvn gitflow:release-finish
after_script:
- echo "APP_VERSION=${RELEASE_VERSION}" > ${ENV_FILE}
artifacts:
paths:
- sumaris-core/target/*.zip
- sumaris-server/target/*.war
- ${ARTIFACT_WAR_FILE}
- ${ARTIFACT_CONFIG_FILES}
- ${APP_WAR_MODULE}/target/*.tar.gz
- ${APP_WAR_MODULE}/target/*.zip
reports:
dotenv: variables.env
dotenv: ${ENV_FILE}
only:
- develop
allow_failure: false
when: manual
release:
extends: .release
image: ${CI_BUILD_IMAGE}
needs:
- build
failsafe-release:
extends: .release
needs:
- failsafe-build
gitlab-release:
stage: release
tags: [sih_public_runner]
......@@ -127,10 +224,81 @@ gitlab-release:
script:
- echo "running release for ${CI_COMMIT_TAG}"
release:
name: "Release sumaris-pod-$TAG"
name: "Release ${CI_PROJECT_NAME}-${CI_COMMIT_TAG}"
description: "Created using the release-cli $EXTRA_DESCRIPTION"
tag_name: "${CI_COMMIT_TAG}"
ref: "${CI_COMMIT_TAG}"
only:
- tags
# ---------------------------------------------------------------
# Docker jobs
# ---------------------------------------------------------------
.docker-build:
extends: .docker
stage: docker
script:
# Create the target directory
- mkdir -p target/docker/config
- cp -rf ${APP_WAR_MODULE}/src/main/docker/* target/docker/
- cp -f ${ARTIFACT_WAR_FILE} target/docker/app.war
- cp -f ${ARTIFACT_CONFIG_FILES} target/docker/config/
- ls -l target/docker/config
- cd target/docker
# Build docker image
- docker pull ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} || true
- docker build --cache-from ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} --pull -t ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} .
#- docker build --no-cache -t ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} .
- docker push ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}
artifacts:
paths:
- target/docker
expire_in: 60 minutes
docker:develop:
extends: .docker-build
variables:
IMAGE_TAG: develop
only:
- develop
docker:imagine:
extends: .docker-build
variables:
IMAGE_TAG: imagine
only:
- feature/imagine
docker:release:
extends: .docker-build
variables:
IMAGE_TAG: $CI_COMMIT_TAG
only:
- tags
# ---------------------------------------------------------------
# Docs jobs
# ---------------------------------------------------------------
pages:
stage: docs
tags: [sih_public_runner]
image: python:3.7-alpine
before_script:
- git submodule foreach git fetch origin
- git submodule foreach git pull
script:
- Echo "Generate SVG images"
- git submodule foreach ./generate.sh
- mvn -s ./ci_settings.xml site -q -Prun,hsqldb -DperformRelease
after_script:
- mv target/site public
artifacts:
paths:
- public
only:
- develop
when: manual
......@@ -46,93 +46,10 @@ under the License.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ~/.m2/repository
-->
<localRepository>/root/.m2/repository/</localRepository>
<!-- interactiveMode
| This will determine whether maven prompts you when it needs input. If set to false,
| maven will use a sensible default value, perhaps based on some other setting, for
| the parameter in question.
|
| Default: true
<interactiveMode>true</interactiveMode>
-->
<!-- offline
| Determines whether maven should attempt to connect to the network when executing a build.
| This will have an effect on artifact downloads, artifact deployment, and others.
|
| Default: false
<offline>false</offline>
-->
<!-- pluginGroups
| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
|-->
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups>
<!-- proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies>
<localRepository>/root/.m2/repository/</localRepository>
<!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
|-->
<servers>
<!-- server
| Specifies the authentication information to use when connecting to a particular server, identified by
| a unique name within the system (referred to by the 'id' attribute below).
|
| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
| used together.
|
<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>
-->
<server>
<id>internal-maven</id>
<username>${env.MAVEN_REPO_USER}</username>
<password>${env.MAVEN_REPO_PASS}</password>
</server>
<server>
<id>project-maven</id>
<username>gitlab+deploy-token-62</username>
<password>54gJ-pk4XDxmjoxBdirx</password>
</server>
<server>
<id>job-maven</id>
<configuration>
......@@ -151,115 +68,27 @@ under the License.
</server>
</servers>
<!-- mirrors
| This is a list of mirrors to be used in downloading artifacts from remote repositories.
|
| It works like this: a POM may declare a repository to use in resolving certain artifacts.
| However, this repository may have problems with heavy traffic at times, so people have mirrored
| it to several places.
|
| That repository definition will have a unique id, so we can create a mirror reference for that
| repository, to be used as an alternate download site. The mirror site will be the preferred
| server for that repository.
|-->
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
</mirrors>
<!-- profiles
| This is a list of profiles which can be activated in a variety of ways, and which can modify
| the build process. Profiles provided in the settings.xml are intended to provide local machine-
| specific paths and repository locations which allow the build to work in the local environment.
|
| For example, if you have an integration testing plugin - like cactus - that needs to know where
| your Tomcat instance is installed, you can provide a variable here such that the variable is
| dereferenced during the build process to configure the cactus plugin.
|
| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
| section of this document (settings.xml) - will be discussed later. Another way essentially
| relies on the detection of a system property, either matching a particular value for the property,
| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
| Finally, the list of active profiles can be specified directly from the command line.
|
| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
| repositories, plugin repositories, and free-form properties to be used as configuration
| variables for plugins in the POM.
|
|-->
<profiles>
<!-- profile
| Specifies a set of introductions to the build process, to be activated using one or more of the
| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id's for debug.
|
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
-->
<profile>
<id>gitlab-profile</id>
<repositories>
<repository>
<id>project-maven</id>
<id>job-maven</id>
<url>https://gitlab.ifremer.fr/api/v4/projects/1272/packages/maven</url>
</repository>
</repositories>
<properties>
<release.server>internal-maven</release.server>
<release.server>job-maven</release.server>
<release.repository>https://gitlab.ifremer.fr/api/v4/projects/1272/packages/maven</release.repository>
<snapshot.server>job-maven</snapshot.server>
<snapshot.repository>https://gitlab.ifremer.fr/api/v4/projects/1226/packages/maven</snapshot.repository>
<snapshot.repository>https://gitlab.ifremer.fr/api/v4/projects/1272/packages/maven</snapshot.repository>
</properties>
</profile>
</profiles>
<!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
<activeProfiles>
<activeProfile>staging</activeProfile>
</activeProfiles>-->
<activeProfiles>
<activeProfile>gitlab-profile</activeProfile>
<activeProfile>hsqldb</activeProfile>
</activeProfiles>
</settings>
\ No newline at end of file
......@@ -182,9 +182,9 @@
<!-- release config -->
<autoVersionSubmodules>true</autoVersionSubmodules>
<goals>deploy</goals>
<arguments>-DperformFullRelease -Dspring.datasource.platform=hsqldb</arguments>
<arguments>-Phsqldb</arguments>
<preparationGoals>verify</preparationGoals>
<gitflowPluginVersion>1.14.0</gitflowPluginVersion>
<gitflowPluginVersion>1.14.0</gitflowPluginVersion>
<!-- Last JRE version to use -->
<jreVersion>1.8.77</jreVersion>
......@@ -1598,12 +1598,6 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>natusoft-repo</id>
<name>NS GitHub stuff temp repo</name>
<url>https://download.natusoft.se/maven</url>
</repository>
</repositories>
<pluginRepositories>
......@@ -1619,16 +1613,6 @@
<checksumPolicy>fail</checksumPolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>ns-plugin-repo</id>
<name>ns-plugin-repository</name>
<url>https://download.natusoft.se/maven</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
......
Subproject commit 66ff05b00d8e6f53e744bf7a454ec02fd49cbdac
Subproject commit 3b6e149ac009099f8234c3825cf8bb3bacb01f97
......@@ -122,7 +122,7 @@ public class SumarisConfiguration extends PropertyPlaceholderConfigurer {
public SumarisConfiguration(ConfigurableEnvironment env,
String... args) {
this(env, "application.properties", args);
this(env, "application.fake.properties", args);
}
public SumarisConfiguration(String file,
......
......@@ -22,7 +22,7 @@ package net.sumaris.core.util;
* #L%
*/
import com.google.common.collect.ImmutableList;
import graphql.com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.regex.Matcher;
......
......@@ -366,6 +366,7 @@
<jdbc.password />
<jdbc.driver>org.hsqldb.jdbc.JDBCDriver</jdbc.driver>
<jdbc.schema>PUBLIC</jdbc.schema>
<spring.datasource.platform>hsqldb</spring.datasource.platform>
<hibernate.dialect>net.sumaris.core.dao.technical.hibernate.spatial.HSQLSpatialDialect</hibernate.dialect>
<hibernate.jdbcBatchSize>15</hibernate.jdbcBatchSize>
</properties>
......@@ -396,6 +397,7 @@
<jdbc.password />
<jdbc.driver>org.h2.Driver</jdbc.driver>
<jdbc.schema>PUBLIC</jdbc.schema>
<spring.datasource.platform>h2</spring.datasource.platform>