2. Java

2.1. SonarScanner

  • sonar.properties in your repository main folder

Listing 33. Minimal Sonar Project Properties
sonar.projectKey=MyProject
sonar.projectName=MyProject
sonar.projectVersion=1.0

sonar.sources=src/main/java
sonar.java.binaries=target/classes
sonar.java.source=9

2.2. Maven

$ docker container exec -u 0 -it jenkins sh
$ mkdir -p /opt
$ cd /opt
$ wget http://apache.claz.org/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
$ tar -zxvf apache-maven-3.5.4-bin.tar.gz
$ mv apache-maven-3.5.4 /opt/maven
$ ln -s /opt/maven/bin/mvn /usr/local/bin/mvn
$ echo 'export M2_HOME=/opt/maven' > /etc/profile.d/maven.sh

Now load the environment variables in the current shell using the following command.

$ source /etc/profile.d/maven.sh

2.3. Assignments

2.3.1. Build Maven Repo

  1. Use Blue Ocean

  2. Fork repository https://github.com/AstroTech/ecosystem-example-java.git

  3. Use fork for building

  4. Use Pipeline editor to build maven with steps:

    1. mvn compile

    2. mvn test