-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
infra: fix build and plugin execution #434
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,61 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
build-project: | ||
docker: | ||
- image: checkstyle/sonarqube-maven-git:7.7-community-8c1737e | ||
- image: cimg/openjdk:11.0.16 | ||
|
||
steps: | ||
- checkout | ||
- run: mvn package -Pno-validations | ||
- persist_to_workspace: | ||
root: /home/circleci | ||
paths: | ||
- project | ||
|
||
execute-sonar: | ||
docker: | ||
- image: sonarqube:9.0-community | ||
working_directory: ~/repo | ||
|
||
environment: | ||
# Customize the JVM maximum heap limit | ||
MAVEN_OPTS: -Xmx3200m | ||
|
||
steps: | ||
- checkout | ||
- attach_workspace: | ||
at: /root | ||
- run: | ||
name: Install packages | ||
command: apk add maven | ||
Comment on lines
+27
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Installation of maven takes less than 5 seconds, I do not think we need custom sonar image with maven pre-installed |
||
- run: | ||
name: Copy jar | ||
command: | | ||
cp /root/project/target/checkstyle-sonar-plugin*.jar \ | ||
/opt/sonarqube/extensions/plugins/ | ||
- run: | ||
name: Start SonarQube web service and execute maven SonarQube build | ||
command: | | ||
# start SonarQube web server | ||
cd /opt/sonarqube/ | ||
./bin/run.sh & | ||
until grep "SonarQube is up" logs/sonar.log; \ | ||
do sleep 10 && echo "Waiting for web server to come up..."; \ | ||
done | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-sonarqube-{{ checksum "pom.xml" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies-sonarqube | ||
# Note that we cannot separate "start SonarQube web server" above from | ||
# this step, as we would kill web server when step is complete. | ||
cd /root/project | ||
mvn sonar:sonar -Dsonar.login=admin -Dsonar.password=admin | ||
- run: | ||
name: Check logs for error | ||
command: grep "ERROR" /opt/sonarqube/logs/* || test $? = 1 | ||
|
||
- run: mvn package -Pno-validations | ||
|
||
- save_cache: | ||
paths: | ||
- ~/.m2 | ||
key: v1-dependencies-sonarqube-{{ checksum "pom.xml" }} | ||
workflows: | ||
version: 2 | ||
|
||
# run tests | ||
- run: |- | ||
pwd | ||
POM_VERSION=$(grep "<version>" pom.xml | head -n 1 | sed -E "s/.*<version>//" | sed "s/<.*//") | ||
echo "POM_VERSION="$POM_VERSION | ||
echo "creation of jar is skipped as it was created on previous step" | ||
#mvn package -Pno-validations | ||
echo "coping jar to sonarqube ..." | ||
cp target/checkstyle-sonar-plugin-$POM_VERSION.jar /opt/sonarqube/extensions/plugins/ | ||
cd /opt/sonarqube/ | ||
echo "remove existing logs ..." | ||
rm -f logs/*.* | ||
echo "run sonarqube web service" | ||
./bin/run.sh & | ||
echo "sleeping 60 to let sonar start up ..." | ||
sleep 60 | ||
echo "check that sonar service is up ..." | ||
grep "SonarQube is up" logs/sonar.log | ||
echo "switching back to repository code" | ||
cd - | ||
pwd | ||
echo "execution of mvn sonar:sonar ..." | ||
mvn sonar:sonar | ||
echo "grep for ERROR in logs ..." | ||
grep "ERROR" /opt/sonarqube/logs/* || test $? = 1 | ||
build-sonar: | ||
jobs: | ||
- build-project | ||
- execute-sonar: | ||
requires: | ||
- build-project |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need composed images, since we can build jar and generate class files in previous step, and persist the project directory for sonar execution job.