-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Jenkins pipeline for performing Sonar analysis
Signed-off-by: Kai Hudalla <[email protected]>
- Loading branch information
1 parent
d9150f1
commit eba2374
Showing
1 changed file
with
140 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
|
||
/** | ||
* Jenkins pipeline script for perfoming Sonar analysis. | ||
* | ||
*/ | ||
|
||
pipeline { | ||
agent { | ||
kubernetes { | ||
label 'my-agent-pod' | ||
yaml """ | ||
apiVersion: v1 | ||
kind: Pod | ||
spec: | ||
containers: | ||
- name: maven | ||
image: "maven:3.8-openjdk-11" | ||
tty: true | ||
command: | ||
- cat | ||
volumeMounts: | ||
- mountPath: /home/jenkins | ||
name: "jenkins-home" | ||
- mountPath: /home/jenkins/.ssh | ||
name: "volume-known-hosts" | ||
- name: "settings-xml" | ||
mountPath: /home/jenkins/.m2/settings.xml | ||
subPath: settings.xml | ||
readOnly: true | ||
- name: "settings-security-xml" | ||
mountPath: /home/jenkins/.m2/settings-security.xml | ||
subPath: settings-security.xml | ||
readOnly: true | ||
- name: "m2-repo" | ||
mountPath: /home/jenkins/.m2/repository | ||
- name: "toolchains-xml" | ||
mountPath: /home/jenkins/.m2/toolchains.xml | ||
subPath: toolchains.xml | ||
readOnly: true | ||
env: | ||
- name: "HOME" | ||
value: "/home/jenkins" | ||
resources: | ||
limits: | ||
memory: "6Gi" | ||
cpu: "2" | ||
requests: | ||
memory: "6Gi" | ||
cpu: "2" | ||
volumes: | ||
- name: "jenkins-home" | ||
emptyDir: {} | ||
- name: "m2-repo" | ||
emptyDir: {} | ||
- configMap: | ||
name: known-hosts | ||
name: "volume-known-hosts" | ||
- name: "settings-xml" | ||
secret: | ||
secretName: m2-secret-dir | ||
items: | ||
- key: settings.xml | ||
path: settings.xml | ||
- name: "settings-security-xml" | ||
secret: | ||
secretName: m2-secret-dir | ||
items: | ||
- key: settings-security.xml | ||
path: settings-security.xml | ||
- name: "toolchains-xml" | ||
configMap: | ||
name: m2-dir | ||
items: | ||
- key: toolchains.xml | ||
path: toolchains.xml | ||
""" | ||
} | ||
} | ||
|
||
options { | ||
buildDiscarder(logRotator(numToKeepStr: '3')) | ||
disableConcurrentBuilds() | ||
timeout(time: 45, unit: 'MINUTES') | ||
} | ||
|
||
triggers { | ||
cron('TZ=Europe/Berlin\n# every night between 2 and 3 AM\nH 2 * * *') | ||
} | ||
|
||
stages { | ||
|
||
stage('Build and run Sonar analysis on master branch') { | ||
steps { | ||
container('maven') { | ||
echo "checking out branch [master] ..." | ||
checkout([$class : 'GitSCM', | ||
branches : [[name: "refs/heads/master"]], | ||
userRemoteConfigs: [[url: 'https://github.com/eclipse/hono.git']]]) | ||
|
||
withSonarQubeEnv(credentialsId: 'sonarcloud-token', installationName: 'SonarCloudOne') { | ||
echo "building and running Sonar analysis ..." | ||
sh 'mvn verify sonar:sonar -Djacoco.skip=false -DnoDocker -DcreateJavadoc=true -Dsonar.organization=eclipse -Dsonar.projectKey=org.eclipse.hono ' | ||
} | ||
|
||
echo "recording JUnit test results ..." | ||
junit '**/surefire-reports/*.xml' | ||
} | ||
} | ||
|
||
} | ||
} | ||
/** | ||
post { | ||
fixed { | ||
step([$class : 'Mailer', | ||
notifyEveryUnstableBuild: true, | ||
recipients : 'hono-dev@eclipse.org', | ||
sendToIndividuals : false]) | ||
} | ||
failure { | ||
step([$class : 'Mailer', | ||
notifyEveryUnstableBuild: true, | ||
recipients : 'hono-dev@eclipse.org', | ||
sendToIndividuals : false]) | ||
} | ||
} | ||
*/ | ||
} |