.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
4
5
6
variables:
   MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
   MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"

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
30
31
32
33
deploySnapshot:
  stage: deploy
  script:
    - mvn $MAVEN_CLI_OPTS deploy -Dmaven.test.skip=true 
  only: 
   - develop

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'

      ##
      ## Run ssh-agent (inside the build environment)
      ##
      - eval $(ssh-agent -s)

      ##
      ## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
      ## We're using tr to fix line endings which makes ed25519 keys work
      ## without extra base64 encoding.
      ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
      ##
      - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -

      ##
      ## Create the SSH directory and give it the right permissions
      ##
      - mkdir -p ~/.ssh
      - chmod 700 ~/.ssh
lcottret's avatar
lcottret committed
58
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
lcottret's avatar
lcottret committed
59
  script:
lcottret's avatar
lcottret committed
60
61
    - git config --global user.email "$env:GITLAB_USER_EMAIL"
    - git config --global user.name "$env:GITLAB_USER_NAME"
lcottret's avatar
lcottret committed
62
63
    - mvn $MAVEN_CLI_OPTS --batch-mode release:prepare -DautoVersionSubmodules=true -Dmaven.test.skip=true
    - mvn release:perform
lcottret's avatar
lcottret committed
64
65
66
  only:
    - /^release.*$/