-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
82 lines (73 loc) · 2.69 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
variables:
# fix for old git version
GIT_STRATEGY: clone
GIT_SSL_NO_VERIFY: "true"
# config Maven
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
# config SonarQube
SONAR_MAVEN_GOAL: org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar
SONAR_USER_HOME: /builds/sonar
# config CLM
CLM_MAVEN_GOAL: com.sonatype.clm:clm-maven-plugin:2.12.1:evaluate
CLM_SERVER_ID: clm_server
CLM_APPLICATION_ID: REFERENTIELS-OFS
default:
image:
name: $DOCKER_URL/maven:3.8.4-jdk-11
cache:
paths:
- ./.m2/repository
# keep cache across branch
key: "$CI_COMMIT_REF_SLUG"
stages:
- build
- sonarqube
- clm
- deploy
- release
build:
stage: build
script:
- mvn $MAVEN_CLI_OPTS package $SONAR_MAVEN_GOAL -Dsonar.host.url=$SonarQube_URL -Dsonar.analysis.mode=preview -Dsonar.gitlab.commit_sha=$(git log --pretty=format:%H origin/master..$CI_COMMIT_SHA | tr '\n' ',') -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.unique_issue_per_inline=true -Dsonar.gitlab.max_blocker_issues_gate=-1 -Dsonar.gitlab.max_critical_issues_gate=-1
except :
- master
sonarqube:
stage: sonarqube
script:
- mvn $MAVEN_CLI_OPTS install $SONAR_MAVEN_GOAL -Dsonar.host.url=$SonarQube_URL -Dsonar.login=$SONAR_LOGIN -Dsonar.gitlab.project_id=$CI_PROJECT_PATH -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.gitlab.max_blocker_issues_gate=-1 -Dsonar.gitlab.max_critical_issues_gate=-1
only:
- master
clm:
stage: clm
script:
- mvn $MAVEN_CLI_OPTS $CLM_MAVEN_GOAL -Dclm.applicationId=$CLM_APPLICATION_ID -Dclm.serverUrl=$CLM_URL -Dclm.serverId=$CLM_SERVER_ID
only:
- master
deploy:
stage: deploy
script:
- mvn $MAVEN_CLI_OPTS deploy -Dmaven.test.skip=true
only:
- master
deploy-image:
stage: deploy
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- echo "{\"auths\":{\"$Nexus_REPO_URL\":{\"username\":\"$Nexus_REPO_USER\",\"password\":\"$Nexus_REPO_PASS\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
when: manual
only:
- master
release:
stage: release
script:
- git config --global user.email "$RUNNER_EMAIL"
- git config --global user.name "$RUNNER_USERNAME"
- git checkout $CI_COMMIT_REF_NAME
- mvn $MAVEN_CLI_OPTS release:prepare release:perform -Dresume=false -Darguments="-DskipTests" -DskipTests -Dusername=$SCM_USER -Dpassword=$SCM_PASSWORD -DautoVersionSubmodules=true -U
when: manual
only:
- master