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

adds sonar.

parent 9fd19905
No related branches found
No related tags found
No related merge requests found
<!-- A MAVEN SETTINGS FILE TO BE USED IN CI -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>${env.GITHUBLOGIN}</username>
<password>${env.GITHUBPASSWORD}</password>
</server>
<server>
<id>dockerhub</id>
<username>${env.DOCKER_USERNAME}</username>
<password>${env.DOCKER_PASSWORD}</password>
</server>
<server>
<id>github.pages</id>
<username>git</username>
<configuration>
<scmVersionType>branch</scmVersionType>
<scmVersion>gh-pages</scmVersion>
</configuration>
</server>
</servers>
<profiles>
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>http://compute-lsis-2:9000</sonar.host.url>
<sonar.login>${env.SONAR_TOKEN}</sonar.login>
</properties>
</profile>
</profiles>
</settings>
...@@ -14,5 +14,15 @@ jobs: ...@@ -14,5 +14,15 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Build the Docker image - name: Build the Docker image for branch ${GITHUB_REF##*/}
run: DOCKER_BUILDKIT=1 docker build . --file ./docker/Dockerfile --tag my-image-name:$(date +%s) run: DOCKER_BUILDKIT=1 docker build . --file ./docker/Dockerfile --tag brunoe/samplejee91::${GITHUB_REF##*/}
maven-sonar:
runs-on: [ self-hosted, Linux ]
needs: maven-build
# Develop branch only
# 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
...@@ -4,7 +4,7 @@ services: ...@@ -4,7 +4,7 @@ services:
build: build:
context: . context: .
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
image: brunoe/samplejee91restapp image: brunoe/samplejee91
environment: environment:
- ADMIN_PASSWORD=admin - ADMIN_PASSWORD=admin
ports: ports:
......
mvn.sh 0 → 100755
#!/bin/bash
docker run \
--env GITHUBLOGIN="$GITHUBLOGIN" \
--env GITHUBPASSWORD="$GITHUBPASSWORD" \
--env SONAR_TOKEN="$SONAR_TOKEN" \
--volume ~/.m2:/var/maven/.m2 \
--volume ~/.sonar:/var/maven/.sonar \
--volume ~/.config:/var/maven/.config \
--volume ~/.ssh:/home/user/.ssh \
--volume ~/.gitconfig:/home/user/.gitconfig \
--volume "$(pwd)":/usr/src/mymaven \
--workdir /usr/src/mymaven \
--rm \
--env PUID="$(id -u)" -e PGID="$(id -g)" \
--env MAVEN_CONFIG=/var/maven/.m2 \
brunoe/maven:3.8.1-jdk-16 \
runuser --user user --group user -- mvn -B -e -T 1C -Duser.home=/var/maven --settings /usr/src/mymaven/.github/ci-settings.xml "$@"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment