forked from eclipse-kitalpha/kitalpha-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sonar] Setup Sonar analysis using Jenkins pipelines (eclipse-kitalph…
…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
1 parent
d1b16c4
commit ddbf556
Showing
3 changed files
with
117 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters