.gitlab-ci.yml 2.89 KB
Newer Older
Sonia Zorba's avatar
Sonia Zorba committed
1
2
3
4
stages:
  - build
  - test
  - deploy
5
  - publish
Sonia Zorba's avatar
Sonia Zorba committed
6

Sonia Zorba's avatar
Sonia Zorba committed
7
.gms_client:
Sonia Zorba's avatar
Sonia Zorba committed
8
9
  tags:
    - docker
Sonia Zorba's avatar
Sonia Zorba committed
10
  rules:
Sonia Zorba's avatar
Sonia Zorba committed
11
12
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
Sonia Zorba's avatar
Sonia Zorba committed
13
14
15
16
17
        - gms-client/gms-client/*

build_gms_client:
  extends: .gms_client
  stage: build
Sonia Zorba's avatar
Sonia Zorba committed
18
19
20
21
22
23
24
25
26
27
  script:
    - cd gms-client/gms-client
    - mvn clean package -DskipTests -DfinalName=gms-client
  artifacts:
    paths:
      - gms-client/gms-client/target/gms-client.jar
      - gms-client/gms-client/pom.xml
    expire_in: 7 days

test_gms_client:
Sonia Zorba's avatar
Sonia Zorba committed
28
29
30
31
32
  extends: .gms_client
  stage: test
  script:
    - cd gms-client/gms-client
    - mvn clean test
33
    
Sonia Zorba's avatar
Sonia Zorba committed
34
test_gms:
Sonia Zorba's avatar
Sonia Zorba committed
35
36
37
  stage: test
  tags:
    - docker
Sonia Zorba's avatar
Sonia Zorba committed
38
  image: git.ia2.inaf.it:5050/ia2/ia2-devops/maven-otj-pg-embedded
Sonia Zorba's avatar
Sonia Zorba committed
39
  script:
Sonia Zorba's avatar
Sonia Zorba committed
40
    - cd gms
Sonia Zorba's avatar
Sonia Zorba committed
41
    - mvn clean test
Sonia Zorba's avatar
Sonia Zorba committed
42
43
44
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print "coverage=" 100*covered/instructions }' target/site/jacoco/jacoco.csv
  coverage: '/coverage=\d+\.\d+/'
  rules:
Sonia Zorba's avatar
Sonia Zorba committed
45
46
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
Sonia Zorba's avatar
Sonia Zorba committed
47
        - gms/*
Sonia Zorba's avatar
Sonia Zorba committed
48
49

deploy_gms_client:
Sonia Zorba's avatar
Sonia Zorba committed
50
  extends: .gms_client
Sonia Zorba's avatar
Sonia Zorba committed
51
52
53
54
55
56
57
  stage: deploy
  script:
    - mvn deploy:deploy-file
        -Dfile=gms-client/gms-client/target/gms-client.jar
        -DrepositoryId=ia2.snapshots
        -DpomFile=gms-client/gms-client/pom.xml
        -Durl=${IA2_MVN_REPO_SNAPSHOTS}
Sonia Zorba's avatar
Sonia Zorba committed
58

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
deploy_gms_lib:
  stage: deploy
  tags:
    - docker
  script:
    - cd gms
    - mvn clean package -DskipTests
    - version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
    - mvn deploy:deploy-file
        -Dfile=target/gms-lib.jar
        -DartifactId=gms
        -DgroupId=it.inaf.ia2
        -Dclassifier=lib
        -DrepositoryId=ia2.snapshots
        -Dversion=$version
        -Durl=${IA2_MVN_REPO_SNAPSHOTS}
75
        -DpomFile=pom.xml
76
77
78
79
80
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
        - gms/*

Sonia Zorba's avatar
Sonia Zorba committed
81
82
83
84
85
86
87
88
89
dockerize_db:
  stage: deploy
  tags:
    - shell
  script:
    - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
    - docker build -t "${CI_REGISTRY_IMAGE}/database" -f database/Dockerfile .
    - docker push "${CI_REGISTRY_IMAGE}/database"
  rules:
Sonia Zorba's avatar
Sonia Zorba committed
90
91
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
Sonia Zorba's avatar
Sonia Zorba committed
92
93
94
95
96
97
98
99
100
101
102
103
        - database/*
        - gms/src/main/resources/sql/*

dockerize_gms:
  stage: deploy
  tags:
    - shell
  script:
    - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
    - docker build -t "${CI_REGISTRY_IMAGE}" -f gms/Dockerfile .
    - docker push "${CI_REGISTRY_IMAGE}"
  rules:
Sonia Zorba's avatar
Sonia Zorba committed
104
105
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
Sonia Zorba's avatar
Sonia Zorba committed
106
107
        - gms/*
        - gms-ui/*
108
109
110
111
112
113
114
115
116
117
118

upload_jar:
  stage: publish
  tags:
    - shell
  only:
    - master
  script:
    # extract jar from Docker image
    - docker run --rm --entrypoint cat "${CI_REGISTRY_IMAGE}" /gms.jar > gms.jar
    - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file gms.jar "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/gms/latest/gms.jar"'