.gitlab-ci.yml 1.65 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
12
cache:
  paths:
    - .m2/repository/
    - target/

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

test:
  stage: test
  script:
    - mvn test

Ludovic Cottret's avatar
Ludovic Cottret committed
22
verify:
Ludovic Cottret's avatar
Ludovic Cottret committed
23
  stage: test
Ludovic Cottret's avatar
Ludovic Cottret committed
24
25
26
  script:
    - mvn verify

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

lcottret's avatar
lcottret committed
34
35
deployCentral:
  stage: deploy
lcottret's avatar
lcottret committed
36
  before_script:
lcottret's avatar
lcottret committed
37
    - 'which ssh-agent || ( apt-get update -qy && apt-get install openssh-client -qqy )'
lcottret's avatar
lcottret committed
38
    - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
lcottret's avatar
lcottret committed
39
    - eval $(ssh-agent -s)
lcottret's avatar
lcottret committed
40
    - echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
lcottret's avatar
lcottret committed
41
42
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
lcottret's avatar
lcottret committed
43
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
lcottret's avatar
lcottret committed
44
    - 'which gpg || ( apt-get update -qy && apt-get install gnupg -qqy )'
lcottret's avatar
lcottret committed
45
    - export GPG_TTY=$(tty)
lcottret's avatar
lcottret committed
46
    - gpg -v --batch --import <(echo "${GPG_PRIVATE_KEY}")
lcottret's avatar
lcottret committed
47
  script:
lcottret's avatar
lcottret committed
48
49
    - git config --global user.email "$env:GITLAB_USER_EMAIL"
    - git config --global user.name "$env:GITLAB_USER_NAME"
lcottret's avatar
lcottret committed
50
    - git checkout -B "$CI_BUILD_REF_NAME"
51
52
    - mvn $MAVEN_CLI_OPTS build-helper:parse-version versions:set -DnewVersion="\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT" versions:commit
    - mvn $MAVEN_CLI_OPTS release:prepare -DautoVersionSubmodules=true -Dmaven.test.skip=true -DscmCommentPrefix="[skip ci]"
53
    - mvn $MAVEN_CLI_OPTS release:perform -Darguments=-Dgpg.passphrase=${GPG_PASSPHRASE}
lcottret's avatar
lcottret committed
54
55
56
  only:
    - /^release.*$/