.gitlab-ci.yml 1.58 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

Ludovic Cottret's avatar
Ludovic Cottret committed
23

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

lcottret's avatar
lcottret committed
31
32
deployCentral:
  stage: deploy
lcottret's avatar
lcottret committed
33
  before_script:
lcottret's avatar
lcottret committed
34
    - 'which ssh-agent || ( apt-get update -qy && apt-get install openssh-client -qqy )'
lcottret's avatar
lcottret committed
35
    - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
lcottret's avatar
lcottret committed
36
    - eval $(ssh-agent -s)
lcottret's avatar
lcottret committed
37
    - echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
lcottret's avatar
lcottret committed
38
39
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
lcottret's avatar
lcottret committed
40
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
lcottret's avatar
lcottret committed
41
    - 'which gpg || ( apt-get update -qy && apt-get install gnupg -qqy )'
lcottret's avatar
lcottret committed
42
    - export GPG_TTY=$(tty)
lcottret's avatar
lcottret committed
43
    - gpg -v --batch --import <(echo "${GPG_PRIVATE_KEY}")
lcottret's avatar
lcottret committed
44
  script:
lcottret's avatar
lcottret committed
45
46
    - git config --global user.email "$env:GITLAB_USER_EMAIL"
    - git config --global user.name "$env:GITLAB_USER_NAME"
lcottret's avatar
lcottret committed
47
    - git checkout -B "$CI_BUILD_REF_NAME"
48
49
    - 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
50
51
  only:
    - master