forked from gabrie-allaigre/sonar-gitlab-plugin
-
Notifications
You must be signed in to change notification settings - Fork 24
/
.gitlab-ci.yml
73 lines (66 loc) · 1.99 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
image: maven:3.3.3-jdk-8
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
when: never
- if: $CI_COMMIT_BRANCH
stages:
- build
- publish
- test
- deploy
build_job:
stage: build
script:
- mvn --quiet clean package
cache:
key: maven
paths:
- .m2/repository
artifacts:
paths:
- target/*.jar
tags:
- docker
publish_job:
stage: publish
dependencies:
- build_job
artifacts:
paths:
- ci_settings.xml
script:
- |
jarfile=$(ls target/sonar-gitlab-plugin*.jar)
mvn deploy:deploy-file -s gitlab_settings.xml -DpomFile=pom.xml \
-Dfile=${jarfile} \
-DrepositoryId=gitlab-maven \
-Durl=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven
test_sonar_preview_job:
stage: test
except:
- master
- tags
script:
- mvn --batch-mode verify org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN -Dsonar.analysis.mode=preview -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.gitlab.project_id=$CI_PROJECT_ID
tags:
- docker
test_sonar_feature_job:
stage: test
except:
- master
- tags
script:
- mvn --batch-mode verify org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar -Dsonar.host.url=$SONAR_OFF_URL -Dsonar.login=$SONAR_OFF_LOGIN -Dsonar.branch.name=$CI_COMMIT_REF_NAME
tags:
- docker
test_sonar_job:
stage: test
only:
- master
script:
- mvn --batch-mode verify org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN
- mvn --batch-mode verify org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar -Dsonar.host.url=$SONAR_OFF_URL -Dsonar.login=$SONAR_OFF_LOGIN
tags:
- docker