Skip to content
.gitlab-ci.yml 2.89 KiB
Newer Older
Sonia Zorba's avatar
Sonia Zorba committed
stages:
  - build
  - test
  - deploy
Sonia Zorba's avatar
Sonia Zorba committed

Sonia Zorba's avatar
Sonia Zorba committed
.gms_client:
Sonia Zorba's avatar
Sonia Zorba committed
  tags:
    - docker
Sonia Zorba's avatar
Sonia Zorba committed
  rules:
Sonia Zorba's avatar
Sonia Zorba committed
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
Sonia Zorba's avatar
Sonia Zorba committed
        - gms-client/gms-client/*

build_gms_client:
  extends: .gms_client
  stage: build
Sonia Zorba's avatar
Sonia Zorba committed
  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
  extends: .gms_client
  stage: test
  script:
    - cd gms-client/gms-client
    - mvn clean test
Sonia Zorba's avatar
Sonia Zorba committed
test_gms:
Sonia Zorba's avatar
Sonia Zorba committed
  stage: test
  tags:
    - docker
Sonia Zorba's avatar
Sonia Zorba committed
  image: git.ia2.inaf.it:5050/ia2/ia2-devops/maven-otj-pg-embedded
Sonia Zorba's avatar
Sonia Zorba committed
  script:
Sonia Zorba's avatar
Sonia Zorba committed
    - cd gms
Sonia Zorba's avatar
Sonia Zorba committed
    - mvn clean test
Sonia Zorba's avatar
Sonia Zorba committed
    - 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
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
Sonia Zorba's avatar
Sonia Zorba committed
        - gms/*
Sonia Zorba's avatar
Sonia Zorba committed

deploy_gms_client:
Sonia Zorba's avatar
Sonia Zorba committed
  extends: .gms_client
Sonia Zorba's avatar
Sonia Zorba committed
  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

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}
        -DpomFile=pom.xml
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
        - gms/*

Sonia Zorba's avatar
Sonia Zorba committed
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
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
Sonia Zorba's avatar
Sonia Zorba committed
        - 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
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
Sonia Zorba's avatar
Sonia Zorba committed
        - gms/*
        - gms-ui/*

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"'