Skip to content

Commit

Permalink
Merge pull request 'feature-sonarqube-drone' into main
Browse files Browse the repository at this point in the history
- adds a drone pipeline that triggers analysis on
  a sonarqube server
- https://codeberg.org/flyingfishflash/ledger/pulls/12
  • Loading branch information
flyingfishflash committed Apr 11, 2022
2 parents 973e586 + 38f7b07 commit 42caec2
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,55 @@ steps:
- name: drone_cache
path: /drone/drone_cache

---
kind: pipeline
name: "sonarqube"
type: docker

trigger:
event:
- push
- tag

depends_on:
- "frontend - build"
- "backend - build"

volumes:
- name: drone_cache
host:
path: /var/lib/docker/volumes_managed/drone_cache

steps:
- name: cache pull
image: alpine/git
commands:
- /drone/src/scripts/ci/drone/drone-cache-pull.sh ledger-backend
volumes:
- name: drone_cache
path: /drone/drone_cache

- name: sonarqube analysis
failure: ignore
image: gradle:7.4.2-jdk17
depends_on:
- "cache pull"
environment:
SONAR_PROJECT_KEY:
from_secret: sonar_project_key
SONAR_HOST:
from_secret: sonar_host
SONAR_LOGIN:
from_secret: sonar_login
commands:
- >
/drone/src/scripts/ci/drone/drone-is-sonarqube-configured.sh &&
gradle sonarqube
-Dsonar.projectKey=$SONAR_PROJECT_KEY
-Dsonar.projectVersion=$(./scripts/version.sh version)
-Dsonar.host.url=$SONAR_HOST
-Dsonar.login=$SONAR_LOGIN
---
kind: pipeline
name: "backend - publish"
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

plugins {
id 'com.diffplug.spotless' version '6.4.2'
id "com.github.ben-manes.versions" version '0.42.0'
id "org.sonarqube" version '3.3'
}

description = 'A Java based bookkeeping engine and API server, along with an Angular based web application for personal finance management.'

ext {
}

Expand Down
29 changes: 29 additions & 0 deletions scripts/ci/drone/drone-is-sonarqube-configured.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

exitcode=0

case $SONAR_HOST in
(*[![:blank:]]*)
echo '$SONAR_HOST is not blank';;
(*)
echo '$SONAR_HOST contains only blanks or is empty or is unset'
exitcode=1;;
esac

case $SONAR_LOGIN in
(*[![:blank:]]*)
echo '$SONAR_LOGIN is not blank';;
(*)
echo '$SONAR_LOGIN contains only blanks or is empty or is unset'
exitcode=1;;
esac

case $SONAR_PROJECT_KEY in
(*[![:blank:]]*)
echo '$SONAR_PROJECT_KEY is not blank';;
(*)
echo '$SONAR_PROJECT_KEY contains only blanks or is empty or is unset'
exitcode=1;;
esac

exit $exitcode

0 comments on commit 42caec2

Please sign in to comment.