Skip to content

Commit

Permalink
[sonar] Setup Sonar analysis using Jenkins pipelines (eclipse-kitalph…
Browse files Browse the repository at this point in the history
…a#19)

* [sonar] Setup Sonar analysis using Jenkins pipelines

- Configure sonar analysis from pipeline
- Cleanup pom & Jenkinsfile
- Remove jacoco & sonar plugins from pom

Change-Id: I07e0aea9792a20b057a7c2730139d7dbff26f7d1

* [releng] Fix environment variables setting

Change-Id: I50f0e0a4f23ebcc3973f5f433919b91bcbb571c2

* [releng] Missing script block in pipeline

Change-Id: Iab68d287ac607eae0560fb1c2f66b242cb034554

* [releng] Fix faulty "providerName" attribute value

Change-Id: I6bd355c55b9ae8e4c2b51c7df9181ade5bd3eeab

* [releng] Revert appArgLine reformat for dropins creation

Change-Id: I9f462de4545e9fe2faf874910d1463a29b769185
  • Loading branch information
arnauddieumegard authored Apr 23, 2021
1 parent d1b16c4 commit ddbf556
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 98 deletions.
114 changes: 74 additions & 40 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,76 @@
pipeline {
agent { label 'migration' }

tools {
maven 'apache-maven-latest'
jdk 'openjdk-jdk14-latest'
}
stages {
stage('Package introspector addon') {
steps {
wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: true]) {
sh 'mvn -Dmaven.test.failure.ignore=true clean verify -P introspector -e -f pom.xml'
}
}
}
stage('Archive artifacts') {
steps {
archiveArtifacts artifacts: 'releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.all.site/target/PDTTooling_*.zip, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.docgen.site/target/PDTTooling_*.zip, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.model.site/target/PDTTooling_*.zip, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.modeler.site/target/PDTTooling_*.zip, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.site/target/PDTTooling_*.zip, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.all.site/target/repository/**, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.docgen.site/target/repository/**, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.model.site/target/repository/**, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.modeler.site/target/repository/**, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.site/target/repository/**'
}
}
stage('Deploy') {
when {
not { changeRequest() }
}
steps {
sshagent ( ['projects-storage.eclipse.org-bot-ssh']) {
sh '''
echo "deploy update site"
DST_DIR=/home/data/httpd/download.eclipse.org/kitalpha/addons/introspector/nightly/master
ssh [email protected] rm -rf ${DST_DIR}
ssh [email protected] mkdir -p ${DST_DIR}
ssh [email protected] mkdir -p ${DST_DIR}/updates/
ssh [email protected] mkdir -p ${DST_DIR}/dropins/
scp -r releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.all.site/target/repository/* [email protected]:${DST_DIR}/updates/
scp -r releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.all.site/target/PDTTooling_All-dropins-*.zip [email protected]:${DST_DIR}/dropins/
'''
}
}
}
}
agent { label 'migration' }

tools {
maven 'apache-maven-latest'
jdk 'openjdk-jdk14-latest'
}
environment {
JACOCO_VERSION = "0.8.6"
MVN_QUALITY_PROFILES = '-P introspector'
JACOCO_EXEC_FILE_PATH = '${WORKSPACE}/jacoco.exec'
}
stages {
stage('Package Introspector Addon') {
steps {
wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: true]) {
script {
def jacocoPrepareAgent = "-Djacoco.destFile=$JACOCO_EXEC_FILE_PATH -Djacoco.append=true org.jacoco:jacoco-maven-plugin:$JACOCO_VERSION:prepare-agent"
sh 'mvn -Dmaven.test.failure.ignore=true ${jacocoPrepareAgent} clean verify -P introspector -e -f pom.xml'
}
}
}
}
stage('Archive artifacts') {
steps {
archiveArtifacts artifacts: 'releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.all.site/target/PDTTooling_*.zip, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.docgen.site/target/PDTTooling_*.zip, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.model.site/target/PDTTooling_*.zip, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.modeler.site/target/PDTTooling_*.zip, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.site/target/PDTTooling_*.zip, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.all.site/target/repository/**, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.docgen.site/target/repository/**, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.model.site/target/repository/**, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.modeler.site/target/repository/**, releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.site/target/repository/**'
}
}
stage('Deploy') {
when {
not { changeRequest() }
}
steps {
sshagent ( ['projects-storage.eclipse.org-bot-ssh']) {
sh '''
echo "deploy update site"
DST_DIR=/home/data/httpd/download.eclipse.org/kitalpha/addons/introspector/nightly/master
ssh [email protected] rm -rf ${DST_DIR}
ssh [email protected] mkdir -p ${DST_DIR}
ssh [email protected] mkdir -p ${DST_DIR}/updates/
ssh [email protected] mkdir -p ${DST_DIR}/dropins/
scp -r releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.all.site/target/repository/* [email protected]:${DST_DIR}/updates/
scp -r releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.all.site/target/PDTTooling_All-dropins-*.zip [email protected]:${DST_DIR}/dropins/
'''
}
}
}
stage('Publish tests results') {
steps {
junit allowEmptyResults: true, testResults: '*.xml,**/target/surefire-reports/*.xml'
sh "mvn -Djacoco.dataFile=$JACOCO_EXEC_FILE_PATH org.jacoco:jacoco-maven-plugin:$JACOCO_VERSION:report $MVN_QUALITY_PROFILES -e -f pom.xml"
}
}
stage('Perform Sonar analysis') {
environment {
PROJECT_NAME = 'kitalpha-addons'
SONARCLOUD_TOKEN = credentials('sonar-token-kitalpha-addons')
SONAR_PROJECT_KEY = 'eclipse_kitalpha-addons'
}
steps {
withEnv(['MAVEN_OPTS=-Xmx4g']) {
script {
def jacocoParameters = "-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml -Dsonar.java.coveragePlugin=jacoco -Dsonar.core.codeCoveragePlugin=jacoco "
def sonarExclusions = "-Dsonar.exclusions='**/generated/**/*.java,**/src-gen/**/*.java' "
def javaVersion = "8"
def sonarCommon = "sonar:sonar -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.organization=eclipse -Dsonar.host.url=https://sonarcloud.io -Dsonar.login='$SONARCLOUD_TOKEN' -Dsonar.skipDesign=true -Dsonar.dynamic=reuseReports -Dsonar.java.source=${javaVersion} -Dsonar.scanner.force-deprecated-java-version=true "
def sonarBranchAnalysis = "-Dsonar.branch.name=${BRANCH_NAME}"
def sonarPullRequestAnalysis = ("${BRANCH_NAME}".contains('PR-') ? "-Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=eclipse/$PROJECT_NAME -Dsonar.pullrequest.key=${CHANGE_ID} -Dsonar.pullrequest.branch=${CHANGE_BRANCH}" : "" )
def sonar = sonarCommon + jacocoParameters + sonarExclusions + ("${BRANCH_NAME}".contains('PR-') ? sonarPullRequestAnalysis : sonarBranchAnalysis)
sh "mvn ${sonar} $MVN_QUALITY_PROFILES -e -f pom.xml"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
id="org.polarsys.kitalpha.pdt.metamodel.feature"
label="%featureName"
version="5.1.0.qualifier"
provider-name="%ProviderName">
provider-name="%providerName">

<description>
%description
Expand Down
99 changes: 42 additions & 57 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,85 +18,80 @@
<artifactId>org.polarsys.kitalpha.addons</artifactId>
<version>5.1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<tycho-version>2.0.0</tycho-version>
<tycho-extras-version>2.0.0</tycho-extras-version>
<tycho.scmUrl>scm:git:https://github.com/eclipse/kitalpha-addons.git/</tycho.scmUrl>
<antrun-version>1.8</antrun-version>
<jacoco-version>0.8.6</jacoco-version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>

<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>

<!-- for junit -->
<tycho.testArgLine>-Xms256m -Xmx1024m</tycho.testArgLine>

<!-- for packaging -->
<platform-name>2019-06</platform-name>
<eclipse-repo.url>http://download.eclipse.org/releases/${platform-name}</eclipse-repo.url>
<packagedAddonName>PDTTooling</packagedAddonName>

<!-- for sonar -->
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.jacoco.reportPath>${project.basedir}/../../target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.jacoco.itReportPath>${project.basedir}/../../target/jacoco-it.exec</sonar.jacoco.itReportPath>
</properties>

<profiles>
<profile>
<id>introspector</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>

<modules>
<!-- Target -->
<module>releng/org.polarsys.kitalpha.pdt.introspector.targets</module>

<!-- Features -->
<module>introspector/features/org.polarsys.kitalpha.pdt.introspector.feature</module>
<module>introspector/features/org.polarsys.kitalpha.pdt.introspector.ui.feature</module>

<module>introspector/features/org.polarsys.kitalpha.pdt.modeler.feature</module>

<module>introspector/features/org.polarsys.kitalpha.pdt.metamodel.feature</module>

<module>introspector/features/org.polarsys.kitalpha.pdt.docgen.feature</module>
<module>introspector/features/org.polarsys.kitalpha.pdt.docgen.ui.feature</module>



<!-- Plugins -->
<module>introspector/plugins/org.polarsys.kitalpha.pdt.introspector.core</module>
<module>introspector/plugins/org.polarsys.kitalpha.pdt.introspector.preferences</module>
<module>introspector/plugins/org.polarsys.kitalpha.pdt.introspector.ui</module>

<module>introspector/plugins/org.polarsys.kitalpha.pdt.modeler.utils</module>
<module>introspector/plugins/org.polarsys.kitalpha.pdt.modeler.design</module>
<module>introspector/plugins/org.polarsys.kitalpha.pdt.modeler.resources</module>

<module>introspector/plugins/org.polarsys.kitalpha.pdt.metamodel.validation</module>
<module>introspector/plugins/org.polarsys.kitalpha.pdt.metamodel</module>
<module>introspector/plugins/org.polarsys.kitalpha.pdt.metamodel.model</module>
<module>introspector/plugins/org.polarsys.kitalpha.pdt.metamodel.edit</module>
<module>introspector/plugins/org.polarsys.kitalpha.pdt.metamodel.editor</module>

<module>introspector/plugins/org.polarsys.kitalpha.pdt.docgen</module>
<module>introspector/plugins/org.polarsys.kitalpha.pdt.docgen.ui</module>
<module>introspector/plugins/org.polarsys.kitalpha.pdt.docgen.wizard</module>

<!-- Sites -->
<module>releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.site</module>
<module>releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.modeler.site</module>
<module>releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.model.site</module>
<module>releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.docgen.site</module>
<module>releng/sites/introspector/org.polarsys.kitalpha.pdt.introspector.all.site</module>

</modules>
</profile>
</profiles>

<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>src</testSourceDirectory>
Expand Down Expand Up @@ -158,25 +153,38 @@
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-version}</version>
<configuration>
<destFile>${sonar.jacoco.reportPath}</destFile>
</configuration>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>plugin-source</id>
<goals>
<goal>prepare-agent</goal>
<goal>plugin-source</goal>
</goals>
</execution>
</executions>
<configuration>
<strictSrcIncludes>false</strictSrcIncludes>
</configuration>
</plugin>
<!-- enable source feature generation -->
<!-- <plugin>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-source-feature-plugin</artifactId>
<version>${tycho-extras-version}</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<excludes>
<feature id="org.polarsys.kitalpha.pdt.docgen.feature"/>
<feature id="org.polarsys.kitalpha.pdt.docgen.ui.feature"/>
<feature id="org.polarsys.kitalpha.pdt.introspector.feature"/>
<feature id="org.polarsys.kitalpha.pdt.introspector.ui.feature"/>
<feature id="org.polarsys.kitalpha.pdt.metamodel.feature"/>
<feature id="org.polarsys.kitalpha.pdt.modeler.feature"/>
</excludes>
</configuration>
<executions>
<execution>
<id>source-feature</id>
Expand All @@ -186,22 +194,6 @@
</goals>
</execution>
</executions>
</plugin> -->
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>plugin-source</id>
<goals>
<goal>plugin-source</goal>
</goals>
</execution>
</executions>
<configuration>
<strictSrcIncludes>false</strictSrcIncludes>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
Expand Down Expand Up @@ -338,13 +330,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-version}</version>
</plugin>

</plugins>
</pluginManagement>
</build>
Expand Down

0 comments on commit ddbf556

Please sign in to comment.