-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
99 lines (91 loc) · 3.66 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
include:
- project: kount/third_party/tpa-ci-shared
file:
- core/rules.yml
- version.yml
- base/sq-scan.yml
ref: 2.7.1
stages:
- version
- build
- test
- sonarqube scan
- deploy
variables:
#MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_CLI_OPTS: "-s settings.xml --batch-mode"
GPG_CLI_OPTS: "--pinentry-mode loopback"
# GPG_PASSPHRASE: ${GPG_PASSPHRASE}
.maven:
image: maven:3.6.0-jdk-8
before_script:
- echo ${SONATYPE_USERID}
- echo "$GPG_KEY" > private_key_sender.asc
- chmod 400 ./private_key_sender.asc
- echo '<?xml version="1.0" encoding="UTF-8"?><settings><servers><server><id>ossrh</id><username>'${SONATYPE_USERID}'</username><password>'${SONATYPE_PASSWORD}'</password></server></servers><profiles><profile><activation><activeByDefault>true</activeByDefault></activation><id>ossrh</id><properties><gpg.executable>gpg</gpg.executable><gpg.passphrase>'${GPG_PASSPHRASE}'</gpg.passphrase></properties></profile></profiles></settings>' > settings.xml
- chmod 400 ./settings.xml
- |
if [ -n "${BUILD_VERSION}" ]
then
# BUILD_VERSION is cut to 17 characters so SDK_VERSION will not exceed 32 characters in total
BUILD_VERSION=`echo $BUILD_VERSION | cut -c-17`
echo "sed -i \"s/0.0.0/${BUILD_VERSION}/g\" ${CI_PROJECT_DIR}/kount-ris-sdk/src/main/java/com/kount/ris/Config.java"
sed -i "s/0.0.0/${BUILD_VERSION}/g" ${CI_PROJECT_DIR}/kount-ris-sdk/src/main/java/com/kount/ris/Config.java
cat ${CI_PROJECT_DIR}/kount-ris-sdk/src/main/java/com/kount/ris/Config.java
POM_VERS=`echo $BUILD_VERSION`
if grep -q "-" <<< "$BUILD_VERSION";
then
BASE_VERS=`echo "$BUILD_VERSION" | sed 's/-.*//'`
NEXT_VERS=`echo "$BASE_VERS" | awk -vFS=. -vOFS=. '{++$NF;print}'`
POM_VERS="$NEXT_VERS-SNAPSHOT"
fi
echo ${POM_VERS}
mvn versions:set -DnewVersion=${POM_VERS}
mvn versions:update-child-modules
fi
build:
stage: build
extends: .maven
rules:
- !reference [.rule-on-tag]
- !reference [.rule-on-master]
- !reference [.rule-on-mr]
script:
- mvn $MAVEN_CLI_OPTS compile
artifacts:
paths:
- ${CI_PROJECT_DIR}/sdk-integration-tests/target
- ${CI_PROJECT_DIR}/kount-ris-sdk/target
- ${CI_PROJECT_DIR}/sdk-integration-tests/pom.xml
- ${CI_PROJECT_DIR}/kount-ris-sdk/pom.xml
- ${CI_PROJECT_DIR}/pom.xml
test:
stage: test
extends: .maven
rules:
- !reference [.rule-on-tag]
- !reference [.rule-on-master]
- !reference [.rule-on-mr]
script:
- mvn -DRis.MerchantId=${RIS_SDK_SANDBOX_MERCHANT_ID} -DRis.API.Key=${RIS_SDK_SANDBOX_API_KEY} -Dkount.config.key=$(echo ${RIS_CONFIG_KEY_BASE64} | openssl base64 -d) $MAVEN_CLI_OPTS verify
- mvn jacoco:report
artifacts:
paths:
- ${CI_PROJECT_DIR}/sdk-integration-tests/target/reports/jacoco-aggregate/jacoco.xml
sonarqube scan:
extends: .sq-scan
stage: sonarqube scan
allow_failure: true
variables:
SRC_EXCLUSIONS: "**/target/**,**/logs/**,**/bin/**,**/.m2/**,**/DS_Store/**,**/idea/**,**/*LICENSE,**/*.classpath,**/*.project,**/*.settings,**/*.gitignore,**/*.yml,**/test/**"
JAVA_BINARIES_PATHS: "${CI_PROJECT_DIR}/kount-ris-sdk/target/classes/com/kount"
JACOCO_COVERAGE_REPORT_PATHS: "${CI_PROJECT_DIR}/sdk-integration-tests/target/reports/jacoco-aggregate/jacoco.xml"
deploy:
stage: deploy
extends: .maven
rules:
- !reference [.rule-on-tag]
script:
- echo ${GPG_PASSPHRASE}
- gpg $GPG_CLI_OPTS --passphrase ${GPG_PASSPHRASE} --import ./private_key_sender.asc
- mvn --projects '!:sdk-integration-tests' $MAVEN_CLI_OPTS clean deploy -P release