Skip to content
Snippets Groups Projects
Commit 5258de6c authored by Emmanuel Bruno's avatar Emmanuel Bruno
Browse files

initial sonar.

parent f5b5b58a
No related branches found
No related tags found
No related merge requests found
...@@ -18,14 +18,10 @@ jobs: ...@@ -18,14 +18,10 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Build the Docker image for branch ${GITHUB_REF##*/} - name: Build the Docker image for branch ${GITHUB_REF##*/}
run: DOCKER_BUILDKIT=1 docker build . --file ./docker/Dockerfile --tag brunoe/samplejee91::${GITHUB_REF##*/} run: DOCKER_BUILDKIT=1 docker build . \
--env GITHUBLOGIN="$GITHUBLOGIN" \
--env GITHUBPASSWORD="$GITHUBPASSWORD" \
maven-sonar: --env SONAR_HOST="$SONAR_HOST" \
runs-on: [ self-hosted, Linux ] --env SONAR_TOKEN="$SONAR_TOKEN" \
needs: maven-build --file ./docker/Dockerfile \
# Develop branch only --tag brunoe/samplejee91:${GITHUB_REF##*/}
# if: github.ref == 'refs/heads/develop'
steps:
- name: Launch a sonar analysis
run: ./mvn.sh -D sonar.branch.name=${GITHUB_REF#refs/heads/} --activate-profiles sonar sonar:sonar && mvn --activate-profiles sonar -pl . sonar-quality-gate:check
...@@ -2,6 +2,11 @@ version: '3' ...@@ -2,6 +2,11 @@ version: '3'
services: services:
jakartaEE: jakartaEE:
build: build:
args:
- GITHUBLOGIN
- GITHUBPASSWORD
- SONAR_HOST
- SONAR_TOKEN
context: . context: .
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
image: brunoe/samplejee91 image: brunoe/samplejee91
......
# syntax=docker/dockerfile:1.3
### First we build the application in docker in a controlled env ### First we build the application in docker in a controlled env
FROM maven:3.8.4-eclipse-temurin-11 as build FROM maven:3.8.4-eclipse-temurin-11 as build
WORKDIR /app WORKDIR /app
#see https://www.jrebel.com/blog/how-to-speed-up-your-maven-build
# see https://www.baeldung.com/jvm-tiered-compilation
ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
#ENV MAVEN_CLI_OPTS="-T 1C --settings /usr/share/maven/ref/settings-docker.xml -B"
ENV MAVEN_CLI_OPTS="--settings /usr/share/maven/ref/settings-docker.xml -B"
COPY docker/settings-docker.xml /usr/share/maven/ref/
# COPY pom.xml /app/pom.xml # COPY pom.xml /app/pom.xml
COPY . /app/ COPY . /app/
RUN --mount=type=cache,id=mvncache,target=/root/.m2/repository,rw \ RUN --mount=type=cache,id=mvncache,target=/root/.m2/repository,rw \
mvn -B verify mvn $MAVEN_CLI_OPTS -Dmaven.test.skip=true verify
RUN --mount=type=cache,id=mvncache,target=/root/.m2/repository,rw \
if [ "$SONAR_TOKEN" ] ; then \
mvn $MAVEN_CLI_OPTS -D sonar.branch.name=${GITHUB_REF#refs/heads/} \
--activate-profiles sonar sonar:sonar && \
mvn $MAVEN_CLI_OPTS --activate-profiles sonar -pl . sonar-quality-gate:check ; \
fi
### Then we add the builded war to a JEE server. ### Then we add the builded war to a JEE server.
#FROM payara/server-full:5.2021.9-jdk11 as server #FROM payara/server-full:5.2021.9-jdk11 as server
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<profile> <profile>
<id>sonar</id> <id>sonar</id>
<properties> <properties>
<sonar.host.url>http://compute-lsis-2:9000</sonar.host.url> <sonar.host.url>${env.SONAR_HOST}</sonar.host.url>
<sonar.login>${env.SONAR_TOKEN}</sonar.login> <sonar.login>${env.SONAR_TOKEN}</sonar.login>
</properties> </properties>
</profile> </profile>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment