-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
80 lines (69 loc) · 2.86 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
image: docker:latest
services:
- docker:dind
stages:
- deploy
- release
variables:
MAVEN_OPTS: "-Djava.awt.headless=true -Dsonar.host.url=$SONAR_HOST_URL"
MAVEN_CLI_OPTS: "-s .m2/settings.xml -Dmaven.repo.local=./.m2/repository -Dnexus.url=$NEXUS_URL -Dnexus.login=$NEXUS_USERNAME -Dnexus.pwd=$NEXUS_PASSWORD --batch-mode --errors --fail-at-end --show-version"
MAVEN_CLI_CENTRAL_OPTS: "-s .m2/settings.xml -Dmaven.repo.local=./.m2/repository -Pmaven-central -Dnexus.url=$NEXUS_URL -Dsonatype.login=$SONATYPE_USERNAME -Dsonatype.pwd=$SONATYPE_PASSWORD -DskipTests --batch-mode --errors --fail-at-end --show-version"
cache:
paths:
- ./.m2/repository
# keep cache across branch
key: "$CI_BUILD_REF_NAME"
maven-deploy:
stage: deploy
image: maven:alpine
script: "mvn clean deploy $MAVEN_CLI_OPTS -Pprod"
artifacts:
paths:
- target/*.jar
only:
- master
except:
- tags
maven-install:
stage: deploy
image: maven:alpine
script: "mvn clean install $MAVEN_CLI_OPTS"
artifacts:
paths:
- target/*.jar
except:
- tags
- master
#la release è opzionale e manuale.
Perform Maven Release:
stage: release
image: maven:alpine
script:
- 'which git || (apk add --update git && rm -rf /var/cache/apk/*)'
# Install ssh-agent if not already installed, it is required by Docker.
# (change apt-get to yum if you use a CentOS-based image)
- 'which ssh-agent || ( apk add --update openssh-client && rm -rf /var/cache/apk/*)'
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in GIT_SSH_PRIV_KEY variable to the agent store
- ssh-add <(echo "$GIT_SSH_PRIV_KEY")
# For Docker builds disable host key checking. Be aware that by adding that
# you are susceptible to man-in-the-middle attacks.
# WARNING: Use this only with the Docker executor, if you use it with shell
# you will overwrite your user's SSH config.
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- git config --global user.email "marco.spasiano@cnr.it"
- git config --global user.name "marco.spasiano"
- git checkout -B "$CI_BUILD_REF_NAME"
# Add gpg private key
- 'which gnupg || ( apk add --update gnupg && rm -rf /var/cache/apk/*)'
- gpg -v --list-keys
- echo "pinentry-mode loopback" > /root/.gnupg/gpg.conf
- echo "allow-loopback-pinentry" > /root/.gnupg/gpg-agent.conf
- gpg --batch --import <(echo "$GPG_PRIVATE_KEY")
- mvn release:clean release:prepare -Darguments="-Dgpg.passphrase=$GPG_PASSPHRASE -DskipTests" -Dresume=false -B $MAVEN_CLI_CENTRAL_OPTS -DscmCommentPrefix="[ci skip]"
- mvn release:perform -Darguments="-Dgpg.passphrase=$GPG_PASSPHRASE -DskipTests" -Dresume=false -B $MAVEN_CLI_CENTRAL_OPTS -DscmCommentPrefix="[ci skip]"
only:
- master
when: manual