From 60251f878425276787e2b90fff86e282bf0cfb78 Mon Sep 17 00:00:00 2001
From: Sonia Zorba <sonia.zorba@inaf.it>
Date: Fri, 4 Dec 2020 14:27:00 +0100
Subject: [PATCH] Added CI

---
 .gitlab-ci.yml | 43 +++++++++++++++++++++++++++++++++++++++++++
 pom.xml        |  2 ++
 2 files changed, 45 insertions(+)
 create mode 100644 .gitlab-ci.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..39fe156
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,43 @@
+stages:
+  - build
+  - test
+  - deploy
+
+build:
+  stage: build
+  tags:
+    - docker
+  image: maven:3.6.3-openjdk-11
+  script:
+    - mvn clean package -DskipTests -DfinalName=vospace-datamodel
+  artifacts:
+    paths:
+      - target/vospace-datamodel.jar
+      - pom.xml
+    expire_in: 7 days
+  only:
+    - master
+
+test:
+  stage: test
+  tags:
+    - docker
+  script:
+    - mvn clean test
+    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print "coverage=" 100*covered/instructions }' target/site/jacoco/jacoco.csv
+  coverage: '/coverage=\d+\.\d+/'
+  only:
+    - master
+
+deploy:
+  stage: deploy
+  tags:
+    - docker
+  script:
+    - mvn deploy:deploy-file
+        -Dfile=target/vospace-datamodel.jar
+        -DrepositoryId=ia2.snapshots
+        -DpomFile=pom.xml
+        -Durl=${IA2_MVN_REPO_SNAPSHOTS}
+  only:
+    - master
diff --git a/pom.xml b/pom.xml
index 7b611d5..17b96ac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,6 +9,7 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <maven.compiler.source>11</maven.compiler.source>
         <maven.compiler.target>11</maven.compiler.target>
+        <finalName>${project.artifactId}-${project.version}</finalName>
     </properties>
     
     <dependencies>
@@ -45,6 +46,7 @@
         </dependency>
     </dependencies>
     <build>
+        <finalName>${finalName}</finalName>
         <plugins>            
             <plugin>
                 <artifactId>maven-surefire-plugin</artifactId>
-- 
GitLab