.gitlab-ci.yml 2.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
# this file is a template, and might need editing before it works on your project.
---
# Build JAVA applications using Apache Maven (http://maven.apache.org)
# For docker image tags see https://hub.docker.com/_/maven/
#
# For general lifecycle information see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
# 
# This template will build and test your projects as well as create the documentation.
# 
# * Caches downloaded dependencies and plugins between invocation.
variables:
  # This will supress any download for dependencies and plugins or upload messages which would clutter the console log.
  # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
14
  MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true -Dmaven.repo.local=/cache/maven.repository"
15 16 17
  # As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
  # when running from the command line.
  # `installAtEnd` and `deployAtEnd`are only effective with recent version of the corresponding plugins.
Nicola Bertazzo's avatar
Nicola Bertazzo committed
18
  MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
19 20

# Cache downloaded dependencies and plugins between builds.
21 22 23
# cache:
#  paths:
#    - $HOME/.m2/repository/
Nicola Bertazzo's avatar
Nicola Bertazzo committed
24 25 26 27
stages:
  - build
  - test
  - deploy
Nicola Bertazzo's avatar
Nicola Bertazzo committed
28

29
build:
Nicola Bertazzo's avatar
Nicola Bertazzo committed
30
  stage: build
Nicola Bertazzo's avatar
Nicola Bertazzo committed
31
  script: 
Nicola Bertazzo's avatar
Nicola Bertazzo committed
32
    - "mvn clean package -Dhttps.proxyHost=192.168.10.1 -Dhttps.proxyPort=3128"
33
  image: maven:3.3.9-jdk-8
Nicola Bertazzo's avatar
Nicola Bertazzo committed
34 35 36
  cache:
    paths:
      - target/demoapp.jar
Nicola Bertazzo's avatar
Nicola Bertazzo committed
37 38 39
  artifacts:
    paths:
      - target/demoapp.jar
40 41 42 43
  tags:
    - docker

int-test:
Nicola Bertazzo's avatar
Nicola Bertazzo committed
44
  stage: test
Nicola Bertazzo's avatar
Nicola Bertazzo committed
45
  script:
Nicola Bertazzo's avatar
Nicola Bertazzo committed
46
    - "ls ."
47 48 49 50 51
  image: maven:3.3.9-jdk-8
  tags:
    - docker

docker-build:
Nicola Bertazzo's avatar
Nicola Bertazzo committed
52
  stage: deploy
53
  script:
Nicola Bertazzo's avatar
Nicola Bertazzo committed
54
    - "whoami"
Nicola Bertazzo's avatar
Nicola Bertazzo committed
55
    - "ls ."
Nicola Bertazzo's avatar
Nicola Bertazzo committed
56
    - "docker --version"
Nicola Bertazzo's avatar
Nicola Bertazzo committed
57
    - "docker build -t 'demo-app:1.0.0' ./"
Nicola Bertazzo's avatar
Nicola Bertazzo committed
58
    - "docker run --name=prova -d -p 20000:8080 demo-app:1.0.0"
59
  tags:
Nicola Bertazzo's avatar
Nicola Bertazzo committed
60
    - docker_build