.gitlab-ci.yml 1.57 KB
Newer Older
lcottret's avatar
lcottret committed
1
image: maven:3.6-adoptopenjdk-14
Ludovic Cottret's avatar
Ludovic Cottret committed
2

Ludovic Cottret's avatar
Ludovic Cottret committed
3
variables:
lcottret's avatar
lcottret committed
4
5
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
Ludovic Cottret's avatar
Ludovic Cottret committed
6

Ludovic Cottret's avatar
Ludovic Cottret committed
7
8
9
10
11
cache:
  paths:
    - .m2/repository/

build:
Ludovic Cottret's avatar
Ludovic Cottret committed
12
13
14
15
16
17
18
  stage: build
  script:
    - mvn compile

test:
  stage: test
  script:
Ludovic Cottret's avatar
Ludovic Cottret committed
19
20
21
    - mvn clean test
    - cat coverage/target/site/jacoco-aggregate/index.html | grep -o '<tfoot>.*</tfoot>'

Ludovic Cottret's avatar
Ludovic Cottret committed
22
23
24
deploySnapshot:
  stage: deploy
  script:
lcottret's avatar
lcottret committed
25
26
27
    - mvn $MAVEN_CLI_OPTS deploy -Dmaven.test.skip=true
  only:
    - develop
Ludovic Cottret's avatar
Ludovic Cottret committed
28

lcottret's avatar
lcottret committed
29
30
deployCentral:
  stage: deploy
lcottret's avatar
lcottret committed
31
  before_script:
lcottret's avatar
lcottret committed
32
    - 'which ssh-agent || ( apt-get update -qy && apt-get install openssh-client -qqy )'
lcottret's avatar
lcottret committed
33
    - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
lcottret's avatar
lcottret committed
34
    - eval $(ssh-agent -s)
lcottret's avatar
lcottret committed
35
    - echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
lcottret's avatar
lcottret committed
36
37
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
lcottret's avatar
lcottret committed
38
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
lcottret's avatar
lcottret committed
39
    - 'which gpg || ( apt-get update -qy && apt-get install gnupg -qqy )'
lcottret's avatar
lcottret committed
40
    - export GPG_TTY=$(tty)
lcottret's avatar
lcottret committed
41
    - gpg -v --batch --import <(echo "${GPG_PRIVATE_KEY}")
lcottret's avatar
lcottret committed
42
  script:
lcottret's avatar
lcottret committed
43
44
    - git config --global user.email "$env:GITLAB_USER_EMAIL"
    - git config --global user.name "$env:GITLAB_USER_NAME"
lcottret's avatar
lcottret committed
45
    - git checkout -B "$CI_BUILD_REF_NAME"
46
47
    - mvn $MAVEN_CLI_OPTS release:prepare -DautoVersionSubmodules=true -Dmaven.test.skip=true -DscmCommentPrefix="[skip ci]" -DupdateWorkingCopyVersions=false -DpushChanges=false
    - mvn $MAVEN_CLI_OPTS release:perform -Darguments=-Dgpg.passphrase=${GPG_PASSPHRASE} -DlocalCheckout=true
lcottret's avatar
lcottret committed
48
49
  only:
    - master