.gitlab-ci.yml 1.51 KB
Newer Older
Daniel Gerhardt's avatar
Daniel Gerhardt committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
variables:
  MIRROR_REPO: git@github.com:thm-projects/arsnova-backend.git
  WAR_FILE: target/arsnova-backend-*.war

stages:
  - analysis
  - test
  - build
  - deploy
  - synchronization

cache:
  paths:
    - .m2/

sync_mirror:
  stage: synchronization
  when: always
  except:
    - production
    - staging
Daniel Gerhardt's avatar
Daniel Gerhardt committed
22 23
  tags:
    - git
Daniel Gerhardt's avatar
Daniel Gerhardt committed
24 25
  allow_failure: true
  script:
Daniel Gerhardt's avatar
Daniel Gerhardt committed
26 27
    - mkdir ~/.ssh && echo "$GITHUB_HOST_KEY" > ~/.ssh/known_hosts
    - eval $(ssh-agent -s) && ssh-add <(echo "$GITHUB_DEPLOY_KEY")
28
    - git clone --bare "$CI_BUILD_REPO" mirror.git
Daniel Gerhardt's avatar
Daniel Gerhardt committed
29 30 31
    - cd mirror.git
    - git update-ref -d refs/tags/production
    - git update-ref -d refs/tags/staging
32
    - git push --mirror "$MIRROR_REPO"
Daniel Gerhardt's avatar
Daniel Gerhardt committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

sonar:
  stage: analysis
  only:
    - master
  tags:
    - maven
  allow_failure: true
  script:
    - mvn sonar:sonar

checkstyle:
  stage: analysis
  tags:
    - maven
  script:
    - mvn checkstyle:checkstyle

test:
  stage: test
  tags:
    - maven
  script:
    - mvn test

package:
  stage: build
  tags:
    - maven
  artifacts:
    paths:
      - $WAR_FILE
  script:
    - mvn package -DskipTests

tomcat_production:
  stage: deploy
  only:
    - production
  script:
73
    - curl --fail --upload-file $WAR_FILE "https://$PROD_TOMCAT_USER:$PROD_TOMCAT_PASSWORD@$PROD_TOMCAT_HOST/manager/text/deploy?path=%2Fapi&update=true"
Daniel Gerhardt's avatar
Daniel Gerhardt committed
74 75 76 77 78 79

tomcat_development:
  stage: deploy
  only:
    - staging
  script:
80
    - curl --fail --upload-file $WAR_FILE "https://$DEV_TOMCAT_USER:$DEV_TOMCAT_PASSWORD@$DEV_TOMCAT_HOST/manager/text/deploy?path=%2Fapi&update=true"