Skip to content

Commit f77013c

Browse files
nrmancusornveach
authored andcommitted
infra: fix build and plugin execution
1 parent f7f93d4 commit f77013c

File tree

1 file changed

+47
-40
lines changed

1 file changed

+47
-40
lines changed

.circleci/config.yml

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,61 @@
11
version: 2
22
jobs:
3-
build:
3+
build-project:
44
docker:
5-
- image: checkstyle/sonarqube-maven-git:7.7-community-8c1737e
5+
- image: cimg/openjdk:11.0.16
66

7+
steps:
8+
- checkout
9+
- run: mvn package -Pno-validations
10+
- persist_to_workspace:
11+
root: /home/circleci
12+
paths:
13+
- project
14+
15+
execute-sonar:
16+
docker:
17+
- image: sonarqube:9.0-community
718
working_directory: ~/repo
819

920
environment:
1021
# Customize the JVM maximum heap limit
1122
MAVEN_OPTS: -Xmx3200m
1223

1324
steps:
14-
- checkout
25+
- attach_workspace:
26+
at: /root
27+
- run:
28+
name: Install packages
29+
command: apk add maven
30+
- run:
31+
name: Copy jar
32+
command: |
33+
cp /root/project/target/checkstyle-sonar-plugin*.jar \
34+
/opt/sonarqube/extensions/plugins/
35+
- run:
36+
name: Start SonarQube web service and execute maven SonarQube build
37+
command: |
38+
# start SonarQube web server
39+
cd /opt/sonarqube/
40+
./bin/run.sh &
41+
until grep "SonarQube is up" logs/sonar.log; \
42+
do sleep 10 && echo "Waiting for web server to come up..."; \
43+
done
1544
16-
# Download and cache dependencies
17-
- restore_cache:
18-
keys:
19-
- v1-dependencies-sonarqube-{{ checksum "pom.xml" }}
20-
# fallback to using the latest cache if no exact match is found
21-
- v1-dependencies-sonarqube
45+
# Note that we cannot separate "start SonarQube web server" above from
46+
# this step, as we would kill web server when step is complete.
47+
cd /root/project
48+
mvn sonar:sonar -Dsonar.login=admin -Dsonar.password=admin
49+
- run:
50+
name: Check logs for error
51+
command: grep "ERROR" /opt/sonarqube/logs/* || test $? = 1
2252

23-
- run: mvn package -Pno-validations
24-
25-
- save_cache:
26-
paths:
27-
- ~/.m2
28-
key: v1-dependencies-sonarqube-{{ checksum "pom.xml" }}
53+
workflows:
54+
version: 2
2955

30-
# run tests
31-
- run: |-
32-
pwd
33-
POM_VERSION=$(grep "<version>" pom.xml | head -n 1 | sed -E "s/.*<version>//" | sed "s/<.*//")
34-
echo "POM_VERSION="$POM_VERSION
35-
echo "creation of jar is skipped as it was created on previous step"
36-
#mvn package -Pno-validations
37-
echo "coping jar to sonarqube ..."
38-
cp target/checkstyle-sonar-plugin-$POM_VERSION.jar /opt/sonarqube/extensions/plugins/
39-
cd /opt/sonarqube/
40-
echo "remove existing logs ..."
41-
rm -f logs/*.*
42-
echo "run sonarqube web service"
43-
./bin/run.sh &
44-
echo "sleeping 60 to let sonar start up ..."
45-
sleep 60
46-
echo "check that sonar service is up ..."
47-
grep "SonarQube is up" logs/sonar.log
48-
echo "switching back to repository code"
49-
cd -
50-
pwd
51-
echo "execution of mvn sonar:sonar ..."
52-
mvn sonar:sonar
53-
echo "grep for ERROR in logs ..."
54-
grep "ERROR" /opt/sonarqube/logs/* || test $? = 1
56+
build-sonar:
57+
jobs:
58+
- build-project
59+
- execute-sonar:
60+
requires:
61+
- build-project

0 commit comments

Comments
 (0)