image: gradle:alpine

stages:
  - build
  - test
  - deploy

variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"

before_script:
  - export GRADLE_USER_HOME=`pwd`/.gradle

build:
  stage: build
  script:
    - mv src/test/resources/martserver-plugins ~/martserver-plugins/
    - gradle build
    - gradle updateSiteZip
  artifacts:
    paths:
      - de.ugoe.cs.rwm.mocci.model/build/libs/*.jar
      - de.ugoe.cs.rwm.mocci.model.edit/build/libs/*.jar
      - de.ugoe.cs.rwm.mocci.model/build/updatesite.zip
    expire_in: 1 week
    
test:
  stage: test
  script:
   - mv src/test/resources/martserver-plugins ~/martserver-plugins/
   - gradle check
  artifacts:
    paths:
     - build/reports/
     - config/html/

pages:
  stage: deploy
  script:
    - mkdir public
    - mv config/html/* public
    - mv de.ugoe.cs.rwm.mocci.model/build/libs/*.jar public/model
    - mv de.ugoe.cs.rwm.mocci.model/build/updatesite.zip public/model
    - mv de.ugoe.cs.rwm.mocci.model.edit/build/libs/*.jar public/edit
  artifacts:
    paths:
      - public
    expire_in: 1 week
  only:
    - master

upload:
  stage: deploy
  script:
   - gradle upload
  only:
   - master

after_script:
  - echo "End CI"
  
